Skip to content

Commit

Permalink
run ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Jan 4, 2024
1 parent c6aef10 commit 1a74d68
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion python/sdist/amici/__init__.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
)

from .TPL_MODELNAME import * # noqa: F403, F401
from .TPL_MODELNAME import getModel as get_model # noqa: F401
from .TPL_MODELNAME import getModel as get_model # noqa: F401

__version__ = "TPL_PACKAGE_VERSION"
2 changes: 1 addition & 1 deletion python/sdist/amici/de_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def smart_multiply(


def smart_is_zero_matrix(
x: Union[sp.MutableDenseMatrix, sp.MutableSparseMatrix]
x: Union[sp.MutableDenseMatrix, sp.MutableSparseMatrix],
) -> bool:
"""A faster implementation of sympy's is_zero_matrix
Expand Down
2 changes: 1 addition & 1 deletion python/sdist/amici/gradient_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

import copy
from typing import Callable, List, Optional, Sequence
from typing import List, Optional, Sequence

import numpy as np

Expand Down
6 changes: 3 additions & 3 deletions python/sdist/amici/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ObservableTransformation(str, enum.Enum):


def noise_distribution_to_observable_transformation(
noise_distribution: Union[str, Callable]
noise_distribution: Union[str, Callable],
) -> ObservableTransformation:
"""
Parse noise distribution string and extract observable transformation
Expand All @@ -93,7 +93,7 @@ def noise_distribution_to_observable_transformation(


def noise_distribution_to_cost_function(
noise_distribution: Union[str, Callable]
noise_distribution: Union[str, Callable],
) -> Callable[[str], str]:
"""
Parse noise distribution string to a cost function definition amici can
Expand Down Expand Up @@ -423,7 +423,7 @@ def _parse_special_functions(sym: sp.Expr, toplevel: bool = True) -> sp.Expr:


def _denest_piecewise(
args: Sequence[Union[sp.Expr, sp.logic.boolalg.Boolean, bool]]
args: Sequence[Union[sp.Expr, sp.logic.boolalg.Boolean, bool]],
) -> Tuple[Union[sp.Expr, sp.logic.boolalg.Boolean, bool]]:
"""
Denest piecewise functions that contain piecewise as condition
Expand Down
2 changes: 1 addition & 1 deletion python/sdist/amici/petab/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_states_in_condition_table(
spm = pysb.pattern.SpeciesPatternMatcher(
model=petab_problem.model.model
)
except NotImplementedError as e:
except NotImplementedError:
raise NotImplementedError(
"Requires https://github.com/pysb/pysb/pull/570. "
"To use this functionality, update pysb via "
Expand Down
3 changes: 1 addition & 2 deletions python/sdist/amici/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def plot_state_trajectories(
elif model is not None and prefer_names:
labels = np.asarray(model.getStateNames())[list(state_indices)]
labels = [
l if l else model.getStateIds()[ix]
for ix, l in enumerate(labels)
l if l else model.getStateIds()[ix] for ix, l in enumerate(labels)
]
elif model is not None:
labels = np.asarray(model.getStateIds())[list(state_indices)]
Expand Down
4 changes: 2 additions & 2 deletions python/sdist/amici/pysb_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def _process_pysb_species(pysb_model: pysb.Model, ode_model: DEModel) -> None:
sp.Symbol(f"__s{ix}"), f"{specie}", init, xdot[ix]
)
)
logger.debug(f"Finished Processing PySB species ")
logger.debug("Finished Processing PySB species ")


@log_execution_time("processing PySB parameters", logger)
Expand Down Expand Up @@ -1353,7 +1353,7 @@ def has_fixed_parameter_ic(


def extract_monomers(
complex_patterns: Union[pysb.ComplexPattern, List[pysb.ComplexPattern]]
complex_patterns: Union[pysb.ComplexPattern, List[pysb.ComplexPattern]],
) -> List[str]:
"""
Constructs a list of monomer names contained in complex patterns.
Expand Down
9 changes: 4 additions & 5 deletions python/sdist/amici/sbml_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
List,
Optional,
Sequence,
Set,
Tuple,
Union,
)
Expand Down Expand Up @@ -1165,7 +1164,7 @@ def _process_reactions(self):
# accounts for possibly variable compartments.
self.stoichiometric_matrix[
species["index"], reaction_index
] += (sign * stoichiometry * species["conversion_factor"])
] += sign * stoichiometry * species["conversion_factor"]
if reaction.isSetId():
sym_math = self._local_symbols[reaction.getId()]
else:
Expand Down Expand Up @@ -2360,9 +2359,9 @@ def _replace_in_all_expressions(
# rule (at the end of the _process_species method), hence needs to be
# processed here too.
self.compartments = {
smart_subs(c, old, new)
if replace_identifiers
else c: smart_subs(v, old, self._make_initial(new))
smart_subs(c, old, new) if replace_identifiers else c: smart_subs(
v, old, self._make_initial(new)
)
for c, v in self.compartments.items()
}

Expand Down
2 changes: 1 addition & 1 deletion python/sdist/amici/sbml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def mathml2sympy(


def _parse_logical_operators(
math_str: Union[str, float, None]
math_str: Union[str, float, None],
) -> Union[str, float, None]:
"""
Parses a math string in order to replace logical operators by a form
Expand Down
5 changes: 4 additions & 1 deletion python/sdist/amici/splines.py
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,10 @@ def spline_user_functions(
"AmiciSplineSensitivity": [
(
lambda *args: True,
lambda spline_id, x, param_id, *p: f"sspl_{spline_ids.index(spline_id)}_{p_index[param_id]}",
lambda spline_id,
x,
param_id,
*p: f"sspl_{spline_ids.index(spline_id)}_{p_index[param_id]}",
)
],
}
Expand Down
2 changes: 1 addition & 1 deletion python/sdist/amici/swig_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _capture_cstdout():


def _get_ptr(
obj: Union[AmiciModel, AmiciExpData, AmiciSolver, AmiciReturnData]
obj: Union[AmiciModel, AmiciExpData, AmiciSolver, AmiciReturnData],
) -> Union[
"amici_swig.Model",
"amici_swig.ExpData",
Expand Down
1 change: 0 additions & 1 deletion python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import copy
import importlib
import os
import shutil
import sys

import amici
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pathlib import Path

import petab
import yaml2sbml

yaml2sbml_yaml = "lotka_volterra.yaml"
Expand Down
1 change: 0 additions & 1 deletion python/tests/test_edata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import amici
import numpy as np
from amici.testing import skip_on_valgrind
from test_sbml_import import model_units_module


@skip_on_valgrind
Expand Down
2 changes: 1 addition & 1 deletion tests/generateTestConfig/example_steadystate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys

import numpy as np
from example import AmiciExample, dict2attrs
from example import AmiciExample


class ExampleSteadystate(AmiciExample):
Expand Down

0 comments on commit 1a74d68

Please sign in to comment.