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
{{ message }}
Repository navigation
Keep the CSR backing through shift, roll, diff and merge(dim=...) #1011
Child of #972 (phase 2, PR 8). Follows up on the SnapshotWindow.merge fallback reported in a comment on #972.
These operations convert a CSR-backed expression to dense:
shift, roll and diff;
linopy.merge([...], dim=...) along an existing dimension.
The conversion is silent unless options["warn_on_densify"] is set. For a groupby result with uneven group sizes, the conversion costs about 250 ms and 1.4 GB in the #972 benchmark. These operations are common in energy models, for example in storage balances and in snapshot windows.
shift and roll: a row map on the grid through CSRLinearExpression.taken, with -1 for cells that are shifted out. The fill must match the dense v1 result (absent, not zero). roll wraps around.
diff: self - self.shift(...), using the sparse merge.
merge(dim=...): stack the rows and extend the grid, keeping the input order. Cover overlapping labels, absent cells, constants and auxiliary coordinates. Use the reproduction in the Tracking: sparse/CSR path follow-ups after #961 #972 comment as the first test.
Note
The following content was generated by AI.
Describe the feature you'd like to see
Child of #972 (phase 2, PR 8). Follows up on the
SnapshotWindow.mergefallback reported in a comment on #972.These operations convert a CSR-backed expression to dense:
shift,rollanddiff;linopy.merge([...], dim=...)along an existing dimension.The conversion is silent unless
options["warn_on_densify"]is set. For agroupbyresult with uneven group sizes, the conversion costs about 250 ms and 1.4 GB in the #972 benchmark. These operations are common in energy models, for example in storage balances and in snapshot windows.Proposed direction
shiftandroll: a row map on the grid throughCSRLinearExpression.taken, with-1for cells that are shifted out. The fill must match the dense v1 result (absent, not zero).rollwraps around.diff:self - self.shift(...), using the sparse merge.merge(dim=...): stack the rows and extend the grid, keeping the input order. Cover overlapping labels, absent cells, constants and auxiliary coordinates. Use the reproduction in the Tracking: sparse/CSR path follow-ups after #961 #972 comment as the first test.warn_on_densifyby default in a sparse model (tracked in Make the sparse path observable and controllable (.is_sparse, densify warning, per-call sparse=) #969), so the remaining conversions are visible.Still out of scope: multiplication by a DataArray with a new dimension,
rolling,cumsumand quadratic products.