linopy.constraints.Constraint

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

attrs

Get the attributes of the constraint.

coeffs

Get the left-hand-side coefficients of the constraint.

coord_dims

coord_names

Get the names of the coordinates.

coord_sizes

coords

Get the coordinates of the constraint.

data

Get the underlying DataArray.

dims

Get the dimensions of the constraint.

dual

Get the dual values of the constraint.

flat

Convert the constraint to a pandas DataFrame.

indexes

Get the indexes of the constraint.

is_assigned

labels

Get the labels of the constraint.

lhs

Get the left-hand-side linear expression of the constraint.

loc

mask

Get the mask of the constraint.

model

Get the model of the constraint.

name

Return the name of the constraint.

ndim

Get the number of dimensions of the constraint.

nterm

Get the number of terms in the constraint.

range

Return the range of the constraint.

rhs

Get the right hand side constants of the constraint.

shape

Get the shape of the constraint.

sign

Get the signs of the constraint.

size

Get the size of the constraint.

sizes

Get the sizes of the constraint.

term_dim

Return the term dimension of the constraint.

type

Get the type of the constraint.

vars

Get the left-hand-side variables of the constraint.