spec: rows emptied by absence are dropped silently; revisit strict refusal
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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
Hướng nghiên cứu
Start with linopy/spec/builder.py::_check_live and run the minimal example from the issue. Read test/test_spec_builder.py::test_absence_takes_the_row_with_it and ::test_a_row_the_data_emptied_of_variables_is_refused to understand the current behavior. Done requires resolving the strictness and warning or edge-policy questions and adding tests for the chosen behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
In the long term I would like to have things strict, but for now this is fine. Tracking this so we can readdress it later.
[!NOTE]
The following content was generated by AI.
Describe the feature you'd like to see
With the move to mathspec 0.2.0 in #958, linopy/spec/builder.py::_check_live no longer refuses a constraint row that absence empties. It drops the row silently. This follows mathspec's documented semantics: absence spread through arithmetic "takes the row with it", and the first row of a bare shift "is not built".
Before (0a725f43), such a row raised SpecDataError ("N row(s) hold no variable term"), because a row that silently disappears no longer binds.
The current state after #958:
| row | behaviour |
|---|---|
absent (null) row, e.g. x - shift(x) at the first snapshot |
dropped silently |
bare masked Variable as a term |
not checked |
present row with no variable, e.g. absence: zero against a binding side |
refused |
Strict is the long-term goal. Open questions:
- Opt-in strictness, e.g.
add_spec(..., strict=True), or strict by default with an explicit edge policy in the spec (shift(..., edge=...))? - Warn at least with the count of rows dropped per constraint?
- Does mathspec need a language-level way to state "this row may be dropped", so strict engines can tell intended from accidental absence?
Reasons it is relaxed for now: pypsa.yaml, its netcdf round trip and the spec_pypsa benchmark rely on a bare shift dropping the first snapshot.
Minimal example
import pandas as pd
import xarray as xr
import linopy
linopy.options["semantics"] = "v1"
spec = """
dimensions:
snapshot: { dtype: int }
variables:
p:
dims: [snapshot]
bounds: { lower: 0 }
constraints:
no_faster_than_before:
dims: [snapshot]
expression: p <= shift(p, along=snapshot, offset=1)
objective: { sense: minimize, expression: sum(p) }
"""
sources = xr.Dataset(coords={"snapshot": pd.Index([0, 1, 2], name="snapshot")})
m = linopy.Model.from_spec(spec, sources)
print(m.constraints["no_faster_than_before"].labels.values)
# [-1 1 2] -> row at snapshot 0 is dropped without error or warning
Tests pinning the current behaviour: test/test_spec_builder.py::test_absence_takes_the_row_with_it and ::test_a_row_the_data_emptied_of_variables_is_refused.
- Ngôn ngữ chính
- Python
- Star
- 259
- Fork
- 89
- Merge trung bình
- 1 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 26
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 solver interface
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
refactor sparse
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Meta: separate dense and sparse stores from the expression and constraint frontendCó thể đã có người làm @Rishabhkanhaiya đã nhận 5 ngày trước. Đang mởdiscussion refactor sparse
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
PyPSA/linopy#1019 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
refactor sparse
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Xpress missing _license_probe: licensed_solvers includes xpress with an out-of-date licence, breaking local testsCó thể đã có người làm @FabianHofmann đã nhận 15 ngày trước. Đang mởbug solver interface
Độ 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
Issue tương tự
-
bug difficulty:2 good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
MakazhanAlpamys/Soup#1865 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: agents area: docs good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
openapi/gknowledge#23 ·
-
useless-suppression reported for deprecated-* messages that should be exemptCó thể đã có người làm @adityasinha-ghub đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
pylint-dev/pylint#11656 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:provisioning effort:S priority:P2 provider:local-libvirt risk:daytime-only status:in-progress type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
randomparity/kdive#3203 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
get() for StrEnumCó thể đã có người làm @FeJo5952 đã nhận hôm nay. Đang mởgood first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
collective/icalendar#1921 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày