Commit ee62dcc
refac: introduce consistent convention for linopy operations with subsets and supersets (#572)
* refac: introduce consistent convention for linopy operations with subsets and supersets
* move scalar addition to add_constant
* add overwriting logic to add constant
* add join parameter to control alignment in operations
* Add le, ge, eq methods with join parameter for constraints
Add le(), ge(), eq() methods to LinearExpression and Variable classes,
mirroring the pattern of add/sub/mul/div methods. These methods support
the join parameter for flexible coordinate alignment when creating constraints.
* Extract constant alignment logic into _align_constant helper
Consolidate repetitive alignment handling in _add_constant and
_apply_constant_op into a single _align_constant method. This
eliminates code duplication and makes the alignment behavior
(handling join parameter, fill_value, size-aware defaults) testable
and maintainable in one place.
* update notebooks
* update release notes
* fix types
* add regression test
* fix numpy array dim mismatch in constraints and add RHS dim tests
numpy_to_dataarray no longer inflates ndim beyond arr.ndim, fixing
lower-dim numpy arrays as constraint RHS. Also reject higher-dim
constant arrays (numpy/pandas) consistently with DataArray behavior.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* remove pandas reindexing warning
* Fix mypy errors: type ignores for xr.align/merge, match override signature, add test type hints
* remove outdated warning tests
* reintroduce expansions of extra rhs dims, fix multiindex alignment
* refactor test fixtures and use sign constants
* add tests for pandas series subset/superset
* test: add TestMissingValues for same-shape constants with NaN entries
* Fix broken test imports, stray docstring char, and incorrect test assertion from fixture refactor
* Fill NaN with neutral elements in expression arithmetic, preserve NaN as 'no constraint' in RHS
- Fill NaN with 0 (add/sub) or fill_value (mul/div) in _add_constant/_apply_constant_op
- Fill NaN coefficients with 0 in Variable.to_linexpr
- Restore NaN mask in to_constraint() so subset RHS still signals unconstrained positions
* Fix CI doctest collection by deferring linopy import in test/conftest.py
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 4f999c8 commit ee62dcc
File tree
18 files changed
+2032
-233
lines changed- doc
- examples
- linopy
- test
18 files changed
+2032
-233
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | 113 | | |
135 | 114 | | |
136 | 115 | | |
| |||
140 | 119 | | |
141 | 120 | | |
142 | 121 | | |
| 122 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
7 | 13 | | |
8 | 14 | | |
9 | 15 | | |
| |||
0 commit comments