You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LinearExpression has a .reindex method, but Variable does not — so a Variable cannot be aligned to a new coordinate set directly. To reindex a variable today you have to round-trip through .to_linexpr() (or reindex a derived DataArray such as .isnull() separately), which is awkward when you just want to align the variable itself.
A Variable.reindex(...) mirroring LinearExpression.reindex (and the underlying xarray semantics) would let callers align a variable to a target index in a single expression, without converting to a LinearExpression first.
Masking behavior
A masked entry already carries variable label -1, the same sentinel reindex uses for a freshly-introduced coordinate — so masking falls out with a single notion of "absent":
New coordinates fill as masked/null, not with a value (fill_value doesn't apply to variable labels — there's no variable to fill).
Existing masks are preserved; subsetting just drops entries.
isnull() stays mask-aware: it reports True for both pre-existing masks and newly-missing coords, with no special-casing.
The value is a correct, mask-aware null array at the Variable level — before to_linexpr(), which is exactly where one wants to branch on availability. Constant fills (e.g. 1 for "always on") remain a LinearExpression concern (to_linexpr().reindex(...).where(...)); Variable.reindex stays pure: variables or masked, nothing else.
Note
This issue was drafted by AI (Claude).
Describe the feature you'd like to see
LinearExpressionhas a.reindexmethod, butVariabledoes not — so aVariablecannot be aligned to a new coordinate set directly. To reindex a variable today you have to round-trip through.to_linexpr()(or reindex a derivedDataArraysuch as.isnull()separately), which is awkward when you just want to align the variable itself.A
Variable.reindex(...)mirroringLinearExpression.reindex(and the underlying xarray semantics) would let callers align a variable to a target index in a single expression, without converting to aLinearExpressionfirst.Masking behavior
A masked entry already carries variable label
-1, the same sentinel reindex uses for a freshly-introduced coordinate — so masking falls out with a single notion of "absent":fill_valuedoesn't apply to variable labels — there's no variable to fill).isnull()stays mask-aware: it reportsTruefor both pre-existing masks and newly-missing coords, with no special-casing.The value is a correct, mask-aware null array at the
Variablelevel — beforeto_linexpr(), which is exactly where one wants to branch on availability. Constant fills (e.g.1for "always on") remain aLinearExpressionconcern (to_linexpr().reindex(...).where(...));Variable.reindexstays pure: variables or masked, nothing else.