spec: rows emptied by absence are dropped silently; revisit strict refusal
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 30/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 259
- Forks
- 89
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 26
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de PyPSA/linopy
-
bug solver interface
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
refactor sparse
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
Meta: separate dense and sparse stores from the expression and constraint frontendPosiblemente ocupada @Rishabhkanhaiya la tomó hace 3 días. Abiertodiscussion refactor sparse
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
PyPSA/linopy#1019 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
refactor sparse
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
Los mantenedores suelen responder en 1 día
-
Xpress missing _license_probe: licensed_solvers includes xpress with an out-of-date licence, breaking local testsPosiblemente ocupada @FabianHofmann la tomó hace 12 días. Abiertobug solver interface
Dificultad 4/5 3-5 días Aptitud para principiantes 58/100
Los mantenedores suelen responder en 1 día
Todos los issues de PyPSA/linopy
Issues similares
-
area: desktop area: website priority: P2 type: feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
appandflow/stim#3411 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 Menos de una hora Aptitud para principiantes 88/100
baptistehamon/lsapy#185 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
PolicyEngine/policyengine-us#10073 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
syedhamidali/radarx#277 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Arekkazu/sgpmp-backend#549 ·
Los mantenedores suelen responder en 1 día