Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#1,018 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
38/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
pandas, python
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
260
Forks
89
Merge medio
1 d 1 h
PR fusionados (30 d)
24

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PyPSA/linopy

Todos los issues de PyPSA/linopy

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.