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
refactor(csr): use pandas/xarray-style verbs for CSRLinearExpression and Grid methods #1018
linopy/csr.py names the methods of CSRLinearExpression and Grid as past participles (summed, renamed, reindexed, ...). They return a new frozen object, never mutate. pandas and xarray use plain verbs for the same copy-returning operations (df.rename, da.reindex, fillna, ...), so the CSR layer diverges from the convention of the ecosystem linopy builds on.
Proposal: rename them to pandas/xarray-style verbs. Pure refactor, no behavior change.
Trade-off to decide:LinearExpression already exposes the xarray verbs publicly. After the rename, expr.sum() and expr._csr.sum() share a name but differ in signature and semantics (e.g. the CSR sum takes a grid-level dim list and keeps explicit zero coefficients). The current participles keep the internal sparse layer visibly separate from the public dense API. The _csr attribute and the CSRLinearExpression type arguably mark that boundary well enough on their own.
Note
The following content was generated by AI.
Describe the feature you'd like to see
linopy/csr.pynames the methods ofCSRLinearExpressionandGridas past participles (summed,renamed,reindexed, ...). They return a new frozen object, never mutate. pandas and xarray use plain verbs for the same copy-returning operations (df.rename,da.reindex,fillna, ...), so the CSR layer diverges from the convention of the ecosystem linopy builds on.Proposal: rename them to pandas/xarray-style verbs. Pure refactor, no behavior change.
CSRLinearExpression.summed(dims)sum(dims)aggregated(grid, rows)aggregate(grid, rows)renamed(names)rename(names)reindexed(grid, fill)reindex(grid, fill)filled(value)fillna(value)taken(rows, grid)take(rows, grid)added(other)add(other)scaled(factor)mul(factor)contracted(...)dot(...)pruned()prune()with_const(const)assign_const(const)(or keep)Grid.renamed/reordered/conformed/combinedrename/transpose/conform/combineTrade-off to decide:
LinearExpressionalready exposes the xarray verbs publicly. After the rename,expr.sum()andexpr._csr.sum()share a name but differ in signature and semantics (e.g. the CSRsumtakes a grid-level dim list and keeps explicit zero coefficients). The current participles keep the internal sparse layer visibly separate from the public dense API. The_csrattribute and theCSRLinearExpressiontype arguably mark that boundary well enough on their own.