Tracking issue for the known problems with linopy's arithmetic — coordinate alignment and NaN handling — and the v1 convention that fixes them.
linopy aligns coordinates with size-based heuristics. When operands don't line up it guesses, and the guesses are sometimes silently wrong — no exception, the solver returns Optimal, the objective looks plausible. PyPSA/PyPSA#1677 shipped a workaround for one such case (a capacity-expansion result 47% too cheap).
Bugs — silent wrong answers
Opinionated behaviour — silent, debatable choices
Already fixed in v0.7.0
Out of scope
Predictability issues, but not arithmetic-alignment bugs:
#703 (xarray method coverage) consumes the convention rather than constraining it.
The fix
A strict v1 arithmetic convention behind linopy.options["arithmetic_convention"] — align by label, raise on a mismatch, NaN means "absent term". It ships opt-in, becomes the default, and legacy is removed at linopy 1.0. One PR carries the design goals, the spec, tests and code; docs follow. Implementation: #591. Milestone: Predictable Arithmetics.
Tracking issue for the known problems with linopy's arithmetic — coordinate alignment and NaN handling — and the v1 convention that fixes them.
linopy aligns coordinates with size-based heuristics. When operands don't line up it guesses, and the guesses are sometimes silently wrong — no exception, the solver returns
Optimal, the objective looks plausible. PyPSA/PyPSA#1677 shipped a workaround for one such case (a capacity-expansion result 47% too cheap).Bugs — silent wrong answers
*by label,+-/by position) #708 (root cause),x - a <= 0andx <= abuild different constraints #707, bug when adding two linopy expressions/variables that share dimension names but have disjoint label coordinates of same size #670Opinionated behaviour — silent, debatable choices
Already fixed in v0.7.0
Out of scope
Predictability issues, but not arithmetic-alignment bugs:
add_variablesmishandles bounds with missing dimensions — add_variables: DataArray bounds with missing dimensions yield wrong dimension order #706 (DataArraybounds → wrong dimension order), add_variables: pandas Series/DataFrame bounds with missing dimensions silently drop the dimension #709 (Series/DataFramebounds → dimension dropped). Inconsistent creation of dimensions in add_variables #450 is the original report, only partially fixed by fix: add_variables ignoring coords for DataArray bounds #614.groupbyby aDataArray; Slicing selection not aligned on "Python standards" #308 —.locendpoint inclusivity.#703 (xarray method coverage) consumes the convention rather than constraining it.
The fix
A strict v1 arithmetic convention behind
linopy.options["arithmetic_convention"]— align by label, raise on a mismatch, NaN means "absent term". It ships opt-in, becomes the default, and legacy is removed at linopy 1.0. One PR carries the design goals, the spec, tests and code; docs follow. Implementation: #591. Milestone: Predictable Arithmetics.