linopy.variables.Variable.update

linopy.variables.Variable.update#

Variable.update(*, lower=None, upper=None)#

Update variable bounds in place.

Canonical mutation API. Validation and coord alignment live here. Single-attribute setters (var.lower = …) forward to this method.

Parameters:
  • lower (ConstantLike, optional) – New lower bound. Accepts any constant — scalars, numpy arrays, pandas Series / DataFrame, xarray DataArray (e.g. time-varying bounds). Aligned via xarray broadcast against the variable’s existing shape; new dims are rejected. Decision variables / linear expressions are not accepted.

  • upper (ConstantLike, optional) – New upper bound. Same.

Returns:

Variableself for chaining.

Raises:
  • TypeError – If either bound is a Variable / Expression (bounds must be numeric, not symbolic).

  • ValueError – If the new bound introduces dimensions not in the variable’s coords, or if the resulting lower > upper anywhere.