linopy.constraints.Constraint#
- class linopy.constraints.Constraint(data, model, name='', skip_broadcast=False)#
Projection to a single constraint in a model.
The Constraint class is a subclass of xr.DataArray hence most xarray functions can be applied to it.
- __init__(data, model, name='', skip_broadcast=False)#
Initialize the Constraint.
- Parameters:
labels (
xarray.DataArray) – labels of the constraint.model (
linopy.Model) – Underlying model.name (
str) – Name of the constraint.
Methods
__init__(data, model[, name, skip_broadcast])Initialize the Constraint.
assign([variables])Wrapper for the xarray Dataset.assign function for linopy.Constraint
assign_attrs(*args, **kwargs)Wrapper for the xarray DataWithCoords.assign_attrs function for linopy.Constraint
assign_coords([coords])Wrapper for the xarray DataWithCoords.assign_coords function for linopy.Constraint
assign_multiindex_safe(**fields)Wrapper for the xarray assign_multiindex_safe function for linopy.Constraint
broadcast_like(other[, exclude])Wrapper for the xarray Dataset.broadcast_like function for linopy.Constraint
chunk([chunks, name_prefix, token, lock, ...])Wrapper for the xarray Dataset.chunk function for linopy.Constraint
drop_isel([indexers])Wrapper for the xarray Dataset.drop_isel function for linopy.Constraint
drop_sel([labels, errors])Wrapper for the xarray Dataset.drop_sel function for linopy.Constraint
expand_dims([dim, axis, ...])Wrapper for the xarray Dataset.expand_dims function for linopy.Constraint
from_rule(model, rule, coords)Create a constraint from a rule and a set of coordinates.
isel([indexers, drop, missing_dims])Wrapper for the xarray Dataset.isel function for linopy.Constraint
iterate_slices([slice_size, slice_dims])Generate slices of an xarray Dataset or DataArray with a specified soft maximum size.
print([display_max_rows, display_max_terms])Print the linear expression.
reindex([indexers, method, tolerance, copy, ...])Wrapper for the xarray Dataset.reindex function for linopy.Constraint with default arguments: {'fill_value': {'labels': -1, 'rhs': nan, 'coeffs': 0, 'vars': -1, 'sign': '='}}
reindex_like(other[, method, tolerance, ...])Wrapper for the xarray Dataset.reindex_like function for linopy.Constraint with default arguments: {'fill_value': {'labels': -1, 'rhs': nan, 'coeffs': 0, 'vars': -1, 'sign': '='}}
rename([name_dict])Wrapper for the xarray Dataset.rename function for linopy.Constraint
rename_dims([dims_dict])Wrapper for the xarray Dataset.rename_dims function for linopy.Constraint
roll([shifts, roll_coords])Wrapper for the xarray Dataset.roll function for linopy.Constraint
sel([indexers, method, tolerance, drop])Wrapper for the xarray Dataset.sel function for linopy.Constraint
set_index([indexes, append])Wrapper for the xarray Dataset.set_index function for linopy.Constraint
shift([shifts, fill_value])Wrapper for the xarray Dataset.shift function for linopy.Constraint
stack([dim, create_index, index_cls])Wrapper for the xarray Dataset.stack function for linopy.Constraint
swap_dims([dims_dict])Wrapper for the xarray Dataset.swap_dims function for linopy.Constraint
to_polars()Convert the constraint to a polars DataFrame.
unstack([dim, fill_value, sparse])Wrapper for the xarray Dataset.unstack function for linopy.Constraint
Attributes
attrsGet the attributes of the constraint.
Get the left-hand-side coefficients of the constraint.
coord_dimscoord_namesGet the names of the coordinates.
coord_sizescoordsGet the coordinates of the constraint.
dataGet the underlying DataArray.
dimsGet the dimensions of the constraint.
dualGet the dual values of the constraint.
Convert the constraint to a pandas DataFrame.
indexesGet the indexes of the constraint.
is_assignedlabelsGet the labels of the constraint.
Get the left-hand-side linear expression of the constraint.
locmaskGet the mask of the constraint.
modelGet the model of the constraint.
nameReturn the name of the constraint.
ndimGet the number of dimensions of the constraint.
ntermGet the number of terms in the constraint.
rangeReturn the range of the constraint.
Get the right hand side constants of the constraint.
shapeGet the shape of the constraint.
Get the signs of the constraint.
sizeGet the size of the constraint.
sizesGet the sizes of the constraint.
term_dimReturn the term dimension of the constraint.
typeGet the type of the constraint.
Get the left-hand-side variables of the constraint.