Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 34 additions & 33 deletions linopy/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,8 @@ def _align_constant(
Fill value for missing coordinates.
join : str, optional
Alignment method. If None, the default is determined by
``options["semantics"]`` — ``"exact"`` under ``v1``, the
``options["semantics"]`` — under ``v1`` shared dimensions must
carry the same label set (a pure reorder aligns by label), the
legacy size-aware behavior under ``legacy``.

Returns
Expand Down Expand Up @@ -1067,10 +1068,10 @@ def add(
The expression to add.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
semantics default: "exact" under v1 (order-independent — a pure
reorder aligns by label, only a differing label set raises), the
legacy positional behavior under legacy.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
if join is None:
return self.__add__(other)
Expand All @@ -1097,10 +1098,10 @@ def sub(
The expression to subtract.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
semantics default: "exact" under v1 (order-independent — a pure
reorder aligns by label, only a differing label set raises), the
legacy positional behavior under legacy.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
return self.add(-other, join=join)

Expand All @@ -1118,10 +1119,10 @@ def mul(
The factor to multiply by.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
semantics default: "exact" under v1 (order-independent — a pure
reorder aligns by label, only a differing label set raises), the
legacy positional behavior under legacy.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
if join is None:
return self.__mul__(other)
Expand All @@ -1145,10 +1146,10 @@ def div(
The divisor.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
semantics default: "exact" under v1 (order-independent — a pure
reorder aligns by label, only a differing label set raises), the
legacy positional behavior under legacy.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
if join is None:
return self.__div__(other)
Expand All @@ -1174,10 +1175,10 @@ def le(
Right-hand side of the constraint.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
semantics default: "exact" under v1 (order-independent — a pure
reorder aligns by label, only a differing label set raises), the
legacy positional behavior under legacy.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
return self.to_constraint(LESS_EQUAL, rhs, join=join)

Expand All @@ -1195,10 +1196,10 @@ def ge(
Right-hand side of the constraint.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
semantics default: "exact" under v1 (order-independent — a pure
reorder aligns by label, only a differing label set raises), the
legacy positional behavior under legacy.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
return self.to_constraint(GREATER_EQUAL, rhs, join=join)

Expand All @@ -1216,10 +1217,10 @@ def eq(
Right-hand side of the constraint.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
semantics default: "exact" under v1 (order-independent — a pure
reorder aligns by label, only a differing label set raises), the
legacy positional behavior under legacy.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
return self.to_constraint(EQUAL, rhs, join=join)

Expand Down Expand Up @@ -1479,10 +1480,10 @@ def to_constraint(
raise a ValueError. NaN entries in the RHS mean "no constraint".
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
semantics default: "exact" under v1 (order-independent — a pure
reorder aligns by label, only a differing label set raises), the
legacy positional behavior under legacy.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.

Returns
-------
Expand Down
42 changes: 28 additions & 14 deletions linopy/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,10 @@ def add(
The expression to add.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
current default behavior.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
return self.to_linexpr().add(other, join=join)

Expand All @@ -642,8 +644,10 @@ def sub(
The expression to subtract.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
current default behavior.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
return self.to_linexpr().sub(other, join=join)

Expand All @@ -659,8 +663,10 @@ def mul(
The coefficient to multiply by.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
current default behavior.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
return self.to_linexpr().mul(other, join=join)

Expand All @@ -676,8 +682,10 @@ def div(
The divisor.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
current default behavior.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
return self.to_linexpr().div(other, join=join)

Expand All @@ -691,8 +699,10 @@ def le(self, rhs: SideLike, join: JoinOptions | None = None) -> Constraint:
Right-hand side of the constraint.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
current default behavior.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
return self.to_linexpr().le(rhs, join=join)

Expand All @@ -706,8 +716,10 @@ def ge(self, rhs: SideLike, join: JoinOptions | None = None) -> Constraint:
Right-hand side of the constraint.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
current default behavior.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
return self.to_linexpr().ge(rhs, join=join)

Expand All @@ -721,8 +733,10 @@ def eq(self, rhs: SideLike, join: JoinOptions | None = None) -> Constraint:
Right-hand side of the constraint.
join : str, optional
How to align coordinates. One of "outer", "inner", "left",
"right", "exact", "override". When None (default), uses the
current default behavior.
"right", "exact", "override". When None (default), follows the
semantics setting: under v1, shared dimensions must carry the
same label set — a pure reorder aligns by label, a differing set
raises; under legacy, positional alignment.
"""
return self.to_linexpr().eq(rhs, join=join)

Expand Down