-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Issue Description
Multiplying with a constant that has a subset of coordinates on a shared dimension behaves differently for Variable vs LinearExpression:
x * subset_daworks (produces NaN coefficients)(1 * x) * subset_dafails withAssertionError
Mathematically these should be equivalent.
Reproducible Example
import pandas as pd
import xarray as xr
import linopy
m = linopy.Model()
x = m.add_variables(coords=[pd.Index(range(5), name="i")])
subset_da = xr.DataArray([10.0, 30.0], dims=["i"], coords={"i": [1, 3]})
# This works
result1 = x * subset_da
print(result1.coeffs.values) # [nan, 10., nan, 30., nan]
# This fails with AssertionError
expr = 1 * x
result2 = expr * subset_da # AssertionError in _multiply_by_constantExpected Behavior
Both operations should behave consistently. Either:
- Both succeed with same result, or
- Both raise an error indicating misaligned coordinates
Installed Versions
Details
master branch (commit 59f92ae)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working