You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refac: introduce consistent convention for linopy operations with subsets and supersets (PyPSA#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>
- Fixes superset DataArrays expanding result coords beyond the variable's coordinate space
7
13
* Add ``add_piecewise_constraints()`` with SOS2, incremental, LP, and disjunctive formulations (``linopy.piecewise(x, x_pts, y_pts) == y``).
8
14
* Add ``linopy.piecewise()`` to create piecewise linear function descriptors (`PiecewiseExpression`) from separate x/y breakpoint arrays.
9
15
* Add ``linopy.breakpoints()`` factory for convenient breakpoint construction from lists, Series, DataFrames, DataArrays, or dicts. Supports slopes mode.
0 commit comments