Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 10, 2024
1 parent 381f163 commit 71c0a32
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/pyoperators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- operators_pywt : (optional) loaded if PyWavelets is present.
"""

from importlib.metadata import version as _version

from .core import (
Expand Down
39 changes: 24 additions & 15 deletions src/pyoperators/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
which can be added, composed or multiplied by a scalar. See the
Operator docstring for more information.
"""

from __future__ import annotations

import inspect
Expand Down Expand Up @@ -1233,16 +1234,20 @@ def _init_inout(
flag_is = (
'explicit'
if self.shapein is not None
else 'implicit'
if self.reshapeout != Operator.reshapeout.__get__(self, type(self))
else 'unconstrained'
else (
'implicit'
if self.reshapeout != Operator.reshapeout.__get__(self, type(self))
else 'unconstrained'
)
)
flag_os = (
'explicit'
if self.shapeout is not None
else 'implicit'
if self.reshapein != Operator.reshapein.__get__(self, type(self))
else 'unconstrained'
else (
'implicit'
if self.reshapein != Operator.reshapein.__get__(self, type(self))
else 'unconstrained'
)
)
self._set_flags(shape_input=flag_is, shape_output=flag_os)

Expand Down Expand Up @@ -1779,9 +1784,11 @@ def __str__(self):

# parentheses for AdditionOperator and BlockDiagonalOperator
operands = [
f'({o})'
if isinstance(o, (AdditionOperator, BlockDiagonalOperator))
else str(o)
(
f'({o})'
if isinstance(o, (AdditionOperator, BlockDiagonalOperator))
else str(o)
)
for o in self.operands
]

Expand Down Expand Up @@ -2440,9 +2447,11 @@ def _apply_rule_homothety(self, operands):
"""
return sum(
(
self._apply_rule_homothety_linear(list(group))
if islinear
else list(group)
(
self._apply_rule_homothety_linear(list(group))
if islinear
else list(group)
)
for islinear, group in groupby(operands, lambda o: o.flags.linear)
),
[],
Expand Down Expand Up @@ -3470,9 +3479,9 @@ def _validate_partition_composition(op1, op2):
)
)

return None if pout is None else merge_none(
op1.partitionout, pout
), None if pin is None else merge_none(op2.partitionin, pin)
return None if pout is None else merge_none(op1.partitionout, pout), (
None if pin is None else merge_none(op2.partitionin, pin)
)

@staticmethod
def _rule_operator_commutative(self, op, cls):
Expand Down
1 change: 1 addition & 0 deletions src/pyoperators/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
linear, square etc.
"""

from collections import namedtuple


Expand Down
1 change: 1 addition & 0 deletions src/pyoperators/iterative/algorithms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Implements iterative algorithm class.
"""

from copy import copy

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/pyoperators/iterative/dli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.165.8284&rep=rep1&type=pdf
"""

from copy import copy

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/pyoperators/iterative/linesearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- LineSearch, LineSearchArmijo, LineSearchWolfe1; LineSearchWolfe2
"""

import numpy as np

from .criterions import Norm2
Expand Down
1 change: 1 addition & 0 deletions src/pyoperators/iterative/optimize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Wraps scipy.optimize.fmin_* algorithms using Criterion instances.
"""

import numpy as np
import scipy.optimize as opt

Expand Down
1 change: 0 additions & 1 deletion src/pyoperators/iterative/stopconditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""


__all__ = ['StopCondition', 'MaxErrorStopCondition', 'MaxIterationStopCondition']


Expand Down
1 change: 1 addition & 0 deletions src/pyoperators/utils/fake_MPI.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
MPI-wrapper module for non-MPI enabled platforms.
"""

import builtins as _builtins
from itertools import count as _count

Expand Down
10 changes: 5 additions & 5 deletions src/pyoperators/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,11 +1208,11 @@ def zip_broadcast(*args, **keywords):
raise TypeError('Invalid keyword(s).')
iter_str = keywords.get('iter_str', True)
n = max(
1
if not isinstance(_, Iterable) or isinstance(_, str) and not iter_str
else len(_)
if hasattr(_, '__len__')
else sys.maxsize
(
1
if not isinstance(_, Iterable) or isinstance(_, str) and not iter_str
else len(_) if hasattr(_, '__len__') else sys.maxsize
)
for _ in args
)

Expand Down

0 comments on commit 71c0a32

Please sign in to comment.