Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#1,018 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
38/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
pandas, python
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
260
Fork
89
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
30

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PyPSA/linopy

Tất cả issue của PyPSA/linopy

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.