linopy.expressions.merge#
- linopy.expressions.merge(exprs, *add_exprs, dim='_term', cls=None, join=None, fill_value=None, **kwargs)#
Merge multiple expression together.
This function is a bit faster than summing over multiple linear expressions. In case a list of LinearExpression with exactly the same shape is passed and the dimension to concatenate on is TERM_DIM, the concatenation uses the coordinates of the first object as a basis which overrides the coordinates of the consecutive objects.
- Parameters:
*exprs (
tuple/list) – List of linear expressions to merge.dim (
str) – Dimension along which the expressions should be concatenated.cls (
type) – Explicitly set the type of the resulting expression (So that the type checker will know the return type)join (
str, optional) – How to align coordinates. One of “outer”, “inner”, “left”, “right”, “exact”, “override”. When None (default), auto-detects based on expression shapes.fill_value (
ABSENT, optional) – Passlinopy.ABSENTto leave the positions the join creates absent instead of contributing the zero expression there. Requires an explicitjoinand the v1 semantics.**kwargs – Additional keyword arguments passed to xarray.concat. Defaults to {coords: “minimal”, compat: “override”} or, in the special case described above, to {coords: “minimal”, compat: “override”, “join”: “override”}.
- Returns:
res (
linopy.LinearExpressionorlinopy.QuadraticExpression)
Notes
Under v1 an absent slot of any operand stays absent in the result (§6), so the term reduction runs with
skipna=Falseinstead of collapsing NaN to the additive (or, for the quadratic build, multiplicative) identity.