Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #94

Merged
merged 3 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ repos:
rev: 22.12.0
hooks:
- id: black
- repo: https://github.com/PyCQA/docformatter
rev: v1.5.1
hooks:
- id: docformatter
args: [--in-place, --make-summary-multi-line, --pre-summary-newline]
# Current docformatter version has a problem with urls (it's annoying)
# - repo: https://github.com/PyCQA/docformatter
# rev: v1.6.0.rc1
# hooks:
# - id: docformatter
# args: [--in-place, --make-summary-multi-line, --pre-summary-newline]
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
hooks:
Expand All @@ -23,7 +24,7 @@ repos:
hooks:
- id: absolufy-imports
- repo: https://github.com/PyCQA/isort
rev: 5.11.4
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
Expand Down
2 changes: 2 additions & 0 deletions linopy/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def wrapper(self, *args, **kwargs):
def is_constant(func):
from linopy import expressions, variables

#
@wraps(func)
def wrapper(self, arg):
if isinstance(arg, (variables.Variable, expressions.LinearExpression)):
Expand All @@ -176,6 +177,7 @@ def wrapper(self, arg):


def forward_as_properties(**routes):
#
def add_accessor(cls, item, attr):
@property
def get(self):
Expand Down
18 changes: 12 additions & 6 deletions linopy/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,14 +635,20 @@ def to_matrix(self, filter_missings=False):
"""
Construct a constraint matrix in sparse format.

Missing values, i.e. -1 in labels and vars, are ignored filtered out.
Missing values, i.e. -1 in labels and vars, are ignored filtered
out.

If filter_missings is set to True, the index of the rows and columns
correspond to the constraint and variable labels stored in the model.
If filter_missings is set to True, the index of the rows and
columns
correspond to the constraint and variable labels stored in the
model.
If set to False, the rows correspond to the constraints given by
`m.constraints.ravel('labels', filter_missings=True)` and columns to
`m.variables.ravel('labels', filter_missings=True)` where `m` is the
underlying model. The matrix has then a shape of (`m.ncons`, `m.nvars`).
`m.constraints.ravel('labels', filter_missings=True)` and
columns to
`m.variables.ravel('labels', filter_missings=True)` where `m` is
the
underlying model. The matrix has then a shape of (`m.ncons`,
`m.nvars`).
"""
self.sanitize_missings()

Expand Down
3 changes: 0 additions & 3 deletions linopy/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ def sum(self, dims=None, drop_zeros=False) -> "LinearExpression":
linopy.LinearExpression
Summed expression.
"""

res = self.__class__(self._sum(self, dims=dims), self.model)

if drop_zeros:
Expand Down Expand Up @@ -745,7 +744,6 @@ def rolling_sum(self, **kwargs):
-------
linopy.LinearExpression
"""

coeffs = xr.DataArray.rolling(self.coeffs, **kwargs).construct(
"_rolling_term", keep_attrs=True
)
Expand Down Expand Up @@ -832,7 +830,6 @@ def sanitize(self):
-------
linopy.LinearExpression
"""

if not np.issubdtype(self.vars.dtype, np.integer):
return self.assign(vars=self.vars.fillna(-1).astype(int))

Expand Down
11 changes: 7 additions & 4 deletions linopy/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,14 @@ def run_glpk(
"""
Solve a linear problem using the glpk solver.

This function reads the linear problem file and passes it to the glpk
solver. If the solution is successful it returns variable solutions and
This function reads the linear problem file and passes it to the
glpk
solver. If the solution is successful it returns variable solutions
and
constraint dual values.

For more information on the glpk solver options:
For more information on the glpk solver options, see

https://kam.mff.cuni.cz/~elias/glpk.pdf
"""
CONDITION_MAP = {
Expand Down Expand Up @@ -603,7 +606,7 @@ def run_xpress(
variable solutions and constraint dual values. The xpress module
must be installed for using this function.

For more information on solver options:
For more information on solver options, see
https://www.fico.com/fico-xpress-optimization/docs/latest/solver/GUID-ACD7E60C-7852-36B7-A78A-CED0EA291CDD.html
"""
CONDITION_MAP = {
Expand Down