Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

refactor(csr): use pandas/xarray-style verbs for CSRLinearExpression and Grid methods

Aperta
#1,018 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
pandas, python
Ambito
backend

Direzione di ricerca

Start with linopy/csr.py and inspect the methods on CSRLinearExpression and Grid, then trace their callers and existing tests. The issue leaves naming choices open, especially for with_const and the boundary with the public LinearExpression API. Done means an agreed naming scheme is applied consistently, with behavior unchanged and relevant tests passing.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

refactor sparse

[!NOTE]
The following content was generated by AI.

Describe the feature you'd like to see

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.

current proposed
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 / combined rename / transpose / conform / combine
# today
expr._csr.aggregated(grid, rows).filled(0.0)
expr._csr.scaled(-1.0)
# proposed
expr._csr.aggregate(grid, rows).fillna(0.0)
expr._csr.mul(-1.0)

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.

Lingua principale
Python
Stelle
260
Fork
89
Merge medio
1g 7h
PR unite (30g)
25

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PyPSA/linopy

Tutte le issue di PyPSA/linopy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.