spec: a row emptied by the data is refused even when it holds
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #1164 của @FabianHofmann — đã đóng, không merge
Đá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
- 48/100
Hướng nghiên cứu
Start by reading _check_live in linopy/spec/builder.py and the test test_a_dimension_with_no_members_empties_a_summed_row, which the issue says may need to change. Reproduce with the provided Model.from_spec example, checking both load[0] = 0 and load[0] = 5. Done when the first case drops the holding row with the existing warning and the second reports that the row cannot hold.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[!NOTE]
The following content was generated by AI.
Version Checks
- exists on
master(127a61c)
Issue Description
Model.from_spec refuses a row that the data empties of every variable term, even when the row holds (0 == 0). This happens even when the spec states the value at the edge (shift(..., edge=0)).
- found while building PyPSA from a spec: a link with
delay=1delivers nothing to its bus in the first snapshot, so that bus's balance row is0 == load. Withload = 0it holds; PyPSA solves it today. _check_live(linopy/spec/builder.py) warns and drops a trivially true row only if every variable declares amissing:number. A plain variable can't declare one (missing: 0 needs a where:), andedge=0doesn't count.
Reproducible Example
import pandas as pd
import xarray as xr
from linopy import Model
spec = {
"dimensions": {"t": {"dtype": "int", "ordered": True}, "k": {"dtype": "str"}},
"parameters": {"load": {"dims": ["t"]}},
"variables": {"x": {"dims": ["t", "k"], "bounds": {"lower": 0}}},
"constraints": {
"balance": {
"dims": ["t"],
"expression": "sum(shift(x, along=t, offset=1, edge=0), over=k) == load",
}
},
"objective": {"sense": "minimize", "expression": "sum(x, over=[t, k])"},
}
t = pd.Index([0, 1, 2], name="t")
load = xr.DataArray([0.0, 10.0, 10.0], coords=[t])
Model.from_spec(spec, {"t": t, "k": ["a"], "load": load})
# SpecDataError: constraint 'balance': 1 row(s) hold no variable term once the data
# is attached, the first at t=0. ...
Same error without edge=0, and with load[0] = 5.
Expected Behavior
load[0] = 0: builds; the emptied row holds, so it is dropped with the existing "trivially true" warning.load[0] = 5: refused, but saying the row can't hold (0 == 5), not that it leaves the problem silently.
Open question
- without
edge=, the shifted term is absent, not zero. Should a sum of absent terms count as0for this check, or must the spec say so (edge=0, awhere:)? test_a_dimension_with_no_members_empties_a_summed_rowrefusessum(x, over=t) <= 0over an emptyton purpose, so a change here moves that test too.
Installed Versions
linopy master 127a61c, mathspec 0.0.1.dev1+gf0aaaf4, xarray 2026.9.0, pandas 3.1.1, numpy 2.5.4
Generated by Claude Code
- Ngôn ngữ chính
- Python
- Star
- 264
- Fork
- 95
- Merge trung bình
- 11 giờ 33 phút
- Pull request đã merge (30 ngày)
- 86
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của PyPSA/linopy
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
Maintainer thường phản hồi trong vòng 1 ngày
-
feature needs triage
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
PyPSA/linopy#1180 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 18/100
PyPSA/linopy#1159 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Gurobi raises GurobiError when a MIP stops at a limit without an incumbentCó thể đã có người làm @Blizzeq đã nhận 15 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Rose22/openlumara#166 ·
-
documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement feature/signals self-driving team/self-driving
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
PostHog/posthog#144208 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue help wanted tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
LMPrado-DZ23/open_notas_br#14 ·
Maintainer thường phản hồi trong vòng 1 ngày