diff --git a/python/sdist/amici/__init__.template.py b/python/sdist/amici/__init__.template.py index 477cc727ec..f5e49b03dd 100644 --- a/python/sdist/amici/__init__.template.py +++ b/python/sdist/amici/__init__.template.py @@ -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" diff --git a/python/sdist/amici/de_export.py b/python/sdist/amici/de_export.py index 63c9c05072..dddb748cab 100644 --- a/python/sdist/amici/de_export.py +++ b/python/sdist/amici/de_export.py @@ -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 diff --git a/python/sdist/amici/gradient_check.py b/python/sdist/amici/gradient_check.py index d71983b266..5372fcc853 100644 --- a/python/sdist/amici/gradient_check.py +++ b/python/sdist/amici/gradient_check.py @@ -6,7 +6,7 @@ """ import copy -from typing import Callable, List, Optional, Sequence +from typing import List, Optional, Sequence import numpy as np diff --git a/python/sdist/amici/import_utils.py b/python/sdist/amici/import_utils.py index 2dfc60d0c5..9f75fcff75 100644 --- a/python/sdist/amici/import_utils.py +++ b/python/sdist/amici/import_utils.py @@ -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 @@ -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 @@ -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 diff --git a/python/sdist/amici/petab/util.py b/python/sdist/amici/petab/util.py index 6d34fabfdf..8f309e4071 100644 --- a/python/sdist/amici/petab/util.py +++ b/python/sdist/amici/petab/util.py @@ -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 " diff --git a/python/sdist/amici/plotting.py b/python/sdist/amici/plotting.py index edf4a33156..895f83814a 100644 --- a/python/sdist/amici/plotting.py +++ b/python/sdist/amici/plotting.py @@ -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)] diff --git a/python/sdist/amici/pysb_import.py b/python/sdist/amici/pysb_import.py index aa1dc7cd9b..5862d515a1 100644 --- a/python/sdist/amici/pysb_import.py +++ b/python/sdist/amici/pysb_import.py @@ -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) @@ -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. diff --git a/python/sdist/amici/sbml_import.py b/python/sdist/amici/sbml_import.py index 124dfc7a63..d8361c04ab 100644 --- a/python/sdist/amici/sbml_import.py +++ b/python/sdist/amici/sbml_import.py @@ -21,7 +21,6 @@ List, Optional, Sequence, - Set, Tuple, Union, ) @@ -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: @@ -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() } diff --git a/python/sdist/amici/sbml_utils.py b/python/sdist/amici/sbml_utils.py index 66c9d01bbc..75bcb82a18 100644 --- a/python/sdist/amici/sbml_utils.py +++ b/python/sdist/amici/sbml_utils.py @@ -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 diff --git a/python/sdist/amici/splines.py b/python/sdist/amici/splines.py index fdb0912045..657170c2f5 100644 --- a/python/sdist/amici/splines.py +++ b/python/sdist/amici/splines.py @@ -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]}", ) ], } diff --git a/python/sdist/amici/swig_wrappers.py b/python/sdist/amici/swig_wrappers.py index f56f3bd5d2..4983a28f23 100644 --- a/python/sdist/amici/swig_wrappers.py +++ b/python/sdist/amici/swig_wrappers.py @@ -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", diff --git a/python/tests/conftest.py b/python/tests/conftest.py index 9ab64b91d7..1da7cb31b3 100644 --- a/python/tests/conftest.py +++ b/python/tests/conftest.py @@ -2,7 +2,6 @@ import copy import importlib import os -import shutil import sys import amici diff --git a/python/tests/petab_test_problems/lotka_volterra/model/writer.py b/python/tests/petab_test_problems/lotka_volterra/model/writer.py index 76b98c3deb..c6abebaebe 100644 --- a/python/tests/petab_test_problems/lotka_volterra/model/writer.py +++ b/python/tests/petab_test_problems/lotka_volterra/model/writer.py @@ -1,6 +1,5 @@ from pathlib import Path -import petab import yaml2sbml yaml2sbml_yaml = "lotka_volterra.yaml" diff --git a/python/tests/test_edata.py b/python/tests/test_edata.py index 9c4d9b9edc..17164e2d85 100644 --- a/python/tests/test_edata.py +++ b/python/tests/test_edata.py @@ -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 diff --git a/tests/generateTestConfig/example_steadystate.py b/tests/generateTestConfig/example_steadystate.py index 07fab49dfe..80e8a776d2 100755 --- a/tests/generateTestConfig/example_steadystate.py +++ b/tests/generateTestConfig/example_steadystate.py @@ -2,7 +2,7 @@ import sys import numpy as np -from example import AmiciExample, dict2attrs +from example import AmiciExample class ExampleSteadystate(AmiciExample):