diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index b38e6697cb..de2ba64d57 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -10,3 +10,5 @@ a63e49ece0f9336d1f5c2562f7459e555c6e6693 ff6d81c01331c7d269303b4a8321d9881bdf98fa # migrated to ruff-format - https://github.com/pybamm-team/PyBaMM/pull/3655 60ebd4148059a95428a496f4f55c1175ead362d3 +# activated isort - https://github.com/pybamm-team/PyBaMM/pull/3853 +36e6c5a5a36976591275ed4de700dc1b27567ba1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c5ba024f06..d217c25a79 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,3 +37,12 @@ repos: - id: rst-backticks - id: rst-directive-colons - id: rst-inline-touching-normal + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.8.0 + hooks: + - id: mypy + files: pybamm + additional_dependencies: + - numpy + - packaging diff --git a/benchmarks/benchmark_utils.py b/benchmarks/benchmark_utils.py index e5431ff4ea..57dbe0adad 100644 --- a/benchmarks/benchmark_utils.py +++ b/benchmarks/benchmark_utils.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import numpy as np diff --git a/benchmarks/different_model_options.py b/benchmarks/different_model_options.py index a4cf787ad9..00b9cb6f52 100644 --- a/benchmarks/different_model_options.py +++ b/benchmarks/different_model_options.py @@ -1,6 +1,9 @@ +from __future__ import annotations + +import numpy as np + import pybamm from benchmarks.benchmark_utils import set_random_seed -import numpy as np def compute_discretisation(model, param): diff --git a/benchmarks/memory_sims.py b/benchmarks/memory_sims.py index 45d3e41834..567c979606 100644 --- a/benchmarks/memory_sims.py +++ b/benchmarks/memory_sims.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm from benchmarks.benchmark_utils import set_random_seed diff --git a/benchmarks/memory_unit_benchmarks.py b/benchmarks/memory_unit_benchmarks.py index 79970c70ef..619befb622 100644 --- a/benchmarks/memory_unit_benchmarks.py +++ b/benchmarks/memory_unit_benchmarks.py @@ -1,6 +1,9 @@ +from __future__ import annotations + +import numpy as np + import pybamm from benchmarks.benchmark_utils import set_random_seed -import numpy as np class MemCreateExpression: diff --git a/benchmarks/time_setup_models_and_sims.py b/benchmarks/time_setup_models_and_sims.py index 2677c9936c..359e41e4aa 100644 --- a/benchmarks/time_setup_models_and_sims.py +++ b/benchmarks/time_setup_models_and_sims.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm from benchmarks.benchmark_utils import set_random_seed diff --git a/benchmarks/time_sims_experiments.py b/benchmarks/time_sims_experiments.py index bcd3e71f2f..86818257b4 100644 --- a/benchmarks/time_sims_experiments.py +++ b/benchmarks/time_sims_experiments.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm from benchmarks.benchmark_utils import set_random_seed diff --git a/benchmarks/time_solve_models.py b/benchmarks/time_solve_models.py index e41a7ccd16..c036b187ea 100644 --- a/benchmarks/time_solve_models.py +++ b/benchmarks/time_solve_models.py @@ -1,9 +1,11 @@ # Write the benchmarking functions here. # See "Writing benchmarks" in the asv docs for more information. +from __future__ import annotations + +import numpy as np import pybamm from benchmarks.benchmark_utils import set_random_seed -import numpy as np def solve_model_once(model, solver, t_eval): diff --git a/benchmarks/unit_benchmarks.py b/benchmarks/unit_benchmarks.py index 73af4dda26..cd763a1710 100644 --- a/benchmarks/unit_benchmarks.py +++ b/benchmarks/unit_benchmarks.py @@ -1,5 +1,8 @@ -import pybamm +from __future__ import annotations + import numpy as np + +import pybamm from benchmarks.benchmark_utils import set_random_seed diff --git a/benchmarks/work_precision_sets/time_vs_abstols.py b/benchmarks/work_precision_sets/time_vs_abstols.py index d680766c43..29806c9131 100644 --- a/benchmarks/work_precision_sets/time_vs_abstols.py +++ b/benchmarks/work_precision_sets/time_vs_abstols.py @@ -1,8 +1,11 @@ -import pybamm -import numpy as np -import matplotlib.pyplot as plt +from __future__ import annotations + import itertools +import matplotlib.pyplot as plt +import numpy as np + +import pybamm parameters = ["Marquis2019", "Ecker2015", "Ramadass2004", "Chen2020"] diff --git a/benchmarks/work_precision_sets/time_vs_dt_max.py b/benchmarks/work_precision_sets/time_vs_dt_max.py index a1f8ca06bc..c0c630ce2e 100644 --- a/benchmarks/work_precision_sets/time_vs_dt_max.py +++ b/benchmarks/work_precision_sets/time_vs_dt_max.py @@ -1,7 +1,9 @@ -import pybamm -import numpy as np +from __future__ import annotations + import matplotlib.pyplot as plt +import numpy as np +import pybamm parameters = [ "Marquis2019", diff --git a/benchmarks/work_precision_sets/time_vs_mesh_size.py b/benchmarks/work_precision_sets/time_vs_mesh_size.py index cbab18d16c..7f450a1f95 100644 --- a/benchmarks/work_precision_sets/time_vs_mesh_size.py +++ b/benchmarks/work_precision_sets/time_vs_mesh_size.py @@ -1,8 +1,10 @@ -import pybamm +from __future__ import annotations -import matplotlib.pyplot as plt import itertools +import matplotlib.pyplot as plt + +import pybamm parameters = [ "Marquis2019", diff --git a/benchmarks/work_precision_sets/time_vs_no_of_states.py b/benchmarks/work_precision_sets/time_vs_no_of_states.py index febc69f0a1..91e3f106b8 100644 --- a/benchmarks/work_precision_sets/time_vs_no_of_states.py +++ b/benchmarks/work_precision_sets/time_vs_no_of_states.py @@ -1,7 +1,10 @@ -import pybamm -import matplotlib.pyplot as plt +from __future__ import annotations + import itertools +import matplotlib.pyplot as plt + +import pybamm parameters = [ "Marquis2019", diff --git a/benchmarks/work_precision_sets/time_vs_reltols.py b/benchmarks/work_precision_sets/time_vs_reltols.py index 42e9a1bab1..87597af68c 100644 --- a/benchmarks/work_precision_sets/time_vs_reltols.py +++ b/benchmarks/work_precision_sets/time_vs_reltols.py @@ -1,8 +1,11 @@ -import pybamm -import numpy as np -import matplotlib.pyplot as plt +from __future__ import annotations + import itertools +import matplotlib.pyplot as plt +import numpy as np + +import pybamm parameters = [ "Marquis2019", diff --git a/docs/conf.py b/docs/conf.py index 2d83436a71..aab1f97e21 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,8 +11,11 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # +from __future__ import annotations + import os import sys + import pybamm # Path for repository root diff --git a/docs/source/examples/notebooks/batch_study.ipynb b/docs/source/examples/notebooks/batch_study.ipynb index 0c0d216763..eed74bba31 100644 --- a/docs/source/examples/notebooks/batch_study.ipynb +++ b/docs/source/examples/notebooks/batch_study.ipynb @@ -31,6 +31,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm\n", "\n", diff --git a/docs/source/examples/notebooks/change-settings.ipynb b/docs/source/examples/notebooks/change-settings.ipynb index 3e578f07b3..a2901b0035 100644 --- a/docs/source/examples/notebooks/change-settings.ipynb +++ b/docs/source/examples/notebooks/change-settings.ipynb @@ -43,11 +43,15 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np\n", "import os\n", + "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "import pybamm\n", "\n", "os.chdir(pybamm.__path__[0] + \"/..\")\n", "\n", diff --git a/docs/source/examples/notebooks/creating_models/1-an-ode-model.ipynb b/docs/source/examples/notebooks/creating_models/1-an-ode-model.ipynb index dd97a4aad8..61a4d5ba8b 100644 --- a/docs/source/examples/notebooks/creating_models/1-an-ode-model.ipynb +++ b/docs/source/examples/notebooks/creating_models/1-an-ode-model.ipynb @@ -36,10 +36,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import matplotlib.pyplot as plt" + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/creating_models/2-a-pde-model.ipynb b/docs/source/examples/notebooks/creating_models/2-a-pde-model.ipynb index 4926d19432..54cff0f636 100644 --- a/docs/source/examples/notebooks/creating_models/2-a-pde-model.ipynb +++ b/docs/source/examples/notebooks/creating_models/2-a-pde-model.ipynb @@ -41,10 +41,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import matplotlib.pyplot as plt" + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/creating_models/3-negative-particle-problem.ipynb b/docs/source/examples/notebooks/creating_models/3-negative-particle-problem.ipynb index c14c1279e6..b24b8140a8 100644 --- a/docs/source/examples/notebooks/creating_models/3-negative-particle-problem.ipynb +++ b/docs/source/examples/notebooks/creating_models/3-negative-particle-problem.ipynb @@ -58,10 +58,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "import pybamm\n", "\n", "model = pybamm.BaseModel()" ] diff --git a/docs/source/examples/notebooks/creating_models/4-comparing-full-and-reduced-order-models.ipynb b/docs/source/examples/notebooks/creating_models/4-comparing-full-and-reduced-order-models.ipynb index f180d16f0d..9ea9584e0a 100644 --- a/docs/source/examples/notebooks/creating_models/4-comparing-full-and-reduced-order-models.ipynb +++ b/docs/source/examples/notebooks/creating_models/4-comparing-full-and-reduced-order-models.ipynb @@ -62,10 +62,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "import pybamm\n", "\n", "full_model = pybamm.BaseModel(name=\"full model\")\n", "reduced_model = pybamm.BaseModel(name=\"reduced model\")" diff --git a/docs/source/examples/notebooks/creating_models/5-half-cell-model.ipynb b/docs/source/examples/notebooks/creating_models/5-half-cell-model.ipynb index 685ac0b8d1..0cdb20059d 100644 --- a/docs/source/examples/notebooks/creating_models/5-half-cell-model.ipynb +++ b/docs/source/examples/notebooks/creating_models/5-half-cell-model.ipynb @@ -71,10 +71,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import numpy as np\n", "\n", + "import pybamm\n", + "\n", "model = pybamm.BaseModel()" ] }, diff --git a/docs/source/examples/notebooks/creating_models/6-a-simple-SEI-model.ipynb b/docs/source/examples/notebooks/creating_models/6-a-simple-SEI-model.ipynb index fbbe0cac5e..e8df2291c8 100644 --- a/docs/source/examples/notebooks/creating_models/6-a-simple-SEI-model.ipynb +++ b/docs/source/examples/notebooks/creating_models/6-a-simple-SEI-model.ipynb @@ -123,11 +123,15 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np\n", "import os\n", "\n", + "import numpy as np\n", + "\n", + "import pybamm\n", + "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] }, diff --git a/docs/source/examples/notebooks/expression_tree/broadcasts.ipynb b/docs/source/examples/notebooks/expression_tree/broadcasts.ipynb index 466baa3c7a..847a87d057 100644 --- a/docs/source/examples/notebooks/expression_tree/broadcasts.ipynb +++ b/docs/source/examples/notebooks/expression_tree/broadcasts.ipynb @@ -24,9 +24,12 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np" + "import numpy as np\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/expression_tree/expression-tree.ipynb b/docs/source/examples/notebooks/expression_tree/expression-tree.ipynb index a5b38efd9e..fdbbbf576d 100644 --- a/docs/source/examples/notebooks/expression_tree/expression-tree.ipynb +++ b/docs/source/examples/notebooks/expression_tree/expression-tree.ipynb @@ -35,10 +35,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import numpy as np\n", "\n", + "import pybamm\n", + "\n", "y = pybamm.StateVector(slice(0, 1))\n", "t = pybamm.t\n", "equation = 2 * y * (1 - y) + t\n", diff --git a/docs/source/examples/notebooks/getting_started/tutorial-1-how-to-run-a-model.ipynb b/docs/source/examples/notebooks/getting_started/tutorial-1-how-to-run-a-model.ipynb index 226e016300..790a17b385 100644 --- a/docs/source/examples/notebooks/getting_started/tutorial-1-how-to-run-a-model.ipynb +++ b/docs/source/examples/notebooks/getting_started/tutorial-1-how-to-run-a-model.ipynb @@ -34,6 +34,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/getting_started/tutorial-10-creating-a-model.ipynb b/docs/source/examples/notebooks/getting_started/tutorial-10-creating-a-model.ipynb index c788a773b8..c8cd80ea75 100644 --- a/docs/source/examples/notebooks/getting_started/tutorial-10-creating-a-model.ipynb +++ b/docs/source/examples/notebooks/getting_started/tutorial-10-creating-a-model.ipynb @@ -40,6 +40,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/getting_started/tutorial-11-creating-a-submodel.ipynb b/docs/source/examples/notebooks/getting_started/tutorial-11-creating-a-submodel.ipynb index 45dd6a7702..72b940d990 100644 --- a/docs/source/examples/notebooks/getting_started/tutorial-11-creating-a-submodel.ipynb +++ b/docs/source/examples/notebooks/getting_started/tutorial-11-creating-a-submodel.ipynb @@ -32,6 +32,8 @@ "metadata": {}, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/getting_started/tutorial-2-compare-models.ipynb b/docs/source/examples/notebooks/getting_started/tutorial-2-compare-models.ipynb index aa957be1b3..4eca6125b0 100644 --- a/docs/source/examples/notebooks/getting_started/tutorial-2-compare-models.ipynb +++ b/docs/source/examples/notebooks/getting_started/tutorial-2-compare-models.ipynb @@ -32,6 +32,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/getting_started/tutorial-3-basic-plotting.ipynb b/docs/source/examples/notebooks/getting_started/tutorial-3-basic-plotting.ipynb index 7fee5435c9..2402b4d846 100644 --- a/docs/source/examples/notebooks/getting_started/tutorial-3-basic-plotting.ipynb +++ b/docs/source/examples/notebooks/getting_started/tutorial-3-basic-plotting.ipynb @@ -40,10 +40,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import matplotlib.pyplot as plt\n", "\n", + "import pybamm\n", + "\n", "model_dfn = pybamm.lithium_ion.DFN()\n", "sim_dfn = pybamm.Simulation(model_dfn)\n", "sim_dfn.solve([0, 3600])" diff --git a/docs/source/examples/notebooks/getting_started/tutorial-4-setting-parameter-values.ipynb b/docs/source/examples/notebooks/getting_started/tutorial-4-setting-parameter-values.ipynb index 59feef7919..2445a9a379 100644 --- a/docs/source/examples/notebooks/getting_started/tutorial-4-setting-parameter-values.ipynb +++ b/docs/source/examples/notebooks/getting_started/tutorial-4-setting-parameter-values.ipynb @@ -32,10 +32,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import os\n", "\n", + "import pybamm\n", + "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] }, diff --git a/docs/source/examples/notebooks/getting_started/tutorial-5-run-experiments.ipynb b/docs/source/examples/notebooks/getting_started/tutorial-5-run-experiments.ipynb index 9ec8d79cf1..321d0527e0 100644 --- a/docs/source/examples/notebooks/getting_started/tutorial-5-run-experiments.ipynb +++ b/docs/source/examples/notebooks/getting_started/tutorial-5-run-experiments.ipynb @@ -33,9 +33,12 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np" + "import numpy as np\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/getting_started/tutorial-6-managing-simulation-outputs.ipynb b/docs/source/examples/notebooks/getting_started/tutorial-6-managing-simulation-outputs.ipynb index f2e1b9be75..5e41a71368 100644 --- a/docs/source/examples/notebooks/getting_started/tutorial-6-managing-simulation-outputs.ipynb +++ b/docs/source/examples/notebooks/getting_started/tutorial-6-managing-simulation-outputs.ipynb @@ -42,6 +42,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm\n", "\n", diff --git a/docs/source/examples/notebooks/getting_started/tutorial-7-model-options.ipynb b/docs/source/examples/notebooks/getting_started/tutorial-7-model-options.ipynb index 8969afc15a..49a9452c19 100644 --- a/docs/source/examples/notebooks/getting_started/tutorial-7-model-options.ipynb +++ b/docs/source/examples/notebooks/getting_started/tutorial-7-model-options.ipynb @@ -24,6 +24,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/getting_started/tutorial-8-solver-options.ipynb b/docs/source/examples/notebooks/getting_started/tutorial-8-solver-options.ipynb index 2e55321659..3455b02c4e 100644 --- a/docs/source/examples/notebooks/getting_started/tutorial-8-solver-options.ipynb +++ b/docs/source/examples/notebooks/getting_started/tutorial-8-solver-options.ipynb @@ -28,6 +28,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/getting_started/tutorial-9-changing-the-mesh.ipynb b/docs/source/examples/notebooks/getting_started/tutorial-9-changing-the-mesh.ipynb index 7cee8dd679..055710099f 100644 --- a/docs/source/examples/notebooks/getting_started/tutorial-9-changing-the-mesh.ipynb +++ b/docs/source/examples/notebooks/getting_started/tutorial-9-changing-the-mesh.ipynb @@ -28,6 +28,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/initialize-model-with-solution.ipynb b/docs/source/examples/notebooks/initialize-model-with-solution.ipynb index aa7bea4d5c..4eb7f908a0 100644 --- a/docs/source/examples/notebooks/initialize-model-with-solution.ipynb +++ b/docs/source/examples/notebooks/initialize-model-with-solution.ipynb @@ -30,12 +30,16 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "\n", - "import pybamm\n", - "import pandas as pd\n", "import os\n", "\n", + "import pandas as pd\n", + "\n", + "import pybamm\n", + "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] }, diff --git a/docs/source/examples/notebooks/models/DFN-with-particle-size-distributions.ipynb b/docs/source/examples/notebooks/models/DFN-with-particle-size-distributions.ipynb index d3553ed278..3cfbf4a65f 100644 --- a/docs/source/examples/notebooks/models/DFN-with-particle-size-distributions.ipynb +++ b/docs/source/examples/notebooks/models/DFN-with-particle-size-distributions.ipynb @@ -42,9 +42,12 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import matplotlib.pyplot as plt" + "import matplotlib.pyplot as plt\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/models/DFN.ipynb b/docs/source/examples/notebooks/models/DFN.ipynb index a6237a2f3f..3bcd3d50a5 100644 --- a/docs/source/examples/notebooks/models/DFN.ipynb +++ b/docs/source/examples/notebooks/models/DFN.ipynb @@ -128,9 +128,12 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np" + "import numpy as np\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/models/MPM.ipynb b/docs/source/examples/notebooks/models/MPM.ipynb index 82e5a9502d..b3897f64a9 100644 --- a/docs/source/examples/notebooks/models/MPM.ipynb +++ b/docs/source/examples/notebooks/models/MPM.ipynb @@ -103,9 +103,12 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import matplotlib.pyplot as plt" + "import matplotlib.pyplot as plt\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/models/MSMR.ipynb b/docs/source/examples/notebooks/models/MSMR.ipynb index 3f009a045a..368f702505 100644 --- a/docs/source/examples/notebooks/models/MSMR.ipynb +++ b/docs/source/examples/notebooks/models/MSMR.ipynb @@ -23,9 +23,12 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import matplotlib.pyplot as plt" + "import matplotlib.pyplot as plt\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/models/SEI-on-cracks.ipynb b/docs/source/examples/notebooks/models/SEI-on-cracks.ipynb index f9d41ffc54..b70a34273a 100644 --- a/docs/source/examples/notebooks/models/SEI-on-cracks.ipynb +++ b/docs/source/examples/notebooks/models/SEI-on-cracks.ipynb @@ -28,9 +28,12 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import matplotlib.pyplot as plt" + "import matplotlib.pyplot as plt\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/models/SPM.ipynb b/docs/source/examples/notebooks/models/SPM.ipynb index 9b01b13a80..693417bf04 100644 --- a/docs/source/examples/notebooks/models/SPM.ipynb +++ b/docs/source/examples/notebooks/models/SPM.ipynb @@ -73,11 +73,15 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np\n", "import os\n", + "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "import pybamm\n", "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] diff --git a/docs/source/examples/notebooks/models/SPMe.ipynb b/docs/source/examples/notebooks/models/SPMe.ipynb index 1e60568055..b681d56753 100644 --- a/docs/source/examples/notebooks/models/SPMe.ipynb +++ b/docs/source/examples/notebooks/models/SPMe.ipynb @@ -126,6 +126,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/models/Validating_mechanical_models_Enertech_DFN.ipynb b/docs/source/examples/notebooks/models/Validating_mechanical_models_Enertech_DFN.ipynb index 8e1b742c15..570a41d2cd 100644 --- a/docs/source/examples/notebooks/models/Validating_mechanical_models_Enertech_DFN.ipynb +++ b/docs/source/examples/notebooks/models/Validating_mechanical_models_Enertech_DFN.ipynb @@ -23,11 +23,15 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import os\n", + "\n", "import matplotlib.pyplot as plt\n", "\n", + "import pybamm\n", + "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] }, diff --git a/docs/source/examples/notebooks/models/compare-comsol-discharge-curve.ipynb b/docs/source/examples/notebooks/models/compare-comsol-discharge-curve.ipynb index 2faac3bb1d..4729ea1f74 100644 --- a/docs/source/examples/notebooks/models/compare-comsol-discharge-curve.ipynb +++ b/docs/source/examples/notebooks/models/compare-comsol-discharge-curve.ipynb @@ -32,12 +32,16 @@ }, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np\n", "import os\n", "import pickle\n", + "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "import pybamm\n", "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] diff --git a/docs/source/examples/notebooks/models/compare-ecker-data.ipynb b/docs/source/examples/notebooks/models/compare-ecker-data.ipynb index b0db095926..5d7581065c 100644 --- a/docs/source/examples/notebooks/models/compare-ecker-data.ipynb +++ b/docs/source/examples/notebooks/models/compare-ecker-data.ipynb @@ -32,12 +32,16 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import os\n", - "import pandas as pd\n", - "import numpy as np\n", + "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "import pandas as pd\n", + "\n", + "import pybamm\n", "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] diff --git a/docs/source/examples/notebooks/models/compare-lithium-ion.ipynb b/docs/source/examples/notebooks/models/compare-lithium-ion.ipynb index 36dbe5a6af..a8ec42b86d 100644 --- a/docs/source/examples/notebooks/models/compare-lithium-ion.ipynb +++ b/docs/source/examples/notebooks/models/compare-lithium-ion.ipynb @@ -48,14 +48,17 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import os\n", "\n", + "import pybamm\n", + "\n", "os.chdir(pybamm.__path__[0] + \"/..\")\n", "\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt" + "import matplotlib.pyplot as plt\n", + "import numpy as np" ] }, { diff --git a/docs/source/examples/notebooks/models/compare-particle-diffusion-models.ipynb b/docs/source/examples/notebooks/models/compare-particle-diffusion-models.ipynb index 2d74940e3d..6a90df0afc 100644 --- a/docs/source/examples/notebooks/models/compare-particle-diffusion-models.ipynb +++ b/docs/source/examples/notebooks/models/compare-particle-diffusion-models.ipynb @@ -35,11 +35,15 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import os\n", - "import numpy as np\n", + "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "import pybamm\n", "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] diff --git a/docs/source/examples/notebooks/models/composite_particle.ipynb b/docs/source/examples/notebooks/models/composite_particle.ipynb index 387ffd7512..6c5d78f8e3 100644 --- a/docs/source/examples/notebooks/models/composite_particle.ipynb +++ b/docs/source/examples/notebooks/models/composite_particle.ipynb @@ -37,13 +37,17 @@ "outputs": [], "source": [ "# %pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", + "from __future__ import annotations\n", + "\n", "import os\n", + "import timeit\n", + "\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import pybamm\n", - "import timeit\n", "from matplotlib import style\n", "\n", + "import pybamm\n", + "\n", "style.use(\"ggplot\")\n", "os.chdir(pybamm.__path__[0] + \"/..\")\n", "pybamm.set_logging_level(\"INFO\")" diff --git a/docs/source/examples/notebooks/models/coupled-degradation.ipynb b/docs/source/examples/notebooks/models/coupled-degradation.ipynb index 8c083d986a..aba86f1d67 100644 --- a/docs/source/examples/notebooks/models/coupled-degradation.ipynb +++ b/docs/source/examples/notebooks/models/coupled-degradation.ipynb @@ -28,9 +28,12 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import matplotlib.pyplot as plt" + "import matplotlib.pyplot as plt\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/models/electrode-state-of-health.ipynb b/docs/source/examples/notebooks/models/electrode-state-of-health.ipynb index 5528b74830..0dcc6ec0a6 100644 --- a/docs/source/examples/notebooks/models/electrode-state-of-health.ipynb +++ b/docs/source/examples/notebooks/models/electrode-state-of-health.ipynb @@ -31,10 +31,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import matplotlib.pyplot as plt\n", - "import numpy as np" + "import numpy as np\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/models/half-cell.ipynb b/docs/source/examples/notebooks/models/half-cell.ipynb index 2085162694..292c53b1e8 100644 --- a/docs/source/examples/notebooks/models/half-cell.ipynb +++ b/docs/source/examples/notebooks/models/half-cell.ipynb @@ -25,9 +25,12 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install pybamm -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import matplotlib.pyplot as plt" + "import matplotlib.pyplot as plt\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/models/jelly-roll-model.ipynb b/docs/source/examples/notebooks/models/jelly-roll-model.ipynb index 86dd684b64..f6f233abf2 100644 --- a/docs/source/examples/notebooks/models/jelly-roll-model.ipynb +++ b/docs/source/examples/notebooks/models/jelly-roll-model.ipynb @@ -54,11 +54,14 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from numpy import pi\n", - "import matplotlib.pyplot as plt" + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/models/latexify.ipynb b/docs/source/examples/notebooks/models/latexify.ipynb index 5e50c1c12e..0bdad81b57 100644 --- a/docs/source/examples/notebooks/models/latexify.ipynb +++ b/docs/source/examples/notebooks/models/latexify.ipynb @@ -31,6 +31,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/models/lead-acid.ipynb b/docs/source/examples/notebooks/models/lead-acid.ipynb index ccfa35b091..8b24943661 100644 --- a/docs/source/examples/notebooks/models/lead-acid.ipynb +++ b/docs/source/examples/notebooks/models/lead-acid.ipynb @@ -32,11 +32,15 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np\n", "import os\n", + "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "import pybamm\n", "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] diff --git a/docs/source/examples/notebooks/models/lithium-plating.ipynb b/docs/source/examples/notebooks/models/lithium-plating.ipynb index e84fdbb1ac..4ee7a2c75e 100644 --- a/docs/source/examples/notebooks/models/lithium-plating.ipynb +++ b/docs/source/examples/notebooks/models/lithium-plating.ipynb @@ -15,10 +15,13 @@ "metadata": {}, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import os\n", "\n", + "import pybamm\n", + "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] }, diff --git a/docs/source/examples/notebooks/models/loss_of_active_materials.ipynb b/docs/source/examples/notebooks/models/loss_of_active_materials.ipynb index 127763ec35..28bc6682ec 100644 --- a/docs/source/examples/notebooks/models/loss_of_active_materials.ipynb +++ b/docs/source/examples/notebooks/models/loss_of_active_materials.ipynb @@ -32,6 +32,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm\n", "\n", diff --git a/docs/source/examples/notebooks/models/pouch-cell-model.ipynb b/docs/source/examples/notebooks/models/pouch-cell-model.ipynb index 2059bb8144..23da35a26f 100644 --- a/docs/source/examples/notebooks/models/pouch-cell-model.ipynb +++ b/docs/source/examples/notebooks/models/pouch-cell-model.ipynb @@ -57,12 +57,16 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import pickle\n", + "\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import scipy.interpolate as interp" + "import scipy.interpolate as interp\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/models/rate-capability.ipynb b/docs/source/examples/notebooks/models/rate-capability.ipynb index ef09a37909..0f33f8ce33 100644 --- a/docs/source/examples/notebooks/models/rate-capability.ipynb +++ b/docs/source/examples/notebooks/models/rate-capability.ipynb @@ -30,10 +30,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import matplotlib.pyplot as plt" + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/models/saving_models.ipynb b/docs/source/examples/notebooks/models/saving_models.ipynb index 57bda3ef85..07aa3e3974 100644 --- a/docs/source/examples/notebooks/models/saving_models.ipynb +++ b/docs/source/examples/notebooks/models/saving_models.ipynb @@ -30,6 +30,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install pybamm -q # install PyBaMM if it is not installed\n", "import pybamm\n", "\n", diff --git a/docs/source/examples/notebooks/models/simulate-3E-cell.ipynb b/docs/source/examples/notebooks/models/simulate-3E-cell.ipynb index c92cb53465..d509ed1e04 100644 --- a/docs/source/examples/notebooks/models/simulate-3E-cell.ipynb +++ b/docs/source/examples/notebooks/models/simulate-3E-cell.ipynb @@ -24,6 +24,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/models/simulating-ORegan-2022-parameter-set.ipynb b/docs/source/examples/notebooks/models/simulating-ORegan-2022-parameter-set.ipynb index 9965a78563..d64515b8c6 100644 --- a/docs/source/examples/notebooks/models/simulating-ORegan-2022-parameter-set.ipynb +++ b/docs/source/examples/notebooks/models/simulating-ORegan-2022-parameter-set.ipynb @@ -25,6 +25,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/models/submodel_cracking_DFN_or_SPM.ipynb b/docs/source/examples/notebooks/models/submodel_cracking_DFN_or_SPM.ipynb index ac92c06d15..329a458649 100644 --- a/docs/source/examples/notebooks/models/submodel_cracking_DFN_or_SPM.ipynb +++ b/docs/source/examples/notebooks/models/submodel_cracking_DFN_or_SPM.ipynb @@ -19,11 +19,15 @@ }, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import os\n", + "\n", "import matplotlib.pyplot as plt\n", "\n", + "import pybamm\n", + "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] }, diff --git a/docs/source/examples/notebooks/models/thermal-models.ipynb b/docs/source/examples/notebooks/models/thermal-models.ipynb index 599a362b4b..42ca363605 100644 --- a/docs/source/examples/notebooks/models/thermal-models.ipynb +++ b/docs/source/examples/notebooks/models/thermal-models.ipynb @@ -29,6 +29,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/models/unsteady-heat-equation.ipynb b/docs/source/examples/notebooks/models/unsteady-heat-equation.ipynb index 5e3d11a0ee..9e2180a2f8 100644 --- a/docs/source/examples/notebooks/models/unsteady-heat-equation.ipynb +++ b/docs/source/examples/notebooks/models/unsteady-heat-equation.ipynb @@ -45,10 +45,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import matplotlib.pyplot as plt" + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/models/using-model-options_thermal-example.ipynb b/docs/source/examples/notebooks/models/using-model-options_thermal-example.ipynb index 1f6250f760..fb529e543a 100644 --- a/docs/source/examples/notebooks/models/using-model-options_thermal-example.ipynb +++ b/docs/source/examples/notebooks/models/using-model-options_thermal-example.ipynb @@ -32,10 +32,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import os\n", "\n", + "import pybamm\n", + "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] }, diff --git a/docs/source/examples/notebooks/models/using-submodels.ipynb b/docs/source/examples/notebooks/models/using-submodels.ipynb index 5c00de05da..c2b1f212e6 100644 --- a/docs/source/examples/notebooks/models/using-submodels.ipynb +++ b/docs/source/examples/notebooks/models/using-submodels.ipynb @@ -32,6 +32,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/parameterization/change-input-current.ipynb b/docs/source/examples/notebooks/parameterization/change-input-current.ipynb index 28fc476e16..142bb28e70 100644 --- a/docs/source/examples/notebooks/parameterization/change-input-current.ipynb +++ b/docs/source/examples/notebooks/parameterization/change-input-current.ipynb @@ -41,11 +41,15 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np\n", "import os\n", "\n", + "import numpy as np\n", + "\n", + "import pybamm\n", + "\n", "os.chdir(pybamm.__path__[0] + \"/..\")\n", "\n", "# create the model\n", diff --git a/docs/source/examples/notebooks/parameterization/parameter-values.ipynb b/docs/source/examples/notebooks/parameterization/parameter-values.ipynb index b13084b166..dfbf713312 100644 --- a/docs/source/examples/notebooks/parameterization/parameter-values.ipynb +++ b/docs/source/examples/notebooks/parameterization/parameter-values.ipynb @@ -31,11 +31,15 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np\n", "import os\n", + "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "import pybamm\n", "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] diff --git a/docs/source/examples/notebooks/parameterization/parameterization.ipynb b/docs/source/examples/notebooks/parameterization/parameterization.ipynb index d201ef1024..92a30e4b9d 100644 --- a/docs/source/examples/notebooks/parameterization/parameterization.ipynb +++ b/docs/source/examples/notebooks/parameterization/parameterization.ipynb @@ -46,10 +46,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import matplotlib.pyplot as plt" + "\n", + "import pybamm" ] }, { @@ -1113,7 +1116,7 @@ " ]\n", ")\n", "\n", - "from pybamm import exp, constants\n", + "from pybamm import constants, exp\n", "\n", "\n", "def graphite_LGM50_electrolyte_exchange_current_density_Chen2020(\n", diff --git a/docs/source/examples/notebooks/plotting/customize-quick-plot.ipynb b/docs/source/examples/notebooks/plotting/customize-quick-plot.ipynb index 67b81b4ae6..276bf8273a 100644 --- a/docs/source/examples/notebooks/plotting/customize-quick-plot.ipynb +++ b/docs/source/examples/notebooks/plotting/customize-quick-plot.ipynb @@ -45,6 +45,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm\n", "\n", diff --git a/docs/source/examples/notebooks/plotting/plot-voltage-components.ipynb b/docs/source/examples/notebooks/plotting/plot-voltage-components.ipynb index be0706bbfe..2ec9fdf17a 100644 --- a/docs/source/examples/notebooks/plotting/plot-voltage-components.ipynb +++ b/docs/source/examples/notebooks/plotting/plot-voltage-components.ipynb @@ -116,6 +116,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm\n", "\n", diff --git a/docs/source/examples/notebooks/simulations_and_experiments/callbacks.ipynb b/docs/source/examples/notebooks/simulations_and_experiments/callbacks.ipynb index f6fb7609ae..c0d2f01bfe 100644 --- a/docs/source/examples/notebooks/simulations_and_experiments/callbacks.ipynb +++ b/docs/source/examples/notebooks/simulations_and_experiments/callbacks.ipynb @@ -48,6 +48,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q\n", "import pybamm\n", "\n", diff --git a/docs/source/examples/notebooks/simulations_and_experiments/custom-experiments.ipynb b/docs/source/examples/notebooks/simulations_and_experiments/custom-experiments.ipynb index 4dfa8c8c72..89f143b254 100644 --- a/docs/source/examples/notebooks/simulations_and_experiments/custom-experiments.ipynb +++ b/docs/source/examples/notebooks/simulations_and_experiments/custom-experiments.ipynb @@ -21,6 +21,8 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/simulations_and_experiments/experiments-start-time.ipynb b/docs/source/examples/notebooks/simulations_and_experiments/experiments-start-time.ipynb index 60699ab6b2..046cb15d57 100644 --- a/docs/source/examples/notebooks/simulations_and_experiments/experiments-start-time.ipynb +++ b/docs/source/examples/notebooks/simulations_and_experiments/experiments-start-time.ipynb @@ -36,9 +36,12 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "from datetime import datetime" + "from datetime import datetime\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/simulations_and_experiments/rpt-experiment.ipynb b/docs/source/examples/notebooks/simulations_and_experiments/rpt-experiment.ipynb index fe06dadffe..f108951dbc 100644 --- a/docs/source/examples/notebooks/simulations_and_experiments/rpt-experiment.ipynb +++ b/docs/source/examples/notebooks/simulations_and_experiments/rpt-experiment.ipynb @@ -31,12 +31,16 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install pybamm[plot,cite] -q # install PyBaMM if it is not installed\n", "\n", - "import pybamm\n", - "import matplotlib.pyplot as plt\n", "import os\n", "\n", + "import matplotlib.pyplot as plt\n", + "\n", + "import pybamm\n", + "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] }, diff --git a/docs/source/examples/notebooks/simulations_and_experiments/simulating-long-experiments.ipynb b/docs/source/examples/notebooks/simulations_and_experiments/simulating-long-experiments.ipynb index c7f1f0e634..21f4e8073a 100644 --- a/docs/source/examples/notebooks/simulations_and_experiments/simulating-long-experiments.ipynb +++ b/docs/source/examples/notebooks/simulations_and_experiments/simulating-long-experiments.ipynb @@ -33,9 +33,12 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import matplotlib.pyplot as plt" + "import matplotlib.pyplot as plt\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/simulations_and_experiments/simulation-class.ipynb b/docs/source/examples/notebooks/simulations_and_experiments/simulation-class.ipynb index db2a0fb20d..1460a5654d 100644 --- a/docs/source/examples/notebooks/simulations_and_experiments/simulation-class.ipynb +++ b/docs/source/examples/notebooks/simulations_and_experiments/simulation-class.ipynb @@ -17,6 +17,8 @@ "metadata": {}, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", "import pybamm" ] diff --git a/docs/source/examples/notebooks/solution-data-and-processed-variables.ipynb b/docs/source/examples/notebooks/solution-data-and-processed-variables.ipynb index 3379b05991..1cc3c75710 100644 --- a/docs/source/examples/notebooks/solution-data-and-processed-variables.ipynb +++ b/docs/source/examples/notebooks/solution-data-and-processed-variables.ipynb @@ -42,11 +42,15 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np\n", "import os\n", + "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "import pybamm\n", "\n", "os.chdir(pybamm.__path__[0] + \"/..\")\n", "\n", diff --git a/docs/source/examples/notebooks/solvers/dae-solver.ipynb b/docs/source/examples/notebooks/solvers/dae-solver.ipynb index cb8293c676..9bd3f44e80 100644 --- a/docs/source/examples/notebooks/solvers/dae-solver.ipynb +++ b/docs/source/examples/notebooks/solvers/dae-solver.ipynb @@ -25,11 +25,15 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np\n", "import os\n", + "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "import pybamm\n", "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] diff --git a/docs/source/examples/notebooks/solvers/idaklu-jax-interface.ipynb b/docs/source/examples/notebooks/solvers/idaklu-jax-interface.ipynb index a1204b6589..99d2539262 100644 --- a/docs/source/examples/notebooks/solvers/idaklu-jax-interface.ipynb +++ b/docs/source/examples/notebooks/solvers/idaklu-jax-interface.ipynb @@ -42,12 +42,16 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[jax]\" -q # install PyBaMM with JAX support if it is not installed\n", - "import pybamm\n", "import time\n", - "import numpy as np\n", + "\n", "import jax\n", - "import jax.numpy as jnp" + "import jax.numpy as jnp\n", + "import numpy as np\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/solvers/ode-solver.ipynb b/docs/source/examples/notebooks/solvers/ode-solver.ipynb index 156b7b2ada..c2c8257397 100644 --- a/docs/source/examples/notebooks/solvers/ode-solver.ipynb +++ b/docs/source/examples/notebooks/solvers/ode-solver.ipynb @@ -25,11 +25,15 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np\n", "import os\n", + "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "import pybamm\n", "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] diff --git a/docs/source/examples/notebooks/solvers/speed-up-solver.ipynb b/docs/source/examples/notebooks/solvers/speed-up-solver.ipynb index c49c8926fb..2cefb8300b 100644 --- a/docs/source/examples/notebooks/solvers/speed-up-solver.ipynb +++ b/docs/source/examples/notebooks/solvers/speed-up-solver.ipynb @@ -33,10 +33,13 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", "import matplotlib.pyplot as plt\n", - "import numpy as np" + "import numpy as np\n", + "\n", + "import pybamm" ] }, { diff --git a/docs/source/examples/notebooks/spatial_methods/finite-volumes.ipynb b/docs/source/examples/notebooks/spatial_methods/finite-volumes.ipynb index 849f1bdf47..e093604df5 100644 --- a/docs/source/examples/notebooks/spatial_methods/finite-volumes.ipynb +++ b/docs/source/examples/notebooks/spatial_methods/finite-volumes.ipynb @@ -62,11 +62,15 @@ } ], "source": [ + "from __future__ import annotations\n", + "\n", "%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", - "import pybamm\n", - "import numpy as np\n", "import os\n", + "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "import pybamm\n", "\n", "os.chdir(pybamm.__path__[0] + \"/..\")" ] diff --git a/docs/sphinxext/extend_parent.py b/docs/sphinxext/extend_parent.py index 25978fe804..aceec06400 100644 --- a/docs/sphinxext/extend_parent.py +++ b/docs/sphinxext/extend_parent.py @@ -1,6 +1,7 @@ # Sphinx extension to add a link to a base class in the docstring of a derived class # via the **Extends** directive. The base class is determined by the method resolution # order (MRO) of the derived class. +from __future__ import annotations from inspect import getmro, isclass diff --git a/docs/sphinxext/inheritance_diagram.py b/docs/sphinxext/inheritance_diagram.py index 30a61aeba2..b8b30bf968 100644 --- a/docs/sphinxext/inheritance_diagram.py +++ b/docs/sphinxext/inheritance_diagram.py @@ -1,6 +1,7 @@ # Sphinx extension to add an inheritance diagram in the docstring of a class built upon # the built-in sphinxext.inheritance_diagram extension. The inheritance diagram is # generated via graphviz and the fully qualified name of the class. +from __future__ import annotations from inspect import getmro, isclass diff --git a/examples/scripts/DFN.py b/examples/scripts/DFN.py index 15a4853e85..037e627569 100644 --- a/examples/scripts/DFN.py +++ b/examples/scripts/DFN.py @@ -1,10 +1,12 @@ # # Example showing how to load and solve the DFN # +from __future__ import annotations -import pybamm import numpy as np +import pybamm + pybamm.set_logging_level("INFO") # load model diff --git a/examples/scripts/DFN_ambient_temperature.py b/examples/scripts/DFN_ambient_temperature.py index 4d724aaa0e..bb1742f527 100644 --- a/examples/scripts/DFN_ambient_temperature.py +++ b/examples/scripts/DFN_ambient_temperature.py @@ -1,10 +1,12 @@ # # Example showing how to solve the DFN with a varying ambient temperature # +from __future__ import annotations -import pybamm import numpy as np +import pybamm + pybamm.set_logging_level("DEBUG") diff --git a/examples/scripts/DFN_size_distributions.py b/examples/scripts/DFN_size_distributions.py index 6950af8677..e642570942 100644 --- a/examples/scripts/DFN_size_distributions.py +++ b/examples/scripts/DFN_size_distributions.py @@ -2,6 +2,8 @@ # Compare the DFN with particle size distributions (MP-DFN) # to the DFN with a single particle size, and the MPM # +from __future__ import annotations + import pybamm pybamm.set_logging_level("INFO") diff --git a/examples/scripts/MSMR.py b/examples/scripts/MSMR.py index 4ceb4fc9f4..1f728d6938 100644 --- a/examples/scripts/MSMR.py +++ b/examples/scripts/MSMR.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm pybamm.set_logging_level("INFO") diff --git a/examples/scripts/SPM_compare_particle_grid.py b/examples/scripts/SPM_compare_particle_grid.py index 44a6f84edb..6d90662eba 100644 --- a/examples/scripts/SPM_compare_particle_grid.py +++ b/examples/scripts/SPM_compare_particle_grid.py @@ -1,10 +1,14 @@ # # Compare different discretisations in the particle # +from __future__ import annotations + import argparse + +import matplotlib.pyplot as plt import numpy as np + import pybamm -import matplotlib.pyplot as plt parser = argparse.ArgumentParser() parser.add_argument( diff --git a/examples/scripts/SPMe.py b/examples/scripts/SPMe.py index 6c40a65e6b..0a1a6d509d 100644 --- a/examples/scripts/SPMe.py +++ b/examples/scripts/SPMe.py @@ -1,10 +1,12 @@ # # Example showing how to load and solve the SPMe # +from __future__ import annotations -import pybamm import numpy as np +import pybamm + pybamm.set_logging_level("INFO") # load model diff --git a/examples/scripts/SPMe_SOC.py b/examples/scripts/SPMe_SOC.py index 3094864170..38a81b840f 100644 --- a/examples/scripts/SPMe_SOC.py +++ b/examples/scripts/SPMe_SOC.py @@ -8,9 +8,12 @@ # The negative electrode thickness is varied to highlight the importance of electrode # sizing to enable full lithium utilization # -import pybamm -import numpy as np +from __future__ import annotations + import matplotlib.pyplot as plt +import numpy as np + +import pybamm factor = 6.38 capacities = [] diff --git a/examples/scripts/SPMe_step.py b/examples/scripts/SPMe_step.py index 90d6f3d017..72c2421109 100644 --- a/examples/scripts/SPMe_step.py +++ b/examples/scripts/SPMe_step.py @@ -1,9 +1,12 @@ # # Example to compare solving for all times against stepping individually # -import pybamm -import numpy as np +from __future__ import annotations + import matplotlib.pyplot as plt +import numpy as np + +import pybamm pybamm.set_logging_level("INFO") diff --git a/examples/scripts/calendar_ageing.py b/examples/scripts/calendar_ageing.py index 7714ab5ad4..377ca6d941 100644 --- a/examples/scripts/calendar_ageing.py +++ b/examples/scripts/calendar_ageing.py @@ -1,6 +1,9 @@ -import pybamm as pb +from __future__ import annotations + import numpy as np +import pybamm as pb + pb.set_logging_level("INFO") models = [ diff --git a/examples/scripts/compare_comsol/compare_comsol_DFN.py b/examples/scripts/compare_comsol/compare_comsol_DFN.py index 45bc4182ef..488baed09c 100644 --- a/examples/scripts/compare_comsol/compare_comsol_DFN.py +++ b/examples/scripts/compare_comsol/compare_comsol_DFN.py @@ -1,8 +1,12 @@ -import pybamm +from __future__ import annotations + import os import pickle + import scipy.interpolate as interp +import pybamm + # change working directory to the root of pybamm os.chdir(pybamm.root_dir()) diff --git a/examples/scripts/compare_comsol/discharge_curve.py b/examples/scripts/compare_comsol/discharge_curve.py index 9e437ce301..39da9daee5 100644 --- a/examples/scripts/compare_comsol/discharge_curve.py +++ b/examples/scripts/compare_comsol/discharge_curve.py @@ -1,8 +1,12 @@ -import pybamm -import numpy as np +from __future__ import annotations + import os import pickle + import matplotlib.pyplot as plt +import numpy as np + +import pybamm # change working directory to the root of pybamm os.chdir(pybamm.root_dir()) diff --git a/examples/scripts/compare_dae_solver.py b/examples/scripts/compare_dae_solver.py index c98309a2ed..51d596b9ce 100644 --- a/examples/scripts/compare_dae_solver.py +++ b/examples/scripts/compare_dae_solver.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + pybamm.set_logging_level("INFO") # load model diff --git a/examples/scripts/compare_extrapolations.py b/examples/scripts/compare_extrapolations.py index 76ed6e057e..4fbe012a79 100644 --- a/examples/scripts/compare_extrapolations.py +++ b/examples/scripts/compare_extrapolations.py @@ -1,5 +1,6 @@ -import pybamm +from __future__ import annotations +import pybamm x_n = pybamm.standard_spatial_vars.x_n x_s = pybamm.standard_spatial_vars.x_s diff --git a/examples/scripts/compare_intercalation_kinetics.py b/examples/scripts/compare_intercalation_kinetics.py index 71cce66c5c..a1ef8b1997 100644 --- a/examples/scripts/compare_intercalation_kinetics.py +++ b/examples/scripts/compare_intercalation_kinetics.py @@ -1,6 +1,8 @@ # # Compare different models for intercalation kinetics. # +from __future__ import annotations + import pybamm pybamm.set_logging_level("INFO") diff --git a/examples/scripts/compare_interface_utilisation.py b/examples/scripts/compare_interface_utilisation.py index aa652d9b8b..123d35d2df 100644 --- a/examples/scripts/compare_interface_utilisation.py +++ b/examples/scripts/compare_interface_utilisation.py @@ -1,10 +1,12 @@ # # Example showing how to change the interface utilisation # +from __future__ import annotations -import pybamm import numpy as np +import pybamm + pybamm.set_logging_level("INFO") models = [ diff --git a/examples/scripts/compare_lead_acid.py b/examples/scripts/compare_lead_acid.py index 148f42adc2..ac9dd9d2db 100644 --- a/examples/scripts/compare_lead_acid.py +++ b/examples/scripts/compare_lead_acid.py @@ -1,6 +1,8 @@ # # Compare lead-acid battery models # +from __future__ import annotations + import pybamm pybamm.set_logging_level("INFO") diff --git a/examples/scripts/compare_lithium_ion.py b/examples/scripts/compare_lithium_ion.py index 6108036b9b..506830f0e1 100644 --- a/examples/scripts/compare_lithium_ion.py +++ b/examples/scripts/compare_lithium_ion.py @@ -1,6 +1,8 @@ # # Compare lithium-ion battery models # +from __future__ import annotations + import pybamm pybamm.set_logging_level("INFO") diff --git a/examples/scripts/compare_lithium_ion_2D.py b/examples/scripts/compare_lithium_ion_2D.py index 04568db933..337c4f054d 100644 --- a/examples/scripts/compare_lithium_ion_2D.py +++ b/examples/scripts/compare_lithium_ion_2D.py @@ -1,8 +1,12 @@ # # Compare lithium-ion battery models # +from __future__ import annotations + import argparse + import numpy as np + import pybamm parser = argparse.ArgumentParser() diff --git a/examples/scripts/compare_lithium_ion_half_cell.py b/examples/scripts/compare_lithium_ion_half_cell.py index b6396724f4..ce472440c3 100644 --- a/examples/scripts/compare_lithium_ion_half_cell.py +++ b/examples/scripts/compare_lithium_ion_half_cell.py @@ -1,6 +1,8 @@ # # Compare half-cell lithium-ion battery models # +from __future__ import annotations + import pybamm pybamm.set_logging_level("INFO") diff --git a/examples/scripts/compare_lithium_ion_particle_distribution.py b/examples/scripts/compare_lithium_ion_particle_distribution.py index 906e34416f..bc502f8ea2 100644 --- a/examples/scripts/compare_lithium_ion_particle_distribution.py +++ b/examples/scripts/compare_lithium_ion_particle_distribution.py @@ -1,7 +1,10 @@ # # Compare lithium-ion battery models with and without particle size distibution # +from __future__ import annotations + import numpy as np + import pybamm pybamm.set_logging_level("INFO") diff --git a/examples/scripts/compare_lithium_ion_two_phase.py b/examples/scripts/compare_lithium_ion_two_phase.py index 6b34398e5b..dd22cd450f 100644 --- a/examples/scripts/compare_lithium_ion_two_phase.py +++ b/examples/scripts/compare_lithium_ion_two_phase.py @@ -1,6 +1,8 @@ # # Compare lithium-ion battery models # +from __future__ import annotations + import pybamm pybamm.set_logging_level("INFO") diff --git a/examples/scripts/compare_particle_models.py b/examples/scripts/compare_particle_models.py index 1be5bbdfd9..2abb249ba6 100644 --- a/examples/scripts/compare_particle_models.py +++ b/examples/scripts/compare_particle_models.py @@ -1,6 +1,8 @@ # # Compare models for diffusion within the electrode particles # +from __future__ import annotations + import pybamm # load models diff --git a/examples/scripts/compare_spectral_volume.py b/examples/scripts/compare_spectral_volume.py index 2259bc14d7..0977ebab2a 100644 --- a/examples/scripts/compare_spectral_volume.py +++ b/examples/scripts/compare_spectral_volume.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + pybamm.set_logging_level("INFO") # set order of Spectral Volume method diff --git a/examples/scripts/conservation_lithium.py b/examples/scripts/conservation_lithium.py index fbf931a014..6c173d4b28 100644 --- a/examples/scripts/conservation_lithium.py +++ b/examples/scripts/conservation_lithium.py @@ -1,10 +1,12 @@ # # Check conservation of lithium # +from __future__ import annotations -import pybamm import matplotlib.pyplot as plt +import pybamm + pybamm.set_logging_level("INFO") model = pybamm.lithium_ion.DFN() diff --git a/examples/scripts/create_model.py b/examples/scripts/create_model.py index 25641f9273..fcc52c678b 100644 --- a/examples/scripts/create_model.py +++ b/examples/scripts/create_model.py @@ -1,10 +1,12 @@ # This script is intended to be a stripped back version of the # 'docs/source/examples/notebooks/create-model.ipnb' so for more details please see # that notebook +from __future__ import annotations -import pybamm -import numpy as np import matplotlib.pyplot as plt +import numpy as np + +import pybamm # 1. Initialise model ------------------------------------------------------------------ model = pybamm.BaseModel() diff --git a/examples/scripts/custom_model.py b/examples/scripts/custom_model.py index 4c6dcf3fad..f33ceb8594 100644 --- a/examples/scripts/custom_model.py +++ b/examples/scripts/custom_model.py @@ -1,10 +1,12 @@ # # Example showing how to create a custom lithium-ion model from submodels # +from __future__ import annotations -import pybamm import numpy as np +import pybamm + pybamm.set_logging_level("INFO") # load lithium-ion base model diff --git a/examples/scripts/cycling_ageing.py b/examples/scripts/cycling_ageing.py index 66f23cd900..4f27b9b13d 100644 --- a/examples/scripts/cycling_ageing.py +++ b/examples/scripts/cycling_ageing.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm as pb pb.set_logging_level("NOTICE") diff --git a/examples/scripts/drive_cycle.py b/examples/scripts/drive_cycle.py index 5fbbce2296..bb37233bd1 100644 --- a/examples/scripts/drive_cycle.py +++ b/examples/scripts/drive_cycle.py @@ -1,10 +1,14 @@ # # Simulate drive cycle loaded from csv file # -import pybamm -import pandas as pd +from __future__ import annotations + import os +import pandas as pd + +import pybamm + os.chdir(pybamm.__path__[0] + "/..") pybamm.set_logging_level("INFO") diff --git a/examples/scripts/empirical_hysteresis.py b/examples/scripts/empirical_hysteresis.py index e21d201b4c..262a22c83e 100644 --- a/examples/scripts/empirical_hysteresis.py +++ b/examples/scripts/empirical_hysteresis.py @@ -1,9 +1,12 @@ # # Empirical hysteresis modelling # -import pybamm +from __future__ import annotations + from numpy import array +import pybamm + pybamm.set_logging_level("INFO") # Load model diff --git a/examples/scripts/experiment_drive_cycle.py b/examples/scripts/experiment_drive_cycle.py index e6793b9b20..aad442b6d6 100644 --- a/examples/scripts/experiment_drive_cycle.py +++ b/examples/scripts/experiment_drive_cycle.py @@ -1,10 +1,14 @@ # # Constant-current constant-voltage charge with US06 Drive Cycle using Experiment Class. # -import pybamm -import pandas as pd +from __future__ import annotations + import os +import pandas as pd + +import pybamm + os.chdir(pybamm.__path__[0] + "/..") pybamm.set_logging_level("INFO") diff --git a/examples/scripts/experimental_protocols/cccv.py b/examples/scripts/experimental_protocols/cccv.py index c020588d07..360813df02 100644 --- a/examples/scripts/experimental_protocols/cccv.py +++ b/examples/scripts/experimental_protocols/cccv.py @@ -1,9 +1,12 @@ # # Constant-current constant-voltage charge # -import pybamm +from __future__ import annotations + import matplotlib.pyplot as plt +import pybamm + pybamm.set_logging_level("NOTICE") experiment = pybamm.Experiment( [ diff --git a/examples/scripts/experimental_protocols/gitt.py b/examples/scripts/experimental_protocols/gitt.py index 2b1634cf2c..d3fc73ad01 100644 --- a/examples/scripts/experimental_protocols/gitt.py +++ b/examples/scripts/experimental_protocols/gitt.py @@ -1,6 +1,8 @@ # # GITT discharge # +from __future__ import annotations + import pybamm pybamm.set_logging_level("INFO") diff --git a/examples/scripts/heat_equation.py b/examples/scripts/heat_equation.py index fd01b37f97..667ffbcd96 100644 --- a/examples/scripts/heat_equation.py +++ b/examples/scripts/heat_equation.py @@ -1,10 +1,12 @@ # # Solve the transient heat equation with a spatially-dependent source term # +from __future__ import annotations -import pybamm -import numpy as np import matplotlib.pyplot as plt +import numpy as np + +import pybamm # Numerical solution ---------------------------------------------------------- diff --git a/examples/scripts/minimal_example_of_lookup_tables.py b/examples/scripts/minimal_example_of_lookup_tables.py index 24aba26a44..16476a86bf 100644 --- a/examples/scripts/minimal_example_of_lookup_tables.py +++ b/examples/scripts/minimal_example_of_lookup_tables.py @@ -1,6 +1,9 @@ -import pybamm -import pandas as pd +from __future__ import annotations + import numpy as np +import pandas as pd + +import pybamm def process_2D(name, data): diff --git a/examples/scripts/minimal_interp3d_example.py b/examples/scripts/minimal_interp3d_example.py index c9ef5a2cd5..b45286ba97 100644 --- a/examples/scripts/minimal_interp3d_example.py +++ b/examples/scripts/minimal_interp3d_example.py @@ -1,7 +1,9 @@ +from __future__ import annotations + +import matplotlib.pyplot as plt import numpy as np import pybamm -import matplotlib.pyplot as plt def f(x, y, z): diff --git a/examples/scripts/nca_parameters.py b/examples/scripts/nca_parameters.py index 20b374bc16..2e596c2cfe 100644 --- a/examples/scripts/nca_parameters.py +++ b/examples/scripts/nca_parameters.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm as pb pb.set_logging_level("INFO") diff --git a/examples/scripts/pouch_cell_cooling.py b/examples/scripts/pouch_cell_cooling.py index be35f52420..c4b015b236 100644 --- a/examples/scripts/pouch_cell_cooling.py +++ b/examples/scripts/pouch_cell_cooling.py @@ -1,7 +1,10 @@ # # Example showing how to customize thermal boundary conditions in a pouch cell model # +from __future__ import annotations + import numpy as np + import pybamm pybamm.set_logging_level("INFO") diff --git a/examples/scripts/print_model_parameter_combinations.py b/examples/scripts/print_model_parameter_combinations.py index f7f00714fb..16550240ae 100644 --- a/examples/scripts/print_model_parameter_combinations.py +++ b/examples/scripts/print_model_parameter_combinations.py @@ -2,6 +2,8 @@ # Loop through all combinations of models and parameters and print whether that # model can be parameterized by those parameters # +from __future__ import annotations + import pybamm all_options = pybamm.BatteryModelOptions({}).possible_options diff --git a/examples/scripts/print_parameters.py b/examples/scripts/print_parameters.py index f1e19817cf..46efdf8e4d 100644 --- a/examples/scripts/print_parameters.py +++ b/examples/scripts/print_parameters.py @@ -1,6 +1,8 @@ # # Example for printing the parameters of a parameter set # +from __future__ import annotations + import pybamm parameters = pybamm.LithiumIonParameters() diff --git a/examples/scripts/rate_capability.py b/examples/scripts/rate_capability.py index 0ce5be4263..cc411fc9bc 100644 --- a/examples/scripts/rate_capability.py +++ b/examples/scripts/rate_capability.py @@ -1,6 +1,9 @@ -import pybamm -import numpy as np +from __future__ import annotations + import matplotlib.pyplot as plt +import numpy as np + +import pybamm pybamm.set_logging_level("INFO") diff --git a/examples/scripts/run_ecm.py b/examples/scripts/run_ecm.py index 4f15727865..3b306eb60a 100644 --- a/examples/scripts/run_ecm.py +++ b/examples/scripts/run_ecm.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm pybamm.set_logging_level("INFO") diff --git a/examples/scripts/run_simulation.py b/examples/scripts/run_simulation.py index 4cfdb24deb..50a4510ad5 100644 --- a/examples/scripts/run_simulation.py +++ b/examples/scripts/run_simulation.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm model = pybamm.lithium_ion.SPM() diff --git a/examples/scripts/thermal_lithium_ion.py b/examples/scripts/thermal_lithium_ion.py index c6aa978c99..d758ec73e1 100644 --- a/examples/scripts/thermal_lithium_ion.py +++ b/examples/scripts/thermal_lithium_ion.py @@ -1,6 +1,8 @@ # # Compares the full and lumped thermal models for a single layer Li-ion cell # +from __future__ import annotations + import pybamm pybamm.set_logging_level("INFO") diff --git a/noxfile.py b/noxfile.py index 4e6f1df01b..c35758699d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,8 +1,10 @@ -import nox +from __future__ import annotations + import os import sys from pathlib import Path +import nox # Options to modify nox behaviour nox.options.reuse_existing_virtualenvs = True diff --git a/pybamm/batch_study.py b/pybamm/batch_study.py index 1503c3048c..0411c0724f 100644 --- a/pybamm/batch_study.py +++ b/pybamm/batch_study.py @@ -1,9 +1,12 @@ # # BatchStudy class # -import pybamm +from __future__ import annotations + from itertools import product +import pybamm + class BatchStudy: """ diff --git a/pybamm/callbacks.py b/pybamm/callbacks.py index 32607bb716..8f961fd1be 100644 --- a/pybamm/callbacks.py +++ b/pybamm/callbacks.py @@ -5,10 +5,14 @@ # Inspired by Keras callbacks # https://github.com/keras-team/keras/blob/master/keras/callbacks/callback.py # -import pybamm -import numpy as np +from __future__ import annotations + import inspect +import numpy as np + +import pybamm + def setup_callbacks(callbacks): callbacks = callbacks or [] diff --git a/pybamm/citations.py b/pybamm/citations.py index da371bbd84..d42534d724 100644 --- a/pybamm/citations.py +++ b/pybamm/citations.py @@ -3,10 +3,13 @@ # Inspired by firedrake/PETSc citation workflow # https://firedrakeproject.org/citing.html # -import pybamm +from __future__ import annotations + import os import warnings from sys import _getframe + +import pybamm from pybamm.util import have_optional_dependency diff --git a/pybamm/discretisations/discretisation.py b/pybamm/discretisations/discretisation.py index 7be3b2bc53..1575d072de 100644 --- a/pybamm/discretisations/discretisation.py +++ b/pybamm/discretisations/discretisation.py @@ -1,12 +1,16 @@ # # Interface for discretisation # -import pybamm +from __future__ import annotations + +from collections import OrderedDict, defaultdict + import numpy as np -from collections import defaultdict, OrderedDict from scipy.sparse import block_diag, csc_matrix, csr_matrix from scipy.sparse.linalg import inv +import pybamm + def has_bc_of_form(symbol, side, bcs, form): if symbol in bcs: diff --git a/pybamm/doc_utils.py b/pybamm/doc_utils.py index 0e53579c43..da92d58ce9 100644 --- a/pybamm/doc_utils.py +++ b/pybamm/doc_utils.py @@ -1,6 +1,8 @@ # # Documentation utilities for actions on PyBaMM classes # +from __future__ import annotations + from inspect import getmro diff --git a/pybamm/experiment/experiment.py b/pybamm/experiment/experiment.py index a2a40981f3..6a281638aa 100644 --- a/pybamm/experiment/experiment.py +++ b/pybamm/experiment/experiment.py @@ -1,8 +1,10 @@ from __future__ import annotations + import pybamm + from .step._steps_util import ( - _convert_time_to_seconds, _convert_temperature_to_kelvin, + _convert_time_to_seconds, ) diff --git a/pybamm/experiment/step/_steps_util.py b/pybamm/experiment/step/_steps_util.py index 6bf137ed1b..460588d30e 100644 --- a/pybamm/experiment/step/_steps_util.py +++ b/pybamm/experiment/step/_steps_util.py @@ -1,9 +1,14 @@ # # Private classes and functions for experiment steps # -import pybamm -import numpy as np +from __future__ import annotations + from datetime import datetime + +import numpy as np + +import pybamm + from .step_termination import _read_termination _examples = """ diff --git a/pybamm/experiment/step/step_termination.py b/pybamm/experiment/step/step_termination.py index 082711a305..ceeb3486b7 100644 --- a/pybamm/experiment/step/step_termination.py +++ b/pybamm/experiment/step/step_termination.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + class BaseTermination: """ diff --git a/pybamm/experiment/step/steps.py b/pybamm/experiment/step/steps.py index 2f2e9e31a4..a4501f8869 100644 --- a/pybamm/experiment/step/steps.py +++ b/pybamm/experiment/step/steps.py @@ -1,7 +1,9 @@ # # Public functions to create steps for use in an experiment. # -from ._steps_util import _Step, _convert_electric, _examples +from __future__ import annotations + +from ._steps_util import _convert_electric, _examples, _Step def string(string, **kwargs): diff --git a/pybamm/expression_tree/array.py b/pybamm/expression_tree/array.py index 0bb6168a7c..ad9f9f5d5b 100644 --- a/pybamm/expression_tree/array.py +++ b/pybamm/expression_tree/array.py @@ -2,13 +2,15 @@ # NumpyArray class # from __future__ import annotations + +from typing import TYPE_CHECKING + import numpy as np from scipy.sparse import csr_matrix, issparse -from typing import TYPE_CHECKING import pybamm +from pybamm.type_definitions import AuxiliaryDomainType, DomainsType, DomainType from pybamm.util import have_optional_dependency -from pybamm.type_definitions import DomainType, AuxiliaryDomainType, DomainsType if TYPE_CHECKING: # pragma: no cover import sympy diff --git a/pybamm/expression_tree/averages.py b/pybamm/expression_tree/averages.py index d612906b71..d6f362680c 100644 --- a/pybamm/expression_tree/averages.py +++ b/pybamm/expression_tree/averages.py @@ -2,7 +2,9 @@ # Classes and methods for averaging # from __future__ import annotations + from typing import Callable + import pybamm diff --git a/pybamm/expression_tree/binary_operators.py b/pybamm/expression_tree/binary_operators.py index d10844798b..d682a7d097 100644 --- a/pybamm/expression_tree/binary_operators.py +++ b/pybamm/expression_tree/binary_operators.py @@ -2,19 +2,19 @@ # Binary operator classes # from __future__ import annotations + +import functools import numbers +from typing import Callable, cast import numpy as np from scipy.sparse import csr_matrix, issparse -import functools import pybamm -from pybamm.util import have_optional_dependency - -from typing import Callable, cast # create type alias(s) from pybamm.type_definitions import ChildSymbol, ChildValue, Numeric +from pybamm.util import have_optional_dependency def _preprocess_binary( @@ -34,7 +34,7 @@ def _preprocess_binary( right = pybamm.Vector(right) # Check both left and right are pybamm Symbols - if not (isinstance(left, pybamm.Symbol) and isinstance(right, pybamm.Symbol)): + if not (isinstance(left, pybamm.Symbol) and isinstance(right, pybamm.Symbol)): # type: ignore[redundant-expr] raise NotImplementedError( """BinaryOperator not implemented for symbols of type {} and {}""".format( type(left), type(right) diff --git a/pybamm/expression_tree/broadcasts.py b/pybamm/expression_tree/broadcasts.py index e17f375102..5fe66d4fec 100644 --- a/pybamm/expression_tree/broadcasts.py +++ b/pybamm/expression_tree/broadcasts.py @@ -3,15 +3,16 @@ # from __future__ import annotations +from typing import cast + import numpy as np from scipy.sparse import csr_matrix -from typing import cast import pybamm from pybamm.type_definitions import ( - DomainType, AuxiliaryDomainType, DomainsType, + DomainType, Numeric, ) diff --git a/pybamm/expression_tree/concatenations.py b/pybamm/expression_tree/concatenations.py index 06718c311d..33a940a516 100644 --- a/pybamm/expression_tree/concatenations.py +++ b/pybamm/expression_tree/concatenations.py @@ -2,12 +2,13 @@ # Concatenation classes # from __future__ import annotations + import copy from collections import defaultdict +from typing import Sequence import numpy as np from scipy.sparse import issparse, vstack -from typing import Sequence import pybamm from pybamm.util import have_optional_dependency diff --git a/pybamm/expression_tree/exceptions.py b/pybamm/expression_tree/exceptions.py index 6a3b244beb..47cddfa855 100644 --- a/pybamm/expression_tree/exceptions.py +++ b/pybamm/expression_tree/exceptions.py @@ -1,6 +1,7 @@ # # Exception classes # +from __future__ import annotations class DomainError(Exception): diff --git a/pybamm/expression_tree/functions.py b/pybamm/expression_tree/functions.py index 72c9d4074a..6fcdc45d3a 100644 --- a/pybamm/expression_tree/functions.py +++ b/pybamm/expression_tree/functions.py @@ -3,9 +3,10 @@ # from __future__ import annotations +from typing import Callable, Sequence + import numpy as np from scipy import special -from typing import Sequence, Callable from typing_extensions import TypeVar import pybamm diff --git a/pybamm/expression_tree/independent_variable.py b/pybamm/expression_tree/independent_variable.py index 0dca6dba46..695b4e3e23 100644 --- a/pybamm/expression_tree/independent_variable.py +++ b/pybamm/expression_tree/independent_variable.py @@ -2,12 +2,13 @@ # IndependentVariable class # from __future__ import annotations -import sympy + import numpy as np +import sympy import pybamm +from pybamm.type_definitions import AuxiliaryDomainType, DomainsType, DomainType from pybamm.util import have_optional_dependency -from pybamm.type_definitions import DomainType, AuxiliaryDomainType, DomainsType KNOWN_COORD_SYS = ["cartesian", "cylindrical polar", "spherical polar"] diff --git a/pybamm/expression_tree/input_parameter.py b/pybamm/expression_tree/input_parameter.py index a1ee00a47b..ee865a3a5d 100644 --- a/pybamm/expression_tree/input_parameter.py +++ b/pybamm/expression_tree/input_parameter.py @@ -2,11 +2,13 @@ # Parameter classes # from __future__ import annotations + import numbers + import numpy as np import scipy.sparse -import pybamm +import pybamm from pybamm.type_definitions import DomainType diff --git a/pybamm/expression_tree/interpolant.py b/pybamm/expression_tree/interpolant.py index 7d0b0c6eb2..e7b2eed8e4 100644 --- a/pybamm/expression_tree/interpolant.py +++ b/pybamm/expression_tree/interpolant.py @@ -2,10 +2,11 @@ # Interpolating class # from __future__ import annotations -import numpy as np -from scipy import interpolate + from typing import Sequence +import numpy as np +from scipy import interpolate import pybamm diff --git a/pybamm/expression_tree/matrix.py b/pybamm/expression_tree/matrix.py index 435d06d84f..4e36d6346a 100644 --- a/pybamm/expression_tree/matrix.py +++ b/pybamm/expression_tree/matrix.py @@ -2,11 +2,12 @@ # Matrix class # from __future__ import annotations + import numpy as np from scipy.sparse import csr_matrix, issparse import pybamm -from pybamm.type_definitions import DomainType, AuxiliaryDomainType, DomainsType +from pybamm.type_definitions import AuxiliaryDomainType, DomainsType, DomainType class Matrix(pybamm.Array): diff --git a/pybamm/expression_tree/operations/convert_to_casadi.py b/pybamm/expression_tree/operations/convert_to_casadi.py index 084b587721..bd0cecf56f 100644 --- a/pybamm/expression_tree/operations/convert_to_casadi.py +++ b/pybamm/expression_tree/operations/convert_to_casadi.py @@ -3,11 +3,12 @@ # from __future__ import annotations -import pybamm import casadi import numpy as np from scipy import special +import pybamm + class CasadiConverter: def __init__(self, casadi_symbols=None): diff --git a/pybamm/expression_tree/operations/evaluate_python.py b/pybamm/expression_tree/operations/evaluate_python.py index 3582db13aa..ecb2e314c3 100644 --- a/pybamm/expression_tree/operations/evaluate_python.py +++ b/pybamm/expression_tree/operations/evaluate_python.py @@ -2,12 +2,13 @@ # Write a symbol to python # from __future__ import annotations + import numbers from collections import OrderedDict -from numpy.typing import ArrayLike import numpy as np import scipy.sparse +from numpy.typing import ArrayLike import pybamm diff --git a/pybamm/expression_tree/operations/jacobian.py b/pybamm/expression_tree/operations/jacobian.py index 6348e1fdc0..91997a41e9 100644 --- a/pybamm/expression_tree/operations/jacobian.py +++ b/pybamm/expression_tree/operations/jacobian.py @@ -2,6 +2,7 @@ # Calculate the Jacobian of a symbol # from __future__ import annotations + import pybamm diff --git a/pybamm/expression_tree/operations/serialise.py b/pybamm/expression_tree/operations/serialise.py index 0507b3304e..4cf5b29c7a 100644 --- a/pybamm/expression_tree/operations/serialise.py +++ b/pybamm/expression_tree/operations/serialise.py @@ -1,11 +1,13 @@ from __future__ import annotations -import pybamm -from datetime import datetime -import json import importlib -import numpy as np +import json import re +from datetime import datetime + +import numpy as np + +import pybamm class Serialise: diff --git a/pybamm/expression_tree/operations/unpack_symbols.py b/pybamm/expression_tree/operations/unpack_symbols.py index 1933eada76..435b5dab39 100644 --- a/pybamm/expression_tree/operations/unpack_symbols.py +++ b/pybamm/expression_tree/operations/unpack_symbols.py @@ -2,6 +2,7 @@ # Helper function to unpack a symbol # from __future__ import annotations + from typing import TYPE_CHECKING, Sequence if TYPE_CHECKING: # pragma: no cover diff --git a/pybamm/expression_tree/parameter.py b/pybamm/expression_tree/parameter.py index e646ff234d..13c0800067 100644 --- a/pybamm/expression_tree/parameter.py +++ b/pybamm/expression_tree/parameter.py @@ -2,10 +2,11 @@ # Parameter classes # from __future__ import annotations + import sys +from typing import TYPE_CHECKING, Literal import numpy as np -from typing import TYPE_CHECKING, Literal if TYPE_CHECKING: # pragma: no cover import sympy diff --git a/pybamm/expression_tree/printing/print_name.py b/pybamm/expression_tree/printing/print_name.py index 428984d42c..8337e62561 100644 --- a/pybamm/expression_tree/printing/print_name.py +++ b/pybamm/expression_tree/printing/print_name.py @@ -1,6 +1,8 @@ # # Prettify print_name # +from __future__ import annotations + PRINT_NAME_OVERRIDES = { "current_with_time": "I", "current_density_with_time": r"i_{\mathrm{cell}}", diff --git a/pybamm/expression_tree/printing/sympy_overrides.py b/pybamm/expression_tree/printing/sympy_overrides.py index 58ac356399..a9a2468eaa 100644 --- a/pybamm/expression_tree/printing/sympy_overrides.py +++ b/pybamm/expression_tree/printing/sympy_overrides.py @@ -1,6 +1,8 @@ # # SymPy overrides # +from __future__ import annotations + import re from sympy.printing.latex import LatexPrinter diff --git a/pybamm/expression_tree/scalar.py b/pybamm/expression_tree/scalar.py index 26bbabfcf0..bfd37b51fe 100644 --- a/pybamm/expression_tree/scalar.py +++ b/pybamm/expression_tree/scalar.py @@ -2,12 +2,14 @@ # Scalar class # from __future__ import annotations -import numpy as np + from typing import Literal +import numpy as np + import pybamm -from pybamm.util import have_optional_dependency from pybamm.type_definitions import Numeric +from pybamm.util import have_optional_dependency class Scalar(pybamm.Symbol): diff --git a/pybamm/expression_tree/state_vector.py b/pybamm/expression_tree/state_vector.py index f52b41a99c..516bc8ed2a 100644 --- a/pybamm/expression_tree/state_vector.py +++ b/pybamm/expression_tree/state_vector.py @@ -2,11 +2,12 @@ # State Vector class # from __future__ import annotations + import numpy as np from scipy.sparse import csr_matrix, vstack import pybamm -from pybamm.type_definitions import DomainType, AuxiliaryDomainType, DomainsType +from pybamm.type_definitions import AuxiliaryDomainType, DomainsType, DomainType class StateVectorBase(pybamm.Symbol): diff --git a/pybamm/expression_tree/symbol.py b/pybamm/expression_tree/symbol.py index 70f4e82db6..2860faa78a 100644 --- a/pybamm/expression_tree/symbol.py +++ b/pybamm/expression_tree/symbol.py @@ -2,25 +2,27 @@ # Base Symbol Class for the expression tree # from __future__ import annotations + import numbers +from functools import cached_property, lru_cache +from typing import TYPE_CHECKING, Sequence, cast import numpy as np from scipy.sparse import csr_matrix, issparse -from functools import lru_cache, cached_property -from typing import TYPE_CHECKING, Sequence, cast import pybamm -from pybamm.util import have_optional_dependency from pybamm.expression_tree.printing.print_name import prettify_print_name +from pybamm.util import have_optional_dependency if TYPE_CHECKING: # pragma: no cover import casadi + from pybamm.type_definitions import ( + AuxiliaryDomainType, ChildSymbol, ChildValue, - DomainType, - AuxiliaryDomainType, DomainsType, + DomainType, ) DOMAIN_LEVELS = ["primary", "secondary", "tertiary", "quaternary"] diff --git a/pybamm/expression_tree/unary_operators.py b/pybamm/expression_tree/unary_operators.py index 319499a9fc..46eb0b34ef 100644 --- a/pybamm/expression_tree/unary_operators.py +++ b/pybamm/expression_tree/unary_operators.py @@ -5,9 +5,10 @@ import numpy as np from scipy.sparse import csr_matrix, issparse + import pybamm -from pybamm.util import have_optional_dependency from pybamm.type_definitions import DomainsType +from pybamm.util import have_optional_dependency class UnaryOperator(pybamm.Symbol): diff --git a/pybamm/expression_tree/variable.py b/pybamm/expression_tree/variable.py index eb0d90cdb6..09584876e2 100644 --- a/pybamm/expression_tree/variable.py +++ b/pybamm/expression_tree/variable.py @@ -2,16 +2,19 @@ # Variable class # from __future__ import annotations -import numpy as np + import numbers + +import numpy as np + import pybamm -from pybamm.util import have_optional_dependency from pybamm.type_definitions import ( - DomainType, AuxiliaryDomainType, DomainsType, + DomainType, Numeric, ) +from pybamm.util import have_optional_dependency class VariableBase(pybamm.Symbol): diff --git a/pybamm/expression_tree/vector.py b/pybamm/expression_tree/vector.py index a1d8052c94..ce0aa492d3 100644 --- a/pybamm/expression_tree/vector.py +++ b/pybamm/expression_tree/vector.py @@ -2,10 +2,11 @@ # Vector class # from __future__ import annotations + import numpy as np import pybamm -from pybamm.type_definitions import DomainType, AuxiliaryDomainType, DomainsType +from pybamm.type_definitions import AuxiliaryDomainType, DomainsType, DomainType class Vector(pybamm.Array): diff --git a/pybamm/geometry/battery_geometry.py b/pybamm/geometry/battery_geometry.py index e15c358128..11ee864fe8 100644 --- a/pybamm/geometry/battery_geometry.py +++ b/pybamm/geometry/battery_geometry.py @@ -1,6 +1,8 @@ # # Function to create battery geometries # +from __future__ import annotations + import pybamm diff --git a/pybamm/geometry/geometry.py b/pybamm/geometry/geometry.py index 5ace6a9ae5..04147a6b91 100644 --- a/pybamm/geometry/geometry.py +++ b/pybamm/geometry/geometry.py @@ -1,9 +1,12 @@ # # Geometry class for storing the geometry of the model # -import pybamm +from __future__ import annotations + import numbers +import pybamm + class Geometry(dict): """ diff --git a/pybamm/geometry/standard_spatial_vars.py b/pybamm/geometry/standard_spatial_vars.py index 565908deb9..791e0b3b32 100644 --- a/pybamm/geometry/standard_spatial_vars.py +++ b/pybamm/geometry/standard_spatial_vars.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm whole_cell = ["negative electrode", "separator", "positive electrode"] diff --git a/pybamm/input/parameters/ecm/example_set.py b/pybamm/input/parameters/ecm/example_set.py index 1348ba7d22..d2ad4d8f9a 100644 --- a/pybamm/input/parameters/ecm/example_set.py +++ b/pybamm/input/parameters/ecm/example_set.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import os +import pybamm + # An example set of parameters for the equivalent circuit model path, _ = os.path.split(os.path.abspath(__file__)) diff --git a/pybamm/input/parameters/lead_acid/Sulzer2019.py b/pybamm/input/parameters/lead_acid/Sulzer2019.py index 864eef6749..0e2c4aa8e2 100644 --- a/pybamm/input/parameters/lead_acid/Sulzer2019.py +++ b/pybamm/input/parameters/lead_acid/Sulzer2019.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + def lead_ocp_Bode1977(m): """ diff --git a/pybamm/input/parameters/lithium_ion/Ai2020.py b/pybamm/input/parameters/lithium_ion/Ai2020.py index 2bf1eeecdd..100164a711 100644 --- a/pybamm/input/parameters/lithium_ion/Ai2020.py +++ b/pybamm/input/parameters/lithium_ion/Ai2020.py @@ -1,7 +1,11 @@ -import pybamm +from __future__ import annotations + import os + import numpy as np +import pybamm + def graphite_diffusivity_Dualfoil1998(sto, T): """ diff --git a/pybamm/input/parameters/lithium_ion/Chen2020.py b/pybamm/input/parameters/lithium_ion/Chen2020.py index 5a7460871b..4a1f4aa258 100644 --- a/pybamm/input/parameters/lithium_ion/Chen2020.py +++ b/pybamm/input/parameters/lithium_ion/Chen2020.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + def graphite_LGM50_ocp_Chen2020(sto): """ diff --git a/pybamm/input/parameters/lithium_ion/Chen2020_composite.py b/pybamm/input/parameters/lithium_ion/Chen2020_composite.py index 58b6211072..06931b258b 100644 --- a/pybamm/input/parameters/lithium_ion/Chen2020_composite.py +++ b/pybamm/input/parameters/lithium_ion/Chen2020_composite.py @@ -1,7 +1,11 @@ -import pybamm +from __future__ import annotations + import os + import numpy as np +import pybamm + def graphite_LGM50_electrolyte_exchange_current_density_Chen2020( c_e, c_s_surf, c_s_max, T diff --git a/pybamm/input/parameters/lithium_ion/Ecker2015.py b/pybamm/input/parameters/lithium_ion/Ecker2015.py index fa9fd2dcad..78168b1f17 100644 --- a/pybamm/input/parameters/lithium_ion/Ecker2015.py +++ b/pybamm/input/parameters/lithium_ion/Ecker2015.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + def graphite_diffusivity_Ecker2015(sto, T): """ diff --git a/pybamm/input/parameters/lithium_ion/Ecker2015_graphite_halfcell.py b/pybamm/input/parameters/lithium_ion/Ecker2015_graphite_halfcell.py index d878ff7400..76af4eb4b4 100644 --- a/pybamm/input/parameters/lithium_ion/Ecker2015_graphite_halfcell.py +++ b/pybamm/input/parameters/lithium_ion/Ecker2015_graphite_halfcell.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm diff --git a/pybamm/input/parameters/lithium_ion/MSMR_example_set.py b/pybamm/input/parameters/lithium_ion/MSMR_example_set.py index 55033431bd..f7cba55469 100644 --- a/pybamm/input/parameters/lithium_ion/MSMR_example_set.py +++ b/pybamm/input/parameters/lithium_ion/MSMR_example_set.py @@ -1,3 +1,6 @@ +from __future__ import annotations + + def electrolyte_diffusivity_Nyman2008(c_e, T): """ Diffusivity of LiPF6 in EC:EMC (3:7) as a function of ion concentration. The data diff --git a/pybamm/input/parameters/lithium_ion/Marquis2019.py b/pybamm/input/parameters/lithium_ion/Marquis2019.py index b1f63e6ff7..72513e2dab 100644 --- a/pybamm/input/parameters/lithium_ion/Marquis2019.py +++ b/pybamm/input/parameters/lithium_ion/Marquis2019.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + def graphite_mcmb2528_diffusivity_Dualfoil1998(sto, T): """ diff --git a/pybamm/input/parameters/lithium_ion/Mohtat2020.py b/pybamm/input/parameters/lithium_ion/Mohtat2020.py index 9923d9d308..864c0a0062 100644 --- a/pybamm/input/parameters/lithium_ion/Mohtat2020.py +++ b/pybamm/input/parameters/lithium_ion/Mohtat2020.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + def graphite_diffusivity_PeymanMPM(sto, T): """ diff --git a/pybamm/input/parameters/lithium_ion/NCA_Kim2011.py b/pybamm/input/parameters/lithium_ion/NCA_Kim2011.py index 7d0478b6d0..4c5dafc8dd 100644 --- a/pybamm/input/parameters/lithium_ion/NCA_Kim2011.py +++ b/pybamm/input/parameters/lithium_ion/NCA_Kim2011.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + def graphite_diffusivity_Kim2011(sto, T): """ diff --git a/pybamm/input/parameters/lithium_ion/OKane2022.py b/pybamm/input/parameters/lithium_ion/OKane2022.py index d3e43c1e90..13e945a337 100644 --- a/pybamm/input/parameters/lithium_ion/OKane2022.py +++ b/pybamm/input/parameters/lithium_ion/OKane2022.py @@ -1,7 +1,11 @@ -import pybamm +from __future__ import annotations + import os + import numpy as np +import pybamm + def plating_exchange_current_density_OKane2020(c_e, c_Li, T): """ diff --git a/pybamm/input/parameters/lithium_ion/OKane2022_graphite_SiOx_halfcell.py b/pybamm/input/parameters/lithium_ion/OKane2022_graphite_SiOx_halfcell.py index fe9d444874..ee43297fac 100644 --- a/pybamm/input/parameters/lithium_ion/OKane2022_graphite_SiOx_halfcell.py +++ b/pybamm/input/parameters/lithium_ion/OKane2022_graphite_SiOx_halfcell.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import os +import pybamm + def li_metal_electrolyte_exchange_current_density_Xu2019(c_e, c_Li, T): """ diff --git a/pybamm/input/parameters/lithium_ion/ORegan2022.py b/pybamm/input/parameters/lithium_ion/ORegan2022.py index 3ca5f6824c..15997eb681 100644 --- a/pybamm/input/parameters/lithium_ion/ORegan2022.py +++ b/pybamm/input/parameters/lithium_ion/ORegan2022.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + def electrolyte_conductivity_base_Landesfeind2019(c_e, T, coeffs): """ diff --git a/pybamm/input/parameters/lithium_ion/Prada2013.py b/pybamm/input/parameters/lithium_ion/Prada2013.py index 0ba56516ab..0dd40e9dfb 100644 --- a/pybamm/input/parameters/lithium_ion/Prada2013.py +++ b/pybamm/input/parameters/lithium_ion/Prada2013.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + def graphite_LGM50_ocp_Chen2020(sto): """ diff --git a/pybamm/input/parameters/lithium_ion/Ramadass2004.py b/pybamm/input/parameters/lithium_ion/Ramadass2004.py index 879a5f55c6..1482585618 100644 --- a/pybamm/input/parameters/lithium_ion/Ramadass2004.py +++ b/pybamm/input/parameters/lithium_ion/Ramadass2004.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + def graphite_mcmb2528_diffusivity_Dualfoil1998(sto, T): """ diff --git a/pybamm/input/parameters/lithium_ion/Xu2019.py b/pybamm/input/parameters/lithium_ion/Xu2019.py index edf3bd40b0..853eda280c 100644 --- a/pybamm/input/parameters/lithium_ion/Xu2019.py +++ b/pybamm/input/parameters/lithium_ion/Xu2019.py @@ -1,6 +1,9 @@ -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + def li_metal_electrolyte_exchange_current_density_Xu2019(c_e, c_Li, T): """ diff --git a/pybamm/install_odes.py b/pybamm/install_odes.py index a69037fb62..56789713f5 100644 --- a/pybamm/install_odes.py +++ b/pybamm/install_odes.py @@ -1,11 +1,13 @@ -import os -import tarfile -from os.path import join, isfile +from __future__ import annotations + import argparse -import sys import logging +import os import subprocess +import sys +import tarfile from multiprocessing import cpu_count +from os.path import isfile, join from pybamm.util import root_dir diff --git a/pybamm/logger.py b/pybamm/logger.py index 5e96d5a010..abe104ddec 100644 --- a/pybamm/logger.py +++ b/pybamm/logger.py @@ -6,6 +6,8 @@ # Implementation from stackoverflow # https://stackoverflow.com/questions/2183233/how-to-add-a-custom-loglevel-to-pythons-logging-facility # +from __future__ import annotations + import logging diff --git a/pybamm/meshes/meshes.py b/pybamm/meshes/meshes.py index 7fdcd0eede..d10b18600b 100644 --- a/pybamm/meshes/meshes.py +++ b/pybamm/meshes/meshes.py @@ -1,8 +1,12 @@ # # Native PyBaMM Meshes # +from __future__ import annotations + import numbers + import numpy as np + import pybamm diff --git a/pybamm/meshes/one_dimensional_submeshes.py b/pybamm/meshes/one_dimensional_submeshes.py index d6c3c7f78e..cabfcf79ac 100644 --- a/pybamm/meshes/one_dimensional_submeshes.py +++ b/pybamm/meshes/one_dimensional_submeshes.py @@ -1,11 +1,14 @@ # # One-dimensional submeshes # -import pybamm -from .meshes import SubMesh +from __future__ import annotations import numpy as np +import pybamm + +from .meshes import SubMesh + class SubMesh1D(SubMesh): """ diff --git a/pybamm/meshes/scikit_fem_submeshes.py b/pybamm/meshes/scikit_fem_submeshes.py index 82a7bd72f1..1fc4ffcbd1 100644 --- a/pybamm/meshes/scikit_fem_submeshes.py +++ b/pybamm/meshes/scikit_fem_submeshes.py @@ -1,12 +1,15 @@ # # scikit-fem meshes for use in PyBaMM # -import pybamm -from .meshes import SubMesh +from __future__ import annotations + import numpy as np +import pybamm from pybamm.util import have_optional_dependency +from .meshes import SubMesh + class ScikitSubMesh2D(SubMesh): """ diff --git a/pybamm/meshes/zero_dimensional_submesh.py b/pybamm/meshes/zero_dimensional_submesh.py index 70ec3d7b69..1f27ee0fed 100644 --- a/pybamm/meshes/zero_dimensional_submesh.py +++ b/pybamm/meshes/zero_dimensional_submesh.py @@ -1,11 +1,14 @@ # # Zero dimensional submesh # -import pybamm -from .meshes import SubMesh +from __future__ import annotations import numpy as np +import pybamm + +from .meshes import SubMesh + class SubMesh0D(SubMesh): """ diff --git a/pybamm/models/base_model.py b/pybamm/models/base_model.py index b6b5a9b2da..3b7c8e26f6 100644 --- a/pybamm/models/base_model.py +++ b/pybamm/models/base_model.py @@ -3,11 +3,11 @@ # from __future__ import annotations +import copy import numbers import warnings from collections import OrderedDict -import copy import casadi import numpy as np diff --git a/pybamm/models/event.py b/pybamm/models/event.py index 8d2695160e..22a669734b 100644 --- a/pybamm/models/event.py +++ b/pybamm/models/event.py @@ -1,10 +1,10 @@ from __future__ import annotations from enum import Enum -import numpy as np - from typing import TypeVar +import numpy as np + class EventType(Enum): """ diff --git a/pybamm/models/full_battery_models/base_battery_model.py b/pybamm/models/full_battery_models/base_battery_model.py index 1ac618ddde..fd20d5b46f 100644 --- a/pybamm/models/full_battery_models/base_battery_model.py +++ b/pybamm/models/full_battery_models/base_battery_model.py @@ -1,10 +1,11 @@ # # Base battery model class # +from __future__ import annotations -import pybamm from functools import cached_property +import pybamm from pybamm.expression_tree.operations.serialise import Serialise diff --git a/pybamm/models/full_battery_models/equivalent_circuit/ecm_model_options.py b/pybamm/models/full_battery_models/equivalent_circuit/ecm_model_options.py index d9bbe0401a..b093dfdb36 100644 --- a/pybamm/models/full_battery_models/equivalent_circuit/ecm_model_options.py +++ b/pybamm/models/full_battery_models/equivalent_circuit/ecm_model_options.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import types diff --git a/pybamm/models/full_battery_models/equivalent_circuit/thevenin.py b/pybamm/models/full_battery_models/equivalent_circuit/thevenin.py index 9d01f89ffd..7950cb9782 100644 --- a/pybamm/models/full_battery_models/equivalent_circuit/thevenin.py +++ b/pybamm/models/full_battery_models/equivalent_circuit/thevenin.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm from .ecm_model_options import NaturalNumberOption, OperatingModes diff --git a/pybamm/models/full_battery_models/lead_acid/base_lead_acid_model.py b/pybamm/models/full_battery_models/lead_acid/base_lead_acid_model.py index c0b5d1935c..a81f8a35e2 100644 --- a/pybamm/models/full_battery_models/lead_acid/base_lead_acid_model.py +++ b/pybamm/models/full_battery_models/lead_acid/base_lead_acid_model.py @@ -1,6 +1,7 @@ # # Lead acid base model class # +from __future__ import annotations import pybamm diff --git a/pybamm/models/full_battery_models/lead_acid/basic_full.py b/pybamm/models/full_battery_models/lead_acid/basic_full.py index 8caac98066..11607d89e2 100644 --- a/pybamm/models/full_battery_models/lead_acid/basic_full.py +++ b/pybamm/models/full_battery_models/lead_acid/basic_full.py @@ -1,7 +1,10 @@ # # Basic lead-acid model # +from __future__ import annotations + import pybamm + from .base_lead_acid_model import BaseModel diff --git a/pybamm/models/full_battery_models/lead_acid/full.py b/pybamm/models/full_battery_models/lead_acid/full.py index 927f9a2028..24dad13bea 100644 --- a/pybamm/models/full_battery_models/lead_acid/full.py +++ b/pybamm/models/full_battery_models/lead_acid/full.py @@ -1,7 +1,10 @@ # # Lead-acid Full model # +from __future__ import annotations + import pybamm + from .base_lead_acid_model import BaseModel diff --git a/pybamm/models/full_battery_models/lead_acid/loqs.py b/pybamm/models/full_battery_models/lead_acid/loqs.py index 953be55c9c..30d794a48a 100644 --- a/pybamm/models/full_battery_models/lead_acid/loqs.py +++ b/pybamm/models/full_battery_models/lead_acid/loqs.py @@ -1,7 +1,10 @@ # # Lead-acid LOQS model # +from __future__ import annotations + import pybamm + from .base_lead_acid_model import BaseModel diff --git a/pybamm/models/full_battery_models/lithium_ion/Yang2017.py b/pybamm/models/full_battery_models/lithium_ion/Yang2017.py index 01c17b22f7..cfdeb02a91 100644 --- a/pybamm/models/full_battery_models/lithium_ion/Yang2017.py +++ b/pybamm/models/full_battery_models/lithium_ion/Yang2017.py @@ -1,4 +1,7 @@ +from __future__ import annotations + import pybamm + from .dfn import DFN diff --git a/pybamm/models/full_battery_models/lithium_ion/base_lithium_ion_model.py b/pybamm/models/full_battery_models/lithium_ion/base_lithium_ion_model.py index fbe19b0d42..99c75cf999 100644 --- a/pybamm/models/full_battery_models/lithium_ion/base_lithium_ion_model.py +++ b/pybamm/models/full_battery_models/lithium_ion/base_lithium_ion_model.py @@ -1,6 +1,8 @@ # # Lithium-ion base model class # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/full_battery_models/lithium_ion/basic_dfn.py b/pybamm/models/full_battery_models/lithium_ion/basic_dfn.py index 5b38926699..70b34f23a7 100644 --- a/pybamm/models/full_battery_models/lithium_ion/basic_dfn.py +++ b/pybamm/models/full_battery_models/lithium_ion/basic_dfn.py @@ -1,7 +1,10 @@ # # Basic Doyle-Fuller-Newman (DFN) Model # +from __future__ import annotations + import pybamm + from .base_lithium_ion_model import BaseModel diff --git a/pybamm/models/full_battery_models/lithium_ion/basic_dfn_composite.py b/pybamm/models/full_battery_models/lithium_ion/basic_dfn_composite.py index 76889d28ea..1daa4106da 100644 --- a/pybamm/models/full_battery_models/lithium_ion/basic_dfn_composite.py +++ b/pybamm/models/full_battery_models/lithium_ion/basic_dfn_composite.py @@ -1,7 +1,10 @@ # # Basic Doyle-Fuller-Newman (DFN) Model # +from __future__ import annotations + import pybamm + from .base_lithium_ion_model import BaseModel diff --git a/pybamm/models/full_battery_models/lithium_ion/basic_dfn_half_cell.py b/pybamm/models/full_battery_models/lithium_ion/basic_dfn_half_cell.py index f8379fffec..80258c752d 100644 --- a/pybamm/models/full_battery_models/lithium_ion/basic_dfn_half_cell.py +++ b/pybamm/models/full_battery_models/lithium_ion/basic_dfn_half_cell.py @@ -1,7 +1,10 @@ # # Basic Doyle-Fuller-Newman (DFN) Half Cell Model # +from __future__ import annotations + import pybamm + from .base_lithium_ion_model import BaseModel diff --git a/pybamm/models/full_battery_models/lithium_ion/basic_spm.py b/pybamm/models/full_battery_models/lithium_ion/basic_spm.py index 802f8037e3..d04d226dce 100644 --- a/pybamm/models/full_battery_models/lithium_ion/basic_spm.py +++ b/pybamm/models/full_battery_models/lithium_ion/basic_spm.py @@ -1,7 +1,10 @@ # # Basic Single Particle Model (SPM) # +from __future__ import annotations + import pybamm + from .base_lithium_ion_model import BaseModel diff --git a/pybamm/models/full_battery_models/lithium_ion/dfn.py b/pybamm/models/full_battery_models/lithium_ion/dfn.py index db4e0282d8..3307130be0 100644 --- a/pybamm/models/full_battery_models/lithium_ion/dfn.py +++ b/pybamm/models/full_battery_models/lithium_ion/dfn.py @@ -1,7 +1,10 @@ # # Doyle-Fuller-Newman (DFN) Model # +from __future__ import annotations + import pybamm + from .base_lithium_ion_model import BaseModel diff --git a/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py b/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py index ad8ee0633d..c45a7cba31 100644 --- a/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py +++ b/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py @@ -1,10 +1,14 @@ # # A model to calculate electrode-specific SOH # -import pybamm -import numpy as np +from __future__ import annotations + from functools import lru_cache +import numpy as np + +import pybamm + class _BaseElectrodeSOH(pybamm.BaseModel): def __init__(self): diff --git a/pybamm/models/full_battery_models/lithium_ion/electrode_soh_half_cell.py b/pybamm/models/full_battery_models/lithium_ion/electrode_soh_half_cell.py index 4fc8c904b6..8b016cdf30 100644 --- a/pybamm/models/full_battery_models/lithium_ion/electrode_soh_half_cell.py +++ b/pybamm/models/full_battery_models/lithium_ion/electrode_soh_half_cell.py @@ -1,6 +1,8 @@ # # A model to calculate electrode-specific SOH, adapted to a half-cell # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/full_battery_models/lithium_ion/mpm.py b/pybamm/models/full_battery_models/lithium_ion/mpm.py index 40a533536f..910d18d911 100644 --- a/pybamm/models/full_battery_models/lithium_ion/mpm.py +++ b/pybamm/models/full_battery_models/lithium_ion/mpm.py @@ -1,7 +1,10 @@ # # Many-Particle Model (MPM) # +from __future__ import annotations + import pybamm + from .spm import SPM diff --git a/pybamm/models/full_battery_models/lithium_ion/msmr.py b/pybamm/models/full_battery_models/lithium_ion/msmr.py index f1ec7f90bd..2d37ba277c 100644 --- a/pybamm/models/full_battery_models/lithium_ion/msmr.py +++ b/pybamm/models/full_battery_models/lithium_ion/msmr.py @@ -1,4 +1,7 @@ +from __future__ import annotations + import pybamm + from .dfn import DFN diff --git a/pybamm/models/full_battery_models/lithium_ion/newman_tobias.py b/pybamm/models/full_battery_models/lithium_ion/newman_tobias.py index a704bd0b33..4386c3d21c 100644 --- a/pybamm/models/full_battery_models/lithium_ion/newman_tobias.py +++ b/pybamm/models/full_battery_models/lithium_ion/newman_tobias.py @@ -1,7 +1,10 @@ # # Newman Tobias Model # +from __future__ import annotations + import pybamm + from .dfn import DFN diff --git a/pybamm/models/full_battery_models/lithium_ion/spm.py b/pybamm/models/full_battery_models/lithium_ion/spm.py index 386c55ded9..020bcc7f07 100644 --- a/pybamm/models/full_battery_models/lithium_ion/spm.py +++ b/pybamm/models/full_battery_models/lithium_ion/spm.py @@ -1,7 +1,10 @@ # # Single Particle Model (SPM) # +from __future__ import annotations + import pybamm + from .base_lithium_ion_model import BaseModel diff --git a/pybamm/models/full_battery_models/lithium_ion/spme.py b/pybamm/models/full_battery_models/lithium_ion/spme.py index 103f13415a..3099358c23 100644 --- a/pybamm/models/full_battery_models/lithium_ion/spme.py +++ b/pybamm/models/full_battery_models/lithium_ion/spme.py @@ -1,7 +1,10 @@ # # Single Particle Model with Electrolyte (SPMe) # +from __future__ import annotations + import pybamm + from .spm import SPM diff --git a/pybamm/models/full_battery_models/lithium_metal/dfn.py b/pybamm/models/full_battery_models/lithium_metal/dfn.py index a7ab8b99e2..10695045a5 100644 --- a/pybamm/models/full_battery_models/lithium_metal/dfn.py +++ b/pybamm/models/full_battery_models/lithium_metal/dfn.py @@ -1,7 +1,10 @@ # # Doyle-Fuller-Newman (DFN) Model # +from __future__ import annotations + import pybamm + from ..lithium_ion.dfn import DFN as LithiumIonDFN diff --git a/pybamm/models/submodels/active_material/base_active_material.py b/pybamm/models/submodels/active_material/base_active_material.py index ba39adf852..06afdef72a 100644 --- a/pybamm/models/submodels/active_material/base_active_material.py +++ b/pybamm/models/submodels/active_material/base_active_material.py @@ -1,6 +1,8 @@ # # Base class for active material volume fraction # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/active_material/constant_active_material.py b/pybamm/models/submodels/active_material/constant_active_material.py index 3237775f1c..cb81a76c5c 100644 --- a/pybamm/models/submodels/active_material/constant_active_material.py +++ b/pybamm/models/submodels/active_material/constant_active_material.py @@ -1,6 +1,8 @@ # # Class for constant active material # +from __future__ import annotations + import pybamm from .base_active_material import BaseModel diff --git a/pybamm/models/submodels/active_material/loss_active_material.py b/pybamm/models/submodels/active_material/loss_active_material.py index 7816122e07..f2ac9c470b 100644 --- a/pybamm/models/submodels/active_material/loss_active_material.py +++ b/pybamm/models/submodels/active_material/loss_active_material.py @@ -1,6 +1,8 @@ # # Class for varying active material volume fraction, driven by stress # +from __future__ import annotations + import pybamm from .base_active_material import BaseModel diff --git a/pybamm/models/submodels/active_material/total_active_material.py b/pybamm/models/submodels/active_material/total_active_material.py index 5e1d7e2f92..cef6df934c 100644 --- a/pybamm/models/submodels/active_material/total_active_material.py +++ b/pybamm/models/submodels/active_material/total_active_material.py @@ -1,6 +1,8 @@ # # Class for total active material volume fraction, for models with multiple phases # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/base_submodel.py b/pybamm/models/submodels/base_submodel.py index 225ae83705..bb82a2af2b 100644 --- a/pybamm/models/submodels/base_submodel.py +++ b/pybamm/models/submodels/base_submodel.py @@ -1,6 +1,8 @@ # # Base submodel class # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/convection/base_convection.py b/pybamm/models/submodels/convection/base_convection.py index a261b7a421..64c1da7dc9 100644 --- a/pybamm/models/submodels/convection/base_convection.py +++ b/pybamm/models/submodels/convection/base_convection.py @@ -1,6 +1,8 @@ # # Base class for convection submodels # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/convection/through_cell/base_through_cell_convection.py b/pybamm/models/submodels/convection/through_cell/base_through_cell_convection.py index 2a8eaa18ed..189d1dc819 100644 --- a/pybamm/models/submodels/convection/through_cell/base_through_cell_convection.py +++ b/pybamm/models/submodels/convection/through_cell/base_through_cell_convection.py @@ -1,7 +1,10 @@ # # Base class for convection submodels in the through-cell direction # +from __future__ import annotations + import pybamm + from ..base_convection import BaseModel diff --git a/pybamm/models/submodels/convection/through_cell/explicit_convection.py b/pybamm/models/submodels/convection/through_cell/explicit_convection.py index 33b58e2b23..b448f24660 100644 --- a/pybamm/models/submodels/convection/through_cell/explicit_convection.py +++ b/pybamm/models/submodels/convection/through_cell/explicit_convection.py @@ -1,7 +1,10 @@ # # Class for leading-order pressure driven convection # +from __future__ import annotations + import pybamm + from .base_through_cell_convection import BaseThroughCellModel diff --git a/pybamm/models/submodels/convection/through_cell/full_convection.py b/pybamm/models/submodels/convection/through_cell/full_convection.py index 0fdc089de7..29d9727971 100644 --- a/pybamm/models/submodels/convection/through_cell/full_convection.py +++ b/pybamm/models/submodels/convection/through_cell/full_convection.py @@ -1,7 +1,10 @@ # # Submodel for pressure driven convection # +from __future__ import annotations + import pybamm + from .base_through_cell_convection import BaseThroughCellModel diff --git a/pybamm/models/submodels/convection/through_cell/no_convection.py b/pybamm/models/submodels/convection/through_cell/no_convection.py index 58f218c5be..ab58c75108 100644 --- a/pybamm/models/submodels/convection/through_cell/no_convection.py +++ b/pybamm/models/submodels/convection/through_cell/no_convection.py @@ -1,7 +1,10 @@ # # No convection # +from __future__ import annotations + import pybamm + from .base_through_cell_convection import BaseThroughCellModel diff --git a/pybamm/models/submodels/convection/transverse/base_transverse_convection.py b/pybamm/models/submodels/convection/transverse/base_transverse_convection.py index e73b586eae..4bf885ea4d 100644 --- a/pybamm/models/submodels/convection/transverse/base_transverse_convection.py +++ b/pybamm/models/submodels/convection/transverse/base_transverse_convection.py @@ -1,7 +1,10 @@ # # Base class for convection submodels in transverse directions # +from __future__ import annotations + import pybamm + from ..base_convection import BaseModel diff --git a/pybamm/models/submodels/convection/transverse/full_convection.py b/pybamm/models/submodels/convection/transverse/full_convection.py index 16da47ae47..199401dfb2 100644 --- a/pybamm/models/submodels/convection/transverse/full_convection.py +++ b/pybamm/models/submodels/convection/transverse/full_convection.py @@ -1,7 +1,10 @@ # # Submodel for pressure driven convection in transverse directions # +from __future__ import annotations + import pybamm + from .base_transverse_convection import BaseTransverseModel diff --git a/pybamm/models/submodels/convection/transverse/no_convection.py b/pybamm/models/submodels/convection/transverse/no_convection.py index c357565070..84ac21e6b8 100644 --- a/pybamm/models/submodels/convection/transverse/no_convection.py +++ b/pybamm/models/submodels/convection/transverse/no_convection.py @@ -1,7 +1,10 @@ # # Submodel for no convection in transverse directions # +from __future__ import annotations + import pybamm + from .base_transverse_convection import BaseTransverseModel diff --git a/pybamm/models/submodels/convection/transverse/uniform_convection.py b/pybamm/models/submodels/convection/transverse/uniform_convection.py index 15a073c148..8fb8d569b5 100644 --- a/pybamm/models/submodels/convection/transverse/uniform_convection.py +++ b/pybamm/models/submodels/convection/transverse/uniform_convection.py @@ -1,7 +1,10 @@ # # Submodel for uniform convection in transverse directions # +from __future__ import annotations + import pybamm + from .base_transverse_convection import BaseTransverseModel diff --git a/pybamm/models/submodels/current_collector/base_current_collector.py b/pybamm/models/submodels/current_collector/base_current_collector.py index 01de9a7797..77b7e61331 100644 --- a/pybamm/models/submodels/current_collector/base_current_collector.py +++ b/pybamm/models/submodels/current_collector/base_current_collector.py @@ -1,6 +1,8 @@ # # Base class for current collector submodels # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/current_collector/effective_resistance_current_collector.py b/pybamm/models/submodels/current_collector/effective_resistance_current_collector.py index 1d50e1be7c..518f823715 100644 --- a/pybamm/models/submodels/current_collector/effective_resistance_current_collector.py +++ b/pybamm/models/submodels/current_collector/effective_resistance_current_collector.py @@ -1,6 +1,8 @@ # # Classes for calcuting the effective resistance of current collectors in a pouch cell # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/current_collector/homogeneous_current_collector.py b/pybamm/models/submodels/current_collector/homogeneous_current_collector.py index 6efc845e32..5841c4208c 100644 --- a/pybamm/models/submodels/current_collector/homogeneous_current_collector.py +++ b/pybamm/models/submodels/current_collector/homogeneous_current_collector.py @@ -1,7 +1,10 @@ # # Class for uniform current collectors # +from __future__ import annotations + import pybamm + from .base_current_collector import BaseModel diff --git a/pybamm/models/submodels/current_collector/potential_pair.py b/pybamm/models/submodels/current_collector/potential_pair.py index 68a9066da3..e26677c79c 100644 --- a/pybamm/models/submodels/current_collector/potential_pair.py +++ b/pybamm/models/submodels/current_collector/potential_pair.py @@ -1,7 +1,10 @@ # # Class for one- and two-dimensional potential pair current collector models # +from __future__ import annotations + import pybamm + from .base_current_collector import BaseModel diff --git a/pybamm/models/submodels/electrode/base_electrode.py b/pybamm/models/submodels/electrode/base_electrode.py index 4248131a75..2146b38531 100644 --- a/pybamm/models/submodels/electrode/base_electrode.py +++ b/pybamm/models/submodels/electrode/base_electrode.py @@ -1,6 +1,8 @@ # # Base class for electrode submodels # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/electrode/ohm/base_ohm.py b/pybamm/models/submodels/electrode/ohm/base_ohm.py index ad38aa6b73..95d3cffbfc 100644 --- a/pybamm/models/submodels/electrode/ohm/base_ohm.py +++ b/pybamm/models/submodels/electrode/ohm/base_ohm.py @@ -1,7 +1,10 @@ # # Base class for Ohm's law submodels # +from __future__ import annotations + import pybamm + from ..base_electrode import BaseElectrode diff --git a/pybamm/models/submodels/electrode/ohm/composite_ohm.py b/pybamm/models/submodels/electrode/ohm/composite_ohm.py index 4845ea9fb2..40dc862051 100644 --- a/pybamm/models/submodels/electrode/ohm/composite_ohm.py +++ b/pybamm/models/submodels/electrode/ohm/composite_ohm.py @@ -1,6 +1,8 @@ # # Composite model for Ohm's law in the electrode # +from __future__ import annotations + import pybamm from .base_ohm import BaseModel diff --git a/pybamm/models/submodels/electrode/ohm/full_ohm.py b/pybamm/models/submodels/electrode/ohm/full_ohm.py index d613b50df2..e7badc7a61 100644 --- a/pybamm/models/submodels/electrode/ohm/full_ohm.py +++ b/pybamm/models/submodels/electrode/ohm/full_ohm.py @@ -1,10 +1,13 @@ # # Full model of electrode employing Ohm's law # +from __future__ import annotations + import pybamm -from .base_ohm import BaseModel from pybamm.doc_utils import copy_parameter_doc_from_parent, doc_extend_parent +from .base_ohm import BaseModel + @copy_parameter_doc_from_parent @doc_extend_parent diff --git a/pybamm/models/submodels/electrode/ohm/leading_ohm.py b/pybamm/models/submodels/electrode/ohm/leading_ohm.py index 7e414f94c9..5948d3136d 100644 --- a/pybamm/models/submodels/electrode/ohm/leading_ohm.py +++ b/pybamm/models/submodels/electrode/ohm/leading_ohm.py @@ -1,6 +1,8 @@ # # Full model for Ohm's law in the electrode # +from __future__ import annotations + import pybamm from .base_ohm import BaseModel diff --git a/pybamm/models/submodels/electrode/ohm/li_metal.py b/pybamm/models/submodels/electrode/ohm/li_metal.py index 6f73d40620..e83e676dba 100644 --- a/pybamm/models/submodels/electrode/ohm/li_metal.py +++ b/pybamm/models/submodels/electrode/ohm/li_metal.py @@ -1,7 +1,10 @@ # # Subodels for a lithium metal electrode # +from __future__ import annotations + import pybamm + from .base_ohm import BaseModel diff --git a/pybamm/models/submodels/electrode/ohm/surface_form_ohm.py b/pybamm/models/submodels/electrode/ohm/surface_form_ohm.py index 316e37e457..4eb6ae9a3d 100644 --- a/pybamm/models/submodels/electrode/ohm/surface_form_ohm.py +++ b/pybamm/models/submodels/electrode/ohm/surface_form_ohm.py @@ -1,6 +1,8 @@ # # Class for ohmic electrodes in the surface potential formulation # +from __future__ import annotations + import pybamm from .base_ohm import BaseModel diff --git a/pybamm/models/submodels/electrolyte_conductivity/base_electrolyte_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/base_electrolyte_conductivity.py index d1178c8cc2..533e7c58d6 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/base_electrolyte_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/base_electrolyte_conductivity.py @@ -1,6 +1,7 @@ # # Base class for electrolyte conductivity # +from __future__ import annotations import pybamm diff --git a/pybamm/models/submodels/electrolyte_conductivity/composite_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/composite_conductivity.py index 475d1a4232..7235d1c4f7 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/composite_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/composite_conductivity.py @@ -1,7 +1,10 @@ # # Composite electrolyte potential employing stefan-maxwell # +from __future__ import annotations + import pybamm + from .base_electrolyte_conductivity import BaseElectrolyteConductivity diff --git a/pybamm/models/submodels/electrolyte_conductivity/full_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/full_conductivity.py index 5acb7d2434..edd3986215 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/full_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/full_conductivity.py @@ -1,6 +1,8 @@ # # Class for electrolyte conductivity employing stefan-maxwell # +from __future__ import annotations + import pybamm from .base_electrolyte_conductivity import BaseElectrolyteConductivity diff --git a/pybamm/models/submodels/electrolyte_conductivity/integrated_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/integrated_conductivity.py index cb9979c6bb..aced0a3c10 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/integrated_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/integrated_conductivity.py @@ -1,7 +1,10 @@ # # Composite electrolyte potential employing integrated Stefan-Maxwell # +from __future__ import annotations + import pybamm + from .base_electrolyte_conductivity import BaseElectrolyteConductivity diff --git a/pybamm/models/submodels/electrolyte_conductivity/leading_order_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/leading_order_conductivity.py index ad2a5b6486..884ee160f2 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/leading_order_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/leading_order_conductivity.py @@ -1,7 +1,10 @@ # # Class for the leading-order electrolyte potential employing stefan-maxwell # +from __future__ import annotations + import pybamm + from .base_electrolyte_conductivity import BaseElectrolyteConductivity diff --git a/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/composite_surface_form_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/composite_surface_form_conductivity.py index 4b40e28e7d..2877f675be 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/composite_surface_form_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/composite_surface_form_conductivity.py @@ -1,6 +1,8 @@ # # Class for composite surface form electrolyte conductivity employing stefan-maxwell # +from __future__ import annotations + import pybamm from ..composite_conductivity import Composite diff --git a/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/explicit_surface_form_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/explicit_surface_form_conductivity.py index c2391b277b..b8a5a3d69e 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/explicit_surface_form_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/explicit_surface_form_conductivity.py @@ -1,7 +1,10 @@ # # Class for explicit surface form potentials # +from __future__ import annotations + import pybamm + from ..base_electrolyte_conductivity import BaseElectrolyteConductivity diff --git a/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/full_surface_form_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/full_surface_form_conductivity.py index 83bcfb8027..cd8f2dd4b4 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/full_surface_form_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/full_surface_form_conductivity.py @@ -1,7 +1,10 @@ # # Class for full surface form electrolyte conductivity employing stefan-maxwell # +from __future__ import annotations + import pybamm + from ..base_electrolyte_conductivity import BaseElectrolyteConductivity diff --git a/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/leading_surface_form_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/leading_surface_form_conductivity.py index 042d143f36..dc57af039e 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/leading_surface_form_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/leading_surface_form_conductivity.py @@ -1,6 +1,8 @@ # # Class for leading-order surface form electrolyte conductivity employing stefan-maxwell # +from __future__ import annotations + import pybamm from ..leading_order_conductivity import LeadingOrder diff --git a/pybamm/models/submodels/electrolyte_diffusion/base_electrolyte_diffusion.py b/pybamm/models/submodels/electrolyte_diffusion/base_electrolyte_diffusion.py index 7b0287ba2f..e5e8026808 100644 --- a/pybamm/models/submodels/electrolyte_diffusion/base_electrolyte_diffusion.py +++ b/pybamm/models/submodels/electrolyte_diffusion/base_electrolyte_diffusion.py @@ -1,6 +1,8 @@ # # Base class for electrolyte diffusion # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/electrolyte_diffusion/constant_concentration.py b/pybamm/models/submodels/electrolyte_diffusion/constant_concentration.py index ca8b11e796..ce2225ef60 100644 --- a/pybamm/models/submodels/electrolyte_diffusion/constant_concentration.py +++ b/pybamm/models/submodels/electrolyte_diffusion/constant_concentration.py @@ -1,6 +1,8 @@ # # Class for leading-order electrolyte diffusion employing stefan-maxwell # +from __future__ import annotations + import pybamm from .base_electrolyte_diffusion import BaseElectrolyteDiffusion diff --git a/pybamm/models/submodels/electrolyte_diffusion/full_diffusion.py b/pybamm/models/submodels/electrolyte_diffusion/full_diffusion.py index 464d82e4e7..c164b006f2 100644 --- a/pybamm/models/submodels/electrolyte_diffusion/full_diffusion.py +++ b/pybamm/models/submodels/electrolyte_diffusion/full_diffusion.py @@ -1,8 +1,12 @@ # # Class for electrolyte diffusion employing stefan-maxwell # -import pybamm +from __future__ import annotations + import numpy as np + +import pybamm + from .base_electrolyte_diffusion import BaseElectrolyteDiffusion diff --git a/pybamm/models/submodels/electrolyte_diffusion/leading_order_diffusion.py b/pybamm/models/submodels/electrolyte_diffusion/leading_order_diffusion.py index 8dedc28cf5..57a8a1c3c0 100644 --- a/pybamm/models/submodels/electrolyte_diffusion/leading_order_diffusion.py +++ b/pybamm/models/submodels/electrolyte_diffusion/leading_order_diffusion.py @@ -1,9 +1,12 @@ # # Class for leading-order electrolyte diffusion employing stefan-maxwell # -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + from .base_electrolyte_diffusion import BaseElectrolyteDiffusion diff --git a/pybamm/models/submodels/equivalent_circuit_elements/ocv_element.py b/pybamm/models/submodels/equivalent_circuit_elements/ocv_element.py index 4c570b3cf4..85154177db 100644 --- a/pybamm/models/submodels/equivalent_circuit_elements/ocv_element.py +++ b/pybamm/models/submodels/equivalent_circuit_elements/ocv_element.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/equivalent_circuit_elements/rc_element.py b/pybamm/models/submodels/equivalent_circuit_elements/rc_element.py index 557bc48a66..aa8d2f4d88 100644 --- a/pybamm/models/submodels/equivalent_circuit_elements/rc_element.py +++ b/pybamm/models/submodels/equivalent_circuit_elements/rc_element.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/equivalent_circuit_elements/resistor_element.py b/pybamm/models/submodels/equivalent_circuit_elements/resistor_element.py index 22f6cf6568..2022266789 100644 --- a/pybamm/models/submodels/equivalent_circuit_elements/resistor_element.py +++ b/pybamm/models/submodels/equivalent_circuit_elements/resistor_element.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/equivalent_circuit_elements/thermal.py b/pybamm/models/submodels/equivalent_circuit_elements/thermal.py index a5003ef615..80a040b418 100644 --- a/pybamm/models/submodels/equivalent_circuit_elements/thermal.py +++ b/pybamm/models/submodels/equivalent_circuit_elements/thermal.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/equivalent_circuit_elements/voltage_model.py b/pybamm/models/submodels/equivalent_circuit_elements/voltage_model.py index d976cd0747..2a232685ef 100644 --- a/pybamm/models/submodels/equivalent_circuit_elements/voltage_model.py +++ b/pybamm/models/submodels/equivalent_circuit_elements/voltage_model.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/external_circuit/base_external_circuit.py b/pybamm/models/submodels/external_circuit/base_external_circuit.py index 713616c063..64103ad3a8 100644 --- a/pybamm/models/submodels/external_circuit/base_external_circuit.py +++ b/pybamm/models/submodels/external_circuit/base_external_circuit.py @@ -1,6 +1,8 @@ # # Base model for the external circuit # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/external_circuit/explicit_control_external_circuit.py b/pybamm/models/submodels/external_circuit/explicit_control_external_circuit.py index e9bf18155b..050a1c047f 100644 --- a/pybamm/models/submodels/external_circuit/explicit_control_external_circuit.py +++ b/pybamm/models/submodels/external_circuit/explicit_control_external_circuit.py @@ -1,7 +1,10 @@ # # External circuit with explicit equations for control # +from __future__ import annotations + import pybamm + from .base_external_circuit import BaseModel diff --git a/pybamm/models/submodels/external_circuit/function_control_external_circuit.py b/pybamm/models/submodels/external_circuit/function_control_external_circuit.py index 2e64e84c9e..ecca0bd059 100644 --- a/pybamm/models/submodels/external_circuit/function_control_external_circuit.py +++ b/pybamm/models/submodels/external_circuit/function_control_external_circuit.py @@ -1,7 +1,10 @@ # # External circuit with an arbitrary function # +from __future__ import annotations + import pybamm + from .base_external_circuit import BaseModel diff --git a/pybamm/models/submodels/interface/base_interface.py b/pybamm/models/submodels/interface/base_interface.py index b7e160ee2f..f1de5953bc 100644 --- a/pybamm/models/submodels/interface/base_interface.py +++ b/pybamm/models/submodels/interface/base_interface.py @@ -1,6 +1,7 @@ # # Base interface class # +from __future__ import annotations import pybamm diff --git a/pybamm/models/submodels/interface/interface_utilisation/base_utilisation.py b/pybamm/models/submodels/interface/interface_utilisation/base_utilisation.py index 3023322854..319dd3f76e 100644 --- a/pybamm/models/submodels/interface/interface_utilisation/base_utilisation.py +++ b/pybamm/models/submodels/interface/interface_utilisation/base_utilisation.py @@ -1,6 +1,8 @@ # # Base class for interface utilisation # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/interface/interface_utilisation/constant_utilisation.py b/pybamm/models/submodels/interface/interface_utilisation/constant_utilisation.py index 50c2c22aa4..f4eeb5a2d5 100644 --- a/pybamm/models/submodels/interface/interface_utilisation/constant_utilisation.py +++ b/pybamm/models/submodels/interface/interface_utilisation/constant_utilisation.py @@ -1,6 +1,8 @@ # # Class for constant interface utilisation # +from __future__ import annotations + import pybamm from .base_utilisation import BaseModel diff --git a/pybamm/models/submodels/interface/interface_utilisation/current_driven_utilisation.py b/pybamm/models/submodels/interface/interface_utilisation/current_driven_utilisation.py index bbd9af4fb6..0691ffb47b 100644 --- a/pybamm/models/submodels/interface/interface_utilisation/current_driven_utilisation.py +++ b/pybamm/models/submodels/interface/interface_utilisation/current_driven_utilisation.py @@ -1,7 +1,10 @@ # # Class for current-driven ODE for interface utilisation # +from __future__ import annotations + import pybamm + from .base_utilisation import BaseModel diff --git a/pybamm/models/submodels/interface/interface_utilisation/full_utilisation.py b/pybamm/models/submodels/interface/interface_utilisation/full_utilisation.py index 3a21a87c31..fd327f1821 100644 --- a/pybamm/models/submodels/interface/interface_utilisation/full_utilisation.py +++ b/pybamm/models/submodels/interface/interface_utilisation/full_utilisation.py @@ -1,6 +1,8 @@ # # Class for full interface utilisation # +from __future__ import annotations + import pybamm from .base_utilisation import BaseModel diff --git a/pybamm/models/submodels/interface/kinetics/base_kinetics.py b/pybamm/models/submodels/interface/kinetics/base_kinetics.py index dd5ee76340..5a62081ca7 100644 --- a/pybamm/models/submodels/interface/kinetics/base_kinetics.py +++ b/pybamm/models/submodels/interface/kinetics/base_kinetics.py @@ -1,7 +1,10 @@ # # Base kinetics class # +from __future__ import annotations + import pybamm + from ..base_interface import BaseInterface diff --git a/pybamm/models/submodels/interface/kinetics/butler_volmer.py b/pybamm/models/submodels/interface/kinetics/butler_volmer.py index 81489b2bd9..08d637c1ec 100644 --- a/pybamm/models/submodels/interface/kinetics/butler_volmer.py +++ b/pybamm/models/submodels/interface/kinetics/butler_volmer.py @@ -1,8 +1,10 @@ # # Bulter volmer class # +from __future__ import annotations import pybamm + from .base_kinetics import BaseKinetics diff --git a/pybamm/models/submodels/interface/kinetics/diffusion_limited.py b/pybamm/models/submodels/interface/kinetics/diffusion_limited.py index b761778155..9ce4419233 100644 --- a/pybamm/models/submodels/interface/kinetics/diffusion_limited.py +++ b/pybamm/models/submodels/interface/kinetics/diffusion_limited.py @@ -1,8 +1,10 @@ # # Diffusion-limited kinetics # +from __future__ import annotations import pybamm + from ..base_interface import BaseInterface diff --git a/pybamm/models/submodels/interface/kinetics/inverse_kinetics/inverse_butler_volmer.py b/pybamm/models/submodels/interface/kinetics/inverse_kinetics/inverse_butler_volmer.py index 88e1793263..5a04cf8814 100644 --- a/pybamm/models/submodels/interface/kinetics/inverse_kinetics/inverse_butler_volmer.py +++ b/pybamm/models/submodels/interface/kinetics/inverse_kinetics/inverse_butler_volmer.py @@ -1,7 +1,10 @@ # # Inverse Bulter-Volmer class # +from __future__ import annotations + import pybamm + from ...base_interface import BaseInterface diff --git a/pybamm/models/submodels/interface/kinetics/linear.py b/pybamm/models/submodels/interface/kinetics/linear.py index 9678009660..1f5543242a 100644 --- a/pybamm/models/submodels/interface/kinetics/linear.py +++ b/pybamm/models/submodels/interface/kinetics/linear.py @@ -1,6 +1,7 @@ # # Linear kinetics # +from __future__ import annotations from .base_kinetics import BaseKinetics diff --git a/pybamm/models/submodels/interface/kinetics/marcus.py b/pybamm/models/submodels/interface/kinetics/marcus.py index 60b5fce3c5..e459b865d7 100644 --- a/pybamm/models/submodels/interface/kinetics/marcus.py +++ b/pybamm/models/submodels/interface/kinetics/marcus.py @@ -1,9 +1,12 @@ # # Marcus and Asymptotic Marcus-Hush-Chidsey classes # +from __future__ import annotations -import pybamm import numpy as np + +import pybamm + from .base_kinetics import BaseKinetics diff --git a/pybamm/models/submodels/interface/kinetics/msmr_butler_volmer.py b/pybamm/models/submodels/interface/kinetics/msmr_butler_volmer.py index 6a4b9f5023..ed5e2b8f5a 100644 --- a/pybamm/models/submodels/interface/kinetics/msmr_butler_volmer.py +++ b/pybamm/models/submodels/interface/kinetics/msmr_butler_volmer.py @@ -1,8 +1,10 @@ # # Bulter volmer class for the MSMR formulation # +from __future__ import annotations import pybamm + from .base_kinetics import BaseKinetics diff --git a/pybamm/models/submodels/interface/kinetics/no_reaction.py b/pybamm/models/submodels/interface/kinetics/no_reaction.py index 27d8d201ca..9a2039b8a1 100644 --- a/pybamm/models/submodels/interface/kinetics/no_reaction.py +++ b/pybamm/models/submodels/interface/kinetics/no_reaction.py @@ -1,8 +1,10 @@ # # Bulter volmer class # +from __future__ import annotations import pybamm + from ..base_interface import BaseInterface diff --git a/pybamm/models/submodels/interface/kinetics/tafel.py b/pybamm/models/submodels/interface/kinetics/tafel.py index bcba681855..6b28b262d6 100644 --- a/pybamm/models/submodels/interface/kinetics/tafel.py +++ b/pybamm/models/submodels/interface/kinetics/tafel.py @@ -1,7 +1,10 @@ # # Tafel classes # +from __future__ import annotations + import pybamm + from .base_kinetics import BaseKinetics diff --git a/pybamm/models/submodels/interface/kinetics/total_main_kinetics.py b/pybamm/models/submodels/interface/kinetics/total_main_kinetics.py index 89ce55086d..0637feab02 100644 --- a/pybamm/models/submodels/interface/kinetics/total_main_kinetics.py +++ b/pybamm/models/submodels/interface/kinetics/total_main_kinetics.py @@ -2,6 +2,8 @@ # Class summing up contributions to the main (e.g. intercalation) reaction # for cases with primary, secondary, ... reactions e.g. silicon-graphite # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/interface/lithium_plating/base_plating.py b/pybamm/models/submodels/interface/lithium_plating/base_plating.py index ebfbe46831..077c553221 100644 --- a/pybamm/models/submodels/interface/lithium_plating/base_plating.py +++ b/pybamm/models/submodels/interface/lithium_plating/base_plating.py @@ -1,7 +1,10 @@ # # Base class for lithium plating models. # +from __future__ import annotations + import pybamm + from ..base_interface import BaseInterface diff --git a/pybamm/models/submodels/interface/lithium_plating/no_plating.py b/pybamm/models/submodels/interface/lithium_plating/no_plating.py index 94697fdd89..4fc3a6d805 100644 --- a/pybamm/models/submodels/interface/lithium_plating/no_plating.py +++ b/pybamm/models/submodels/interface/lithium_plating/no_plating.py @@ -1,7 +1,10 @@ # # Class for no plating # +from __future__ import annotations + import pybamm + from .base_plating import BasePlating diff --git a/pybamm/models/submodels/interface/lithium_plating/plating.py b/pybamm/models/submodels/interface/lithium_plating/plating.py index 9f4de08d2f..6371cb9b57 100644 --- a/pybamm/models/submodels/interface/lithium_plating/plating.py +++ b/pybamm/models/submodels/interface/lithium_plating/plating.py @@ -1,7 +1,10 @@ # # Class for lithium plating # +from __future__ import annotations + import pybamm + from .base_plating import BasePlating diff --git a/pybamm/models/submodels/interface/open_circuit_potential/base_ocp.py b/pybamm/models/submodels/interface/open_circuit_potential/base_ocp.py index 35f3894dfe..e6215f32b6 100644 --- a/pybamm/models/submodels/interface/open_circuit_potential/base_ocp.py +++ b/pybamm/models/submodels/interface/open_circuit_potential/base_ocp.py @@ -1,7 +1,10 @@ # # Base class for open-circuit potential # +from __future__ import annotations + import pybamm + from ..base_interface import BaseInterface diff --git a/pybamm/models/submodels/interface/open_circuit_potential/current_sigmoid_ocp.py b/pybamm/models/submodels/interface/open_circuit_potential/current_sigmoid_ocp.py index fa55ba1079..992a14939a 100644 --- a/pybamm/models/submodels/interface/open_circuit_potential/current_sigmoid_ocp.py +++ b/pybamm/models/submodels/interface/open_circuit_potential/current_sigmoid_ocp.py @@ -1,7 +1,10 @@ # # Different OCPs for charge and discharge, based on current # +from __future__ import annotations + import pybamm + from . import BaseOpenCircuitPotential diff --git a/pybamm/models/submodels/interface/open_circuit_potential/msmr_ocp.py b/pybamm/models/submodels/interface/open_circuit_potential/msmr_ocp.py index 2ac87279f2..69fc9559e2 100644 --- a/pybamm/models/submodels/interface/open_circuit_potential/msmr_ocp.py +++ b/pybamm/models/submodels/interface/open_circuit_potential/msmr_ocp.py @@ -1,7 +1,10 @@ # # Open-circuit potential from the Multi-Species Multi-Reaction framework # +from __future__ import annotations + import pybamm + from . import BaseOpenCircuitPotential diff --git a/pybamm/models/submodels/interface/open_circuit_potential/single_ocp.py b/pybamm/models/submodels/interface/open_circuit_potential/single_ocp.py index 932e2e3eff..a9a44203b3 100644 --- a/pybamm/models/submodels/interface/open_circuit_potential/single_ocp.py +++ b/pybamm/models/submodels/interface/open_circuit_potential/single_ocp.py @@ -1,7 +1,10 @@ # # Single open-circuit potential, same for charge and discharge # +from __future__ import annotations + import pybamm + from . import BaseOpenCircuitPotential diff --git a/pybamm/models/submodels/interface/sei/base_sei.py b/pybamm/models/submodels/interface/sei/base_sei.py index b0e8db56c6..94c3d196ad 100644 --- a/pybamm/models/submodels/interface/sei/base_sei.py +++ b/pybamm/models/submodels/interface/sei/base_sei.py @@ -1,7 +1,10 @@ # # Base class for SEI models. # +from __future__ import annotations + import pybamm + from ..base_interface import BaseInterface diff --git a/pybamm/models/submodels/interface/sei/constant_sei.py b/pybamm/models/submodels/interface/sei/constant_sei.py index 4c507eec3a..40edd2d810 100644 --- a/pybamm/models/submodels/interface/sei/constant_sei.py +++ b/pybamm/models/submodels/interface/sei/constant_sei.py @@ -1,7 +1,10 @@ # # Class for constant SEI thickness # +from __future__ import annotations + import pybamm + from .base_sei import BaseModel diff --git a/pybamm/models/submodels/interface/sei/no_sei.py b/pybamm/models/submodels/interface/sei/no_sei.py index 49d11a35e5..30bada1d51 100644 --- a/pybamm/models/submodels/interface/sei/no_sei.py +++ b/pybamm/models/submodels/interface/sei/no_sei.py @@ -1,7 +1,10 @@ # # Class for no SEI # +from __future__ import annotations + import pybamm + from .base_sei import BaseModel diff --git a/pybamm/models/submodels/interface/sei/sei_growth.py b/pybamm/models/submodels/interface/sei/sei_growth.py index 89bb662fbc..fdba1f14b6 100644 --- a/pybamm/models/submodels/interface/sei/sei_growth.py +++ b/pybamm/models/submodels/interface/sei/sei_growth.py @@ -1,7 +1,10 @@ # # Class for SEI growth # +from __future__ import annotations + import pybamm + from .base_sei import BaseModel diff --git a/pybamm/models/submodels/interface/sei/total_sei.py b/pybamm/models/submodels/interface/sei/total_sei.py index 2a017b94a0..93b246a22b 100644 --- a/pybamm/models/submodels/interface/sei/total_sei.py +++ b/pybamm/models/submodels/interface/sei/total_sei.py @@ -2,6 +2,8 @@ # Class summing up contributions to the SEI reaction # for cases with primary, secondary, ... reactions e.g. silicon-graphite # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/interface/total_interfacial_current.py b/pybamm/models/submodels/interface/total_interfacial_current.py index 79e13e37f6..e204252b71 100644 --- a/pybamm/models/submodels/interface/total_interfacial_current.py +++ b/pybamm/models/submodels/interface/total_interfacial_current.py @@ -1,6 +1,8 @@ # # Total interfacial current class, summing up contributions from all reactions # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/oxygen_diffusion/base_oxygen_diffusion.py b/pybamm/models/submodels/oxygen_diffusion/base_oxygen_diffusion.py index bc8394d5fc..fb7d0fbca3 100644 --- a/pybamm/models/submodels/oxygen_diffusion/base_oxygen_diffusion.py +++ b/pybamm/models/submodels/oxygen_diffusion/base_oxygen_diffusion.py @@ -1,6 +1,8 @@ # # Base class for oxygen diffusion # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/oxygen_diffusion/full_oxygen_diffusion.py b/pybamm/models/submodels/oxygen_diffusion/full_oxygen_diffusion.py index c69312e342..b02eab3ab7 100644 --- a/pybamm/models/submodels/oxygen_diffusion/full_oxygen_diffusion.py +++ b/pybamm/models/submodels/oxygen_diffusion/full_oxygen_diffusion.py @@ -1,6 +1,8 @@ # # Class for oxygen diffusion # +from __future__ import annotations + import pybamm from .base_oxygen_diffusion import BaseModel diff --git a/pybamm/models/submodels/oxygen_diffusion/leading_oxygen_diffusion.py b/pybamm/models/submodels/oxygen_diffusion/leading_oxygen_diffusion.py index 056c7f6715..de0077ee03 100644 --- a/pybamm/models/submodels/oxygen_diffusion/leading_oxygen_diffusion.py +++ b/pybamm/models/submodels/oxygen_diffusion/leading_oxygen_diffusion.py @@ -1,6 +1,8 @@ # # Class for leading-order oxygen diffusion # +from __future__ import annotations + import pybamm from .base_oxygen_diffusion import BaseModel diff --git a/pybamm/models/submodels/oxygen_diffusion/no_oxygen.py b/pybamm/models/submodels/oxygen_diffusion/no_oxygen.py index 3cdd9ae36d..6f572497e0 100644 --- a/pybamm/models/submodels/oxygen_diffusion/no_oxygen.py +++ b/pybamm/models/submodels/oxygen_diffusion/no_oxygen.py @@ -1,6 +1,8 @@ # # Class for when there is no oxygen # +from __future__ import annotations + import pybamm from .base_oxygen_diffusion import BaseModel diff --git a/pybamm/models/submodels/particle/base_particle.py b/pybamm/models/submodels/particle/base_particle.py index dab48b5f79..c25e9f9991 100644 --- a/pybamm/models/submodels/particle/base_particle.py +++ b/pybamm/models/submodels/particle/base_particle.py @@ -1,6 +1,8 @@ # # Base class for particles # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/particle/fickian_diffusion.py b/pybamm/models/submodels/particle/fickian_diffusion.py index 31c5e6be6c..f3fd7e8b3f 100644 --- a/pybamm/models/submodels/particle/fickian_diffusion.py +++ b/pybamm/models/submodels/particle/fickian_diffusion.py @@ -1,7 +1,10 @@ # # Class for particles with Fickian diffusion # +from __future__ import annotations + import pybamm + from .base_particle import BaseParticle diff --git a/pybamm/models/submodels/particle/msmr_diffusion.py b/pybamm/models/submodels/particle/msmr_diffusion.py index c53f313ab4..089643314d 100644 --- a/pybamm/models/submodels/particle/msmr_diffusion.py +++ b/pybamm/models/submodels/particle/msmr_diffusion.py @@ -1,7 +1,10 @@ # # Class for particles using the MSMR model # +from __future__ import annotations + import pybamm + from .base_particle import BaseParticle diff --git a/pybamm/models/submodels/particle/polynomial_profile.py b/pybamm/models/submodels/particle/polynomial_profile.py index dda3a30663..85e1b36c8c 100644 --- a/pybamm/models/submodels/particle/polynomial_profile.py +++ b/pybamm/models/submodels/particle/polynomial_profile.py @@ -1,6 +1,8 @@ # # Class for many particles with polynomial concentration profile # +from __future__ import annotations + import pybamm from .base_particle import BaseParticle diff --git a/pybamm/models/submodels/particle/total_particle_concentration.py b/pybamm/models/submodels/particle/total_particle_concentration.py index 0b5f496705..d3d0c90502 100644 --- a/pybamm/models/submodels/particle/total_particle_concentration.py +++ b/pybamm/models/submodels/particle/total_particle_concentration.py @@ -1,7 +1,10 @@ # # Class to calculate total particle concentrations # +from __future__ import annotations + import pybamm + from .base_particle import BaseParticle diff --git a/pybamm/models/submodels/particle/x_averaged_polynomial_profile.py b/pybamm/models/submodels/particle/x_averaged_polynomial_profile.py index 8b4b7ffe7c..e70ef9931c 100644 --- a/pybamm/models/submodels/particle/x_averaged_polynomial_profile.py +++ b/pybamm/models/submodels/particle/x_averaged_polynomial_profile.py @@ -1,6 +1,8 @@ # # Class for single particle with polynomial concentration profile # +from __future__ import annotations + import pybamm from .polynomial_profile import PolynomialProfile diff --git a/pybamm/models/submodels/particle_mechanics/base_mechanics.py b/pybamm/models/submodels/particle_mechanics/base_mechanics.py index 4e25becbab..74a7a85875 100644 --- a/pybamm/models/submodels/particle_mechanics/base_mechanics.py +++ b/pybamm/models/submodels/particle_mechanics/base_mechanics.py @@ -1,6 +1,8 @@ # # Base class for particle cracking models. # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/particle_mechanics/crack_propagation.py b/pybamm/models/submodels/particle_mechanics/crack_propagation.py index 3bb9ecb7eb..e0f2745f69 100644 --- a/pybamm/models/submodels/particle_mechanics/crack_propagation.py +++ b/pybamm/models/submodels/particle_mechanics/crack_propagation.py @@ -1,9 +1,13 @@ # # Class for cracking # +from __future__ import annotations + +import numpy as np + import pybamm + from .base_mechanics import BaseMechanics -import numpy as np class CrackPropagation(BaseMechanics): diff --git a/pybamm/models/submodels/particle_mechanics/no_mechanics.py b/pybamm/models/submodels/particle_mechanics/no_mechanics.py index 1746d4781f..80ecb96ee6 100644 --- a/pybamm/models/submodels/particle_mechanics/no_mechanics.py +++ b/pybamm/models/submodels/particle_mechanics/no_mechanics.py @@ -1,7 +1,10 @@ # # Class for no mechanics # +from __future__ import annotations + import pybamm + from .base_mechanics import BaseMechanics diff --git a/pybamm/models/submodels/particle_mechanics/swelling_only.py b/pybamm/models/submodels/particle_mechanics/swelling_only.py index 6dd6fde489..eae500a1bf 100644 --- a/pybamm/models/submodels/particle_mechanics/swelling_only.py +++ b/pybamm/models/submodels/particle_mechanics/swelling_only.py @@ -1,7 +1,10 @@ # # Class for swelling only (no cracking) # +from __future__ import annotations + import pybamm + from .base_mechanics import BaseMechanics diff --git a/pybamm/models/submodels/porosity/base_porosity.py b/pybamm/models/submodels/porosity/base_porosity.py index 7a65729dd5..3a16bdc22d 100644 --- a/pybamm/models/submodels/porosity/base_porosity.py +++ b/pybamm/models/submodels/porosity/base_porosity.py @@ -1,6 +1,8 @@ # # Base class for porosity # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/porosity/constant_porosity.py b/pybamm/models/submodels/porosity/constant_porosity.py index 0b9f3c0da4..72bf5e6c5a 100644 --- a/pybamm/models/submodels/porosity/constant_porosity.py +++ b/pybamm/models/submodels/porosity/constant_porosity.py @@ -1,6 +1,8 @@ # # Class for constant porosity # +from __future__ import annotations + import pybamm from .base_porosity import BaseModel diff --git a/pybamm/models/submodels/porosity/reaction_driven_porosity.py b/pybamm/models/submodels/porosity/reaction_driven_porosity.py index fc69d0f1fd..eea4cbd2b7 100644 --- a/pybamm/models/submodels/porosity/reaction_driven_porosity.py +++ b/pybamm/models/submodels/porosity/reaction_driven_porosity.py @@ -1,7 +1,10 @@ # # Class for reaction driven porosity changes as a multiple of SEI/plating thicknesses # +from __future__ import annotations + import pybamm + from .base_porosity import BaseModel diff --git a/pybamm/models/submodels/porosity/reaction_driven_porosity_ode.py b/pybamm/models/submodels/porosity/reaction_driven_porosity_ode.py index 476845f054..bec83551c6 100644 --- a/pybamm/models/submodels/porosity/reaction_driven_porosity_ode.py +++ b/pybamm/models/submodels/porosity/reaction_driven_porosity_ode.py @@ -1,7 +1,10 @@ # # Class for reaction driven porosity changes as an ODE # +from __future__ import annotations + import pybamm + from .base_porosity import BaseModel diff --git a/pybamm/models/submodels/thermal/base_thermal.py b/pybamm/models/submodels/thermal/base_thermal.py index 808cdefc67..11e13a3db2 100644 --- a/pybamm/models/submodels/thermal/base_thermal.py +++ b/pybamm/models/submodels/thermal/base_thermal.py @@ -1,6 +1,8 @@ # # Base class for thermal effects # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/thermal/isothermal.py b/pybamm/models/submodels/thermal/isothermal.py index 52b5277986..18e91ed2d0 100644 --- a/pybamm/models/submodels/thermal/isothermal.py +++ b/pybamm/models/submodels/thermal/isothermal.py @@ -1,6 +1,8 @@ # # Class for isothermal submodel # +from __future__ import annotations + import pybamm from .base_thermal import BaseThermal diff --git a/pybamm/models/submodels/thermal/lumped.py b/pybamm/models/submodels/thermal/lumped.py index 0f396a3f77..e6bdcc3793 100644 --- a/pybamm/models/submodels/thermal/lumped.py +++ b/pybamm/models/submodels/thermal/lumped.py @@ -1,6 +1,8 @@ # # Class for lumped thermal submodel # +from __future__ import annotations + import pybamm from .base_thermal import BaseThermal diff --git a/pybamm/models/submodels/thermal/pouch_cell/pouch_cell_1D_current_collectors.py b/pybamm/models/submodels/thermal/pouch_cell/pouch_cell_1D_current_collectors.py index 2611dbafdc..093352ef02 100644 --- a/pybamm/models/submodels/thermal/pouch_cell/pouch_cell_1D_current_collectors.py +++ b/pybamm/models/submodels/thermal/pouch_cell/pouch_cell_1D_current_collectors.py @@ -1,6 +1,8 @@ # # Class for one-dimensional thermal submodel for use in the "1+1D" pouch cell model # +from __future__ import annotations + import pybamm from ..base_thermal import BaseThermal diff --git a/pybamm/models/submodels/thermal/pouch_cell/pouch_cell_2D_current_collectors.py b/pybamm/models/submodels/thermal/pouch_cell/pouch_cell_2D_current_collectors.py index a5c7c42b17..95adb62d12 100644 --- a/pybamm/models/submodels/thermal/pouch_cell/pouch_cell_2D_current_collectors.py +++ b/pybamm/models/submodels/thermal/pouch_cell/pouch_cell_2D_current_collectors.py @@ -1,6 +1,8 @@ # # Class for two-dimensional thermal submodel for use in the "2+1D" pouch cell model # +from __future__ import annotations + import pybamm from ..base_thermal import BaseThermal diff --git a/pybamm/models/submodels/thermal/pouch_cell/x_full.py b/pybamm/models/submodels/thermal/pouch_cell/x_full.py index 64a6e687c6..30cf63a9fa 100644 --- a/pybamm/models/submodels/thermal/pouch_cell/x_full.py +++ b/pybamm/models/submodels/thermal/pouch_cell/x_full.py @@ -1,6 +1,8 @@ # # Class for one-dimensional (x-direction) thermal submodel # +from __future__ import annotations + import pybamm from ..base_thermal import BaseThermal diff --git a/pybamm/models/submodels/transport_efficiency/base_transport_efficiency.py b/pybamm/models/submodels/transport_efficiency/base_transport_efficiency.py index 6c99cea328..87b63f5e44 100644 --- a/pybamm/models/submodels/transport_efficiency/base_transport_efficiency.py +++ b/pybamm/models/submodels/transport_efficiency/base_transport_efficiency.py @@ -1,6 +1,8 @@ # # Base class for transport_efficiency # +from __future__ import annotations + import pybamm diff --git a/pybamm/models/submodels/transport_efficiency/bruggeman_transport_efficiency.py b/pybamm/models/submodels/transport_efficiency/bruggeman_transport_efficiency.py index 5110ef8d13..8a4cf5ea1f 100644 --- a/pybamm/models/submodels/transport_efficiency/bruggeman_transport_efficiency.py +++ b/pybamm/models/submodels/transport_efficiency/bruggeman_transport_efficiency.py @@ -1,7 +1,10 @@ # # Class for Bruggemantransport_efficiency # +from __future__ import annotations + import pybamm + from .base_transport_efficiency import BaseModel diff --git a/pybamm/parameters/base_parameters.py b/pybamm/parameters/base_parameters.py index a7b319ec81..e9a290a99e 100644 --- a/pybamm/parameters/base_parameters.py +++ b/pybamm/parameters/base_parameters.py @@ -1,9 +1,12 @@ # # Base parameters class # -import pybamm +from __future__ import annotations + import warnings +import pybamm + class BaseParameters: """ diff --git a/pybamm/parameters/bpx.py b/pybamm/parameters/bpx.py index c6037b0f40..eaacad9c92 100644 --- a/pybamm/parameters/bpx.py +++ b/pybamm/parameters/bpx.py @@ -1,14 +1,15 @@ -from bpx import BPX, Function, InterpolatedTable -from bpx.schema import ElectrodeBlended, ElectrodeBlendedSPM -import pybamm +from __future__ import annotations + import math from dataclasses import dataclass -import numpy as np -from pybamm import constants -from pybamm import exp +from functools import partial +import numpy as np +from bpx import BPX, Function, InterpolatedTable +from bpx.schema import ElectrodeBlended, ElectrodeBlendedSPM -from functools import partial +import pybamm +from pybamm import constants, exp def _callable_func(var, fun): diff --git a/pybamm/parameters/constants.py b/pybamm/parameters/constants.py index 777fe83f19..d592afc0cf 100644 --- a/pybamm/parameters/constants.py +++ b/pybamm/parameters/constants.py @@ -1,7 +1,10 @@ # # Standard constants # +from __future__ import annotations + from scipy import constants + from pybamm import Scalar R = Scalar(constants.R) diff --git a/pybamm/parameters/ecm_parameters.py b/pybamm/parameters/ecm_parameters.py index 79bb42e318..7243199fe0 100644 --- a/pybamm/parameters/ecm_parameters.py +++ b/pybamm/parameters/ecm_parameters.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pybamm diff --git a/pybamm/parameters/electrical_parameters.py b/pybamm/parameters/electrical_parameters.py index 946c47f53b..5a43ba0c92 100644 --- a/pybamm/parameters/electrical_parameters.py +++ b/pybamm/parameters/electrical_parameters.py @@ -1,7 +1,10 @@ # # Standard electrical parameters # +from __future__ import annotations + import pybamm + from .base_parameters import BaseParameters diff --git a/pybamm/parameters/geometric_parameters.py b/pybamm/parameters/geometric_parameters.py index ecc52e30f1..6a54d75c0b 100644 --- a/pybamm/parameters/geometric_parameters.py +++ b/pybamm/parameters/geometric_parameters.py @@ -1,7 +1,10 @@ # # Geometric Parameters # +from __future__ import annotations + import pybamm + from .base_parameters import BaseParameters diff --git a/pybamm/parameters/lead_acid_parameters.py b/pybamm/parameters/lead_acid_parameters.py index 7da6a19410..33996f57a1 100644 --- a/pybamm/parameters/lead_acid_parameters.py +++ b/pybamm/parameters/lead_acid_parameters.py @@ -1,8 +1,10 @@ # # Standard parameters for lead-acid battery models # +from __future__ import annotations import pybamm + from .base_parameters import BaseParameters, NullParameters diff --git a/pybamm/parameters/lithium_ion_parameters.py b/pybamm/parameters/lithium_ion_parameters.py index 3fbef57803..bd644bf68d 100644 --- a/pybamm/parameters/lithium_ion_parameters.py +++ b/pybamm/parameters/lithium_ion_parameters.py @@ -1,7 +1,10 @@ # # Standard parameters for lithium-ion battery models # +from __future__ import annotations + import pybamm + from .base_parameters import BaseParameters, NullParameters diff --git a/pybamm/parameters/parameter_sets.py b/pybamm/parameters/parameter_sets.py index 7a517af418..0c025d5574 100644 --- a/pybamm/parameters/parameter_sets.py +++ b/pybamm/parameters/parameter_sets.py @@ -1,7 +1,9 @@ -import sys -import warnings +from __future__ import annotations + import importlib.metadata +import sys import textwrap +import warnings from collections.abc import Mapping from typing import Callable diff --git a/pybamm/parameters/parameter_values.py b/pybamm/parameters/parameter_values.py index 85c8f02b53..5c2550a364 100644 --- a/pybamm/parameters/parameter_values.py +++ b/pybamm/parameters/parameter_values.py @@ -1,11 +1,15 @@ # # Parameter values for a simulation # -import numpy as np -import pybamm +from __future__ import annotations + import numbers -from pprint import pformat from collections import defaultdict +from pprint import pformat + +import numpy as np + +import pybamm class ParameterValues: @@ -93,8 +97,9 @@ def create_from_bpx(filename, target_soc=1): if target_soc < 0 or target_soc > 1: raise ValueError("Target SOC should be between 0 and 1") - from bpx import parse_bpx_file, get_electrode_concentrations + from bpx import get_electrode_concentrations, parse_bpx_file from bpx.schema import ElectrodeBlended, ElectrodeBlendedSPM + from .bpx import _bpx_to_param_dict # parse bpx diff --git a/pybamm/parameters/process_parameter_data.py b/pybamm/parameters/process_parameter_data.py index 03b3c2b54d..edcc489567 100644 --- a/pybamm/parameters/process_parameter_data.py +++ b/pybamm/parameters/process_parameter_data.py @@ -1,5 +1,8 @@ -import os +from __future__ import annotations + import json +import os + import numpy as np diff --git a/pybamm/parameters/size_distribution_parameters.py b/pybamm/parameters/size_distribution_parameters.py index 60383fff50..c6701fcd32 100644 --- a/pybamm/parameters/size_distribution_parameters.py +++ b/pybamm/parameters/size_distribution_parameters.py @@ -2,9 +2,12 @@ # Helper function for adding particle-size distribution parameter values # to a parameter set # -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + def get_size_distribution_parameters( param, diff --git a/pybamm/parameters/thermal_parameters.py b/pybamm/parameters/thermal_parameters.py index 8e92ff8d34..b14184b197 100644 --- a/pybamm/parameters/thermal_parameters.py +++ b/pybamm/parameters/thermal_parameters.py @@ -1,7 +1,10 @@ # # Standard thermal parameters # +from __future__ import annotations + import pybamm + from .base_parameters import BaseParameters diff --git a/pybamm/plotting/dynamic_plot.py b/pybamm/plotting/dynamic_plot.py index 4cde0d3972..5879f8e443 100644 --- a/pybamm/plotting/dynamic_plot.py +++ b/pybamm/plotting/dynamic_plot.py @@ -1,6 +1,8 @@ # # Method for creating a dynamic plot # +from __future__ import annotations + import pybamm diff --git a/pybamm/plotting/plot.py b/pybamm/plotting/plot.py index cf5c972a87..daf6e0120f 100644 --- a/pybamm/plotting/plot.py +++ b/pybamm/plotting/plot.py @@ -1,10 +1,13 @@ # # Method for creating a 1D plot of pybamm arrays # +from __future__ import annotations + import pybamm -from .quick_plot import ax_min, ax_max from pybamm.util import have_optional_dependency +from .quick_plot import ax_max, ax_min + def plot(x, y, ax=None, show_plot=True, **kwargs): """ diff --git a/pybamm/plotting/plot2D.py b/pybamm/plotting/plot2D.py index a37cd1e2ed..eba0b4931d 100644 --- a/pybamm/plotting/plot2D.py +++ b/pybamm/plotting/plot2D.py @@ -1,10 +1,13 @@ # # Method for creating a filled contour plot of pybamm arrays # +from __future__ import annotations + import pybamm -from .quick_plot import ax_min, ax_max from pybamm.util import have_optional_dependency +from .quick_plot import ax_max, ax_min + def plot2D(x, y, z, ax=None, show_plot=True, **kwargs): """ diff --git a/pybamm/plotting/plot_summary_variables.py b/pybamm/plotting/plot_summary_variables.py index 33642c4d5a..b9edaec030 100644 --- a/pybamm/plotting/plot_summary_variables.py +++ b/pybamm/plotting/plot_summary_variables.py @@ -1,7 +1,10 @@ # # Method for plotting/comparing summary variables # +from __future__ import annotations + import numpy as np + import pybamm from pybamm.util import have_optional_dependency diff --git a/pybamm/plotting/plot_voltage_components.py b/pybamm/plotting/plot_voltage_components.py index 3b155b71de..6bf9322b13 100644 --- a/pybamm/plotting/plot_voltage_components.py +++ b/pybamm/plotting/plot_voltage_components.py @@ -1,11 +1,13 @@ # # Method for plotting voltage components # +from __future__ import annotations + import numpy as np -from pybamm.util import have_optional_dependency from pybamm.simulation import Simulation from pybamm.solvers.solution import Solution +from pybamm.util import have_optional_dependency def plot_voltage_components( diff --git a/pybamm/plotting/quick_plot.py b/pybamm/plotting/quick_plot.py index c6d3054abb..73de9bd7d6 100644 --- a/pybamm/plotting/quick_plot.py +++ b/pybamm/plotting/quick_plot.py @@ -1,10 +1,14 @@ # # Class for quick plotting of variables from models # +from __future__ import annotations + import os +from collections import defaultdict + import numpy as np + import pybamm -from collections import defaultdict from pybamm.util import have_optional_dependency @@ -125,7 +129,7 @@ def __init__( # Set colors, linestyles, figsize, axis limits # call LoopList to make sure list index never runs out if colors is None: - self.colors = LoopList(colors or ["r", "b", "k", "g", "m", "c"]) + self.colors = LoopList(["r", "b", "k", "g", "m", "c"]) else: self.colors = LoopList(colors) self.linestyles = LoopList(linestyles or ["-", ":", "--", "-."]) diff --git a/pybamm/settings.py b/pybamm/settings.py index 2ccd9bcd13..1778b0c711 100644 --- a/pybamm/settings.py +++ b/pybamm/settings.py @@ -1,6 +1,7 @@ # # Settings class for PyBaMM # +from __future__ import annotations class Settings: diff --git a/pybamm/simulation.py b/pybamm/simulation.py index c1d62a47e9..40a147edc9 100644 --- a/pybamm/simulation.py +++ b/pybamm/simulation.py @@ -3,17 +3,18 @@ # from __future__ import annotations -import pickle -import pybamm -import numpy as np import hashlib -import warnings +import pickle import sys -from functools import lru_cache +import warnings from datetime import timedelta -from pybamm.util import have_optional_dependency +from functools import lru_cache + +import numpy as np +import pybamm from pybamm.expression_tree.operations.serialise import Serialise +from pybamm.util import have_optional_dependency def is_notebook(): diff --git a/pybamm/solvers/algebraic_solver.py b/pybamm/solvers/algebraic_solver.py index d241d5b24c..72e6f20411 100644 --- a/pybamm/solvers/algebraic_solver.py +++ b/pybamm/solvers/algebraic_solver.py @@ -1,12 +1,15 @@ # # Algebraic solver class # +from __future__ import annotations + import casadi -import pybamm import numpy as np from scipy import optimize from scipy.sparse import issparse +import pybamm + class AlgebraicSolver(pybamm.BaseSolver): """Solve a discretised model which contains only (time independent) algebraic diff --git a/pybamm/solvers/base_solver.py b/pybamm/solvers/base_solver.py index 69de3be968..ff34904ea5 100644 --- a/pybamm/solvers/base_solver.py +++ b/pybamm/solvers/base_solver.py @@ -1,9 +1,10 @@ # # Base solver class # +from __future__ import annotations + import copy import itertools -from scipy.sparse import block_diag import multiprocessing as mp import numbers import sys @@ -11,6 +12,7 @@ import casadi import numpy as np +from scipy.sparse import block_diag import pybamm from pybamm.expression_tree.binary_operators import _Heaviside diff --git a/pybamm/solvers/casadi_algebraic_solver.py b/pybamm/solvers/casadi_algebraic_solver.py index ec7305906a..5ce71a7830 100644 --- a/pybamm/solvers/casadi_algebraic_solver.py +++ b/pybamm/solvers/casadi_algebraic_solver.py @@ -1,10 +1,13 @@ # # Casadi algebraic solver class # +from __future__ import annotations + import casadi -import pybamm import numpy as np +import pybamm + class CasadiAlgebraicSolver(pybamm.BaseSolver): """Solve a discretised model which contains only (time independent) algebraic diff --git a/pybamm/solvers/casadi_solver.py b/pybamm/solvers/casadi_solver.py index 02ff4a2cd9..ed0a35bfa2 100644 --- a/pybamm/solvers/casadi_solver.py +++ b/pybamm/solvers/casadi_solver.py @@ -1,11 +1,16 @@ # # CasADi Solver class # +from __future__ import annotations + +import warnings + import casadi -import pybamm import numpy as np -import warnings from scipy.interpolate import interp1d + +import pybamm + from .lrudict import LRUDict diff --git a/pybamm/solvers/dummy_solver.py b/pybamm/solvers/dummy_solver.py index c98667293d..5babfec3d5 100644 --- a/pybamm/solvers/dummy_solver.py +++ b/pybamm/solvers/dummy_solver.py @@ -1,9 +1,12 @@ # # Dummy solver class, for empty models # -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + class DummySolver(pybamm.BaseSolver): """Dummy solver class for empty models.""" diff --git a/pybamm/solvers/idaklu_jax.py b/pybamm/solvers/idaklu_jax.py index a213eb41fa..fd1a260328 100644 --- a/pybamm/solvers/idaklu_jax.py +++ b/pybamm/solvers/idaklu_jax.py @@ -1,16 +1,16 @@ -import pybamm -import numpy as np +from __future__ import annotations + +import importlib +import importlib.util import logging -import warnings import numbers - +import warnings +from functools import lru_cache from typing import Union -from typing import List -from functools import lru_cache +import numpy as np -import importlib.util -import importlib +import pybamm logger = logging.getLogger("pybamm.solvers.idaklu_jax") @@ -27,9 +27,7 @@ import jax from jax import lax from jax import numpy as jnp - from jax.interpreters import ad - from jax.interpreters import mlir - from jax.interpreters import batching + from jax.interpreters import ad, batching, mlir from jax.interpreters.mlir import custom_call from jax.lib import xla_client from jax.tree_util import tree_flatten @@ -273,9 +271,9 @@ def f_isolated(*args, **kwargs): def jax_value( self, - t: np.ndarray = None, - inputs: Union[dict, None] = None, - output_variables: Union[List[str], None] = None, + t: np.ndarray | None = None, + inputs: dict | None = None, + output_variables: list[str] | None = None, ): """Helper function to compute the gradient of a jaxified expression @@ -306,9 +304,9 @@ def jax_value( def jax_grad( self, - t: np.ndarray = None, - inputs: Union[dict, None] = None, - output_variables: Union[List[str], None] = None, + t: np.ndarray | None = None, + inputs: dict | None = None, + output_variables: list[str] | None = None, ): """Helper function to compute the gradient of a jaxified expression @@ -489,7 +487,7 @@ def _jax_vjp_impl( if t.ndim == 0 or (t.ndim == 1 and t.shape[0] == 1): # scalar time input logger.debug("scalar time") - y_dot = jnp.zeros_like(t) + y_dot: jax.Array | np.ndarray = jnp.zeros_like(t) js = self._jaxify_solve(t, invar, *inputs) if js.ndim == 0: js = jnp.array([js]) diff --git a/pybamm/solvers/idaklu_solver.py b/pybamm/solvers/idaklu_solver.py index e9976fc28c..dc786f87e3 100644 --- a/pybamm/solvers/idaklu_solver.py +++ b/pybamm/solvers/idaklu_solver.py @@ -2,13 +2,16 @@ # Solver class using sundials with the KLU sparse linear solver # # mypy: ignore-errors +from __future__ import annotations + +import importlib +import numbers + import casadi -import pybamm import numpy as np -import numbers import scipy.sparse as sparse -import importlib +import pybamm idaklu_spec = importlib.util.find_spec("pybamm.solvers.idaklu") if idaklu_spec is not None: diff --git a/pybamm/solvers/jax_bdf_solver.py b/pybamm/solvers/jax_bdf_solver.py index 2c7bdc6d17..a53753242a 100644 --- a/pybamm/solvers/jax_bdf_solver.py +++ b/pybamm/solvers/jax_bdf_solver.py @@ -1,4 +1,6 @@ # mypy: ignore-errors +from __future__ import annotations + import collections import operator as op from functools import partial @@ -11,8 +13,8 @@ import jax import jax.numpy as jnp from jax import core, dtypes - from jax.extend import linear_util as lu from jax.api_util import flatten_fun_nokwargs + from jax.extend import linear_util as lu from jax.flatten_util import ravel_pytree from jax.interpreters import partial_eval as pe from jax.tree_util import tree_flatten, tree_map, tree_unflatten diff --git a/pybamm/solvers/jax_solver.py b/pybamm/solvers/jax_solver.py index 6c89bed4dd..147a826e15 100644 --- a/pybamm/solvers/jax_solver.py +++ b/pybamm/solvers/jax_solver.py @@ -1,9 +1,12 @@ # # Solver class using Scipy's adaptive time stepper # -import numpy as onp +from __future__ import annotations + import asyncio +import numpy as onp + import pybamm if pybamm.have_jax(): diff --git a/pybamm/solvers/lrudict.py b/pybamm/solvers/lrudict.py index 733dda9850..f38f2d3f69 100644 --- a/pybamm/solvers/lrudict.py +++ b/pybamm/solvers/lrudict.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from collections import OrderedDict diff --git a/pybamm/solvers/processed_variable.py b/pybamm/solvers/processed_variable.py index d33d6894dd..75752b4c56 100644 --- a/pybamm/solvers/processed_variable.py +++ b/pybamm/solvers/processed_variable.py @@ -1,11 +1,14 @@ # # Processed Variable class # +from __future__ import annotations + import casadi import numpy as np -import pybamm -from scipy.integrate import cumulative_trapezoid import xarray as xr +from scipy.integrate import cumulative_trapezoid + +import pybamm class ProcessedVariable: diff --git a/pybamm/solvers/processed_variable_computed.py b/pybamm/solvers/processed_variable_computed.py index fd17dfab7b..0d7fb5d273 100644 --- a/pybamm/solvers/processed_variable_computed.py +++ b/pybamm/solvers/processed_variable_computed.py @@ -1,11 +1,14 @@ # # Processed Variable class # +from __future__ import annotations + import casadi import numpy as np -import pybamm -from scipy.integrate import cumulative_trapezoid import xarray as xr +from scipy.integrate import cumulative_trapezoid + +import pybamm class ProcessedVariableComputed: diff --git a/pybamm/solvers/scikits_dae_solver.py b/pybamm/solvers/scikits_dae_solver.py index c942e8ccd7..8b9d4b5151 100644 --- a/pybamm/solvers/scikits_dae_solver.py +++ b/pybamm/solvers/scikits_dae_solver.py @@ -2,13 +2,16 @@ # Solver class using Scipy's adaptive time stepper # # mypy: ignore-errors -import casadi -import pybamm +from __future__ import annotations -import numpy as np import importlib + +import casadi +import numpy as np import scipy.sparse as sparse +import pybamm + scikits_odes_spec = importlib.util.find_spec("scikits") if scikits_odes_spec is not None: scikits_odes_spec = importlib.util.find_spec("scikits.odes") diff --git a/pybamm/solvers/scikits_ode_solver.py b/pybamm/solvers/scikits_ode_solver.py index f3a4232da9..1d3e17b188 100644 --- a/pybamm/solvers/scikits_ode_solver.py +++ b/pybamm/solvers/scikits_ode_solver.py @@ -2,13 +2,16 @@ # Solver class using Scipy's adaptive time stepper # # mypy: ignore-errors -import casadi -import pybamm +from __future__ import annotations -import numpy as np import importlib + +import casadi +import numpy as np import scipy.sparse as sparse +import pybamm + scikits_odes_spec = importlib.util.find_spec("scikits") if scikits_odes_spec is not None: scikits_odes_spec = importlib.util.find_spec("scikits.odes") diff --git a/pybamm/solvers/scipy_solver.py b/pybamm/solvers/scipy_solver.py index fb320f558d..9b783245a4 100644 --- a/pybamm/solvers/scipy_solver.py +++ b/pybamm/solvers/scipy_solver.py @@ -1,11 +1,13 @@ # # Solver class using Scipy's adaptive time stepper # -import casadi -import pybamm +from __future__ import annotations -import scipy.integrate as it +import casadi import numpy as np +import scipy.integrate as it + +import pybamm class ScipySolver(pybamm.BaseSolver): diff --git a/pybamm/solvers/solution.py b/pybamm/solvers/solution.py index a3b3e9e6ef..0dfb8ef780 100644 --- a/pybamm/solvers/solution.py +++ b/pybamm/solvers/solution.py @@ -1,15 +1,19 @@ # # Solution class # -import casadi +from __future__ import annotations + import json import numbers -import numpy as np import pickle -import pybamm +from functools import cached_property + +import casadi +import numpy as np import pandas as pd from scipy.io import savemat -from functools import cached_property + +import pybamm class NumpyEncoder(json.JSONEncoder): diff --git a/pybamm/spatial_methods/finite_volume.py b/pybamm/spatial_methods/finite_volume.py index 11313a1450..9eeb119fe9 100644 --- a/pybamm/spatial_methods/finite_volume.py +++ b/pybamm/spatial_methods/finite_volume.py @@ -1,20 +1,22 @@ # # Finite Volume discretisation class # -import pybamm +from __future__ import annotations +import numpy as np from scipy.sparse import ( + coo_matrix, + csr_matrix, diags, - spdiags, eye, - kron, - csr_matrix, - vstack, hstack, + kron, lil_matrix, - coo_matrix, + spdiags, + vstack, ) -import numpy as np + +import pybamm class FiniteVolume(pybamm.SpatialMethod): diff --git a/pybamm/spatial_methods/scikit_finite_element.py b/pybamm/spatial_methods/scikit_finite_element.py index 07a3c0e1be..6fa71bde11 100644 --- a/pybamm/spatial_methods/scikit_finite_element.py +++ b/pybamm/spatial_methods/scikit_finite_element.py @@ -1,12 +1,13 @@ # # Finite Element discretisation class which uses scikit-fem # -import pybamm +from __future__ import annotations -from scipy.sparse import csr_matrix, csc_matrix -from scipy.sparse.linalg import inv import numpy as np +from scipy.sparse import csc_matrix, csr_matrix +from scipy.sparse.linalg import inv +import pybamm from pybamm.util import have_optional_dependency diff --git a/pybamm/spatial_methods/spatial_method.py b/pybamm/spatial_methods/spatial_method.py index a461d6c150..caa5f5cb3a 100644 --- a/pybamm/spatial_methods/spatial_method.py +++ b/pybamm/spatial_methods/spatial_method.py @@ -1,9 +1,12 @@ # # A general spatial method class # -import pybamm +from __future__ import annotations + import numpy as np -from scipy.sparse import eye, kron, coo_matrix, csr_matrix, vstack +from scipy.sparse import coo_matrix, csr_matrix, eye, kron, vstack + +import pybamm class SpatialMethod: diff --git a/pybamm/spatial_methods/spectral_volume.py b/pybamm/spatial_methods/spectral_volume.py index 50e1cadf25..b583d85373 100644 --- a/pybamm/spatial_methods/spectral_volume.py +++ b/pybamm/spatial_methods/spectral_volume.py @@ -1,8 +1,9 @@ -import pybamm +from __future__ import annotations import numpy as np +from scipy.sparse import coo_matrix, csr_matrix, diags, eye, kron, lil_matrix, vstack -from scipy.sparse import diags, eye, kron, csr_matrix, lil_matrix, coo_matrix, vstack +import pybamm class SpectralVolume(pybamm.FiniteVolume): diff --git a/pybamm/spatial_methods/zero_dimensional_method.py b/pybamm/spatial_methods/zero_dimensional_method.py index 6e0a414dae..131c9e8a79 100644 --- a/pybamm/spatial_methods/zero_dimensional_method.py +++ b/pybamm/spatial_methods/zero_dimensional_method.py @@ -1,9 +1,12 @@ # # Spatial method for zero dimensional meshes # -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + class ZeroDimensionalSpatialMethod(pybamm.SpatialMethod): """ diff --git a/pybamm/type_definitions.py b/pybamm/type_definitions.py index c3d0a56faa..83d217de0f 100644 --- a/pybamm/type_definitions.py +++ b/pybamm/type_definitions.py @@ -3,9 +3,11 @@ # from __future__ import annotations -from typing import Union, List, Dict -from typing_extensions import TypeAlias +from typing import Dict, List, Union + import numpy as np +from typing_extensions import TypeAlias + import pybamm # numbers.Number should not be used for type hints diff --git a/pybamm/util.py b/pybamm/util.py index 1149327cf7..83bf6cf51d 100644 --- a/pybamm/util.py +++ b/pybamm/util.py @@ -4,9 +4,12 @@ # The code in this file is adapted from Pints # (see https://github.com/pints-team/pints) # +from __future__ import annotations + import argparse -import importlib.util +import difflib import importlib.metadata +import importlib.util import numbers import os import pathlib @@ -15,10 +18,10 @@ import sys import timeit from platform import system -import difflib from warnings import warn import numpy as np + import pybamm # Versions of jax and jaxlib compatible with PyBaMM. Note: these are also defined in diff --git a/pybamm/version.py b/pybamm/version.py index 61641b1fbe..8691c227c2 100644 --- a/pybamm/version.py +++ b/pybamm/version.py @@ -1 +1,3 @@ +from __future__ import annotations + __version__ = "24.1" diff --git a/pyproject.toml b/pyproject.toml index 13ea6df786..97b0e2c045 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -185,7 +185,7 @@ extend-exclude = ["__init__.py"] [tool.ruff.lint] extend-select = [ # "B", # flake8-bugbear - # "I", # isort + "I", # isort # "ARG", # flake8-unused-arguments # "C4", # flake8-comprehensions # "ICN", # flake8-import-conventions @@ -219,6 +219,7 @@ ignore = [ "RUF002", # Docstring contains ambiguous "UP007", # For pyupgrade ] +isort.required-imports = ["from __future__ import annotations"] [tool.ruff.lint.per-file-ignores] "tests/*" = ["T20"] @@ -266,13 +267,21 @@ concurrency = ["multiprocessing"] [tool.repo-review] ignore = [ - "PP003" # list wheel as a build-dep + "PP003", # list wheel as a build-dep + "PC160", # codespell + "PC180", # prettier + ] [tool.mypy] ignore_missing_imports = true allow_redefinition = true disable_error_code = ["call-overload", "operator"] +enable_error_code = [ + "ignore-without-code", + "truthy-bool", + "redundant-expr", +] [[tool.mypy.overrides]] module = [ diff --git a/run-tests.py b/run-tests.py index be51c3457d..4997042f31 100755 --- a/run-tests.py +++ b/run-tests.py @@ -5,13 +5,16 @@ # The code in this file is adapted from Pints # (see https://github.com/pints-team/pints) # +from __future__ import annotations + +import argparse import os import shutil -import pybamm +import subprocess import sys -import argparse import unittest -import subprocess + +import pybamm def run_code_tests(executable=False, folder: str = "unit", interpreter="python"): diff --git a/scripts/install_KLU_Sundials.py b/scripts/install_KLU_Sundials.py index 546d7a313c..2e4b1b0027 100755 --- a/scripts/install_KLU_Sundials.py +++ b/scripts/install_KLU_Sundials.py @@ -9,19 +9,20 @@ # repository = "https://github.com/pybamm-team/PyBaMM" # documentation = "https://docs.pybamm.org" # /// -import os -import subprocess -import tarfile +from __future__ import annotations + import argparse -import platform import hashlib +import os +import platform import shutil +import subprocess +import tarfile import urllib.request -from os.path import join, isfile -from urllib.parse import urlparse from concurrent.futures import ThreadPoolExecutor from multiprocessing import cpu_count - +from os.path import isfile, join +from urllib.parse import urlparse SUITESPARSE_VERSION = "6.0.3" SUNDIALS_VERSION = "6.5.0" diff --git a/scripts/update_version.py b/scripts/update_version.py index dfc6b7f32e..594aaaf341 100644 --- a/scripts/update_version.py +++ b/scripts/update_version.py @@ -1,13 +1,14 @@ """ Automatically update the version number """ +from __future__ import annotations import json import os import re from datetime import date -from dateutil.relativedelta import relativedelta +from dateutil.relativedelta import relativedelta import pybamm diff --git a/setup.py b/setup.py index 6b97f73058..217e413427 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,17 @@ -import os -import sys +from __future__ import annotations + import logging +import os import subprocess +import sys from multiprocessing import cpu_count from pathlib import Path from platform import system -import wheel.bdist_wheel as orig -from setuptools import setup, Extension -from setuptools.command.install import install +import wheel.bdist_wheel as orig +from setuptools import Extension, setup from setuptools.command.build_ext import build_ext - +from setuptools.command.install import install default_lib_dir = ( "" if system() == "Windows" else os.path.join(os.getenv("HOME"), ".local") diff --git a/tests/integration/test_experiments.py b/tests/integration/test_experiments.py index 30db3e446c..12b4c34f0e 100644 --- a/tests/integration/test_experiments.py +++ b/tests/integration/test_experiments.py @@ -1,11 +1,15 @@ # # Test some experiments # -from tests import TestCase -import pybamm -import numpy as np +from __future__ import annotations + import unittest +import numpy as np + +import pybamm +from tests import TestCase + class TestExperiments(TestCase): def test_discharge_rest_charge(self): diff --git a/tests/integration/test_models/standard_model_tests.py b/tests/integration/test_models/standard_model_tests.py index 43eba8894e..039b5198a7 100644 --- a/tests/integration/test_models/standard_model_tests.py +++ b/tests/integration/test_models/standard_model_tests.py @@ -1,12 +1,15 @@ # # Standard basic tests for any model # -import pybamm -import tests +from __future__ import annotations -import numpy as np import os +import numpy as np + +import pybamm +import tests + class StandardModelTest: """Basic processing test for the models.""" diff --git a/tests/integration/test_models/standard_output_comparison.py b/tests/integration/test_models/standard_output_comparison.py index 4d4d16e5ca..86980ff8a2 100644 --- a/tests/integration/test_models/standard_output_comparison.py +++ b/tests/integration/test_models/standard_output_comparison.py @@ -1,9 +1,12 @@ # # Tests comparing model outputs for standard variables # -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + class StandardOutputComparison: """Calls all the tests comparing standard output variables.""" diff --git a/tests/integration/test_models/standard_output_tests.py b/tests/integration/test_models/standard_output_tests.py index 83b88c0ff0..bc10234f2c 100644 --- a/tests/integration/test_models/standard_output_tests.py +++ b/tests/integration/test_models/standard_output_tests.py @@ -1,9 +1,12 @@ # # Standard tests on the standard set of model outputs # -import pybamm +from __future__ import annotations + import numpy as np +import pybamm + class StandardOutputTests: """Calls all the tests on the standard output variables.""" diff --git a/tests/integration/test_models/test_full_battery_models/test_equivalent_circuit/test_thevenin.py b/tests/integration/test_models/test_full_battery_models/test_equivalent_circuit/test_thevenin.py index 54530222cf..c9e1a90d9c 100644 --- a/tests/integration/test_models/test_full_battery_models/test_equivalent_circuit/test_thevenin.py +++ b/tests/integration/test_models/test_full_battery_models/test_equivalent_circuit/test_thevenin.py @@ -1,5 +1,8 @@ -import pybamm +from __future__ import annotations + import unittest + +import pybamm import tests from tests import TestCase diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_asymptotics_convergence.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_asymptotics_convergence.py index c78e7f9223..cf083958e7 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_asymptotics_convergence.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_asymptotics_convergence.py @@ -1,12 +1,15 @@ # # Tests for the asymptotic convergence of the simplified models # -from tests import TestCase -import pybamm +from __future__ import annotations -import numpy as np import unittest +import numpy as np + +import pybamm +from tests import TestCase + class TestAsymptoticConvergence(TestCase): def test_leading_order_convergence(self): diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_compare_basic_models.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_compare_basic_models.py index 76099c1f5b..484321255d 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_compare_basic_models.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_compare_basic_models.py @@ -1,12 +1,15 @@ # # Compare basic models with full models # -from tests import TestCase -import pybamm +from __future__ import annotations -import numpy as np import unittest +import numpy as np + +import pybamm +from tests import TestCase + class TestCompareBasicModels(TestCase): def test_compare_full(self): diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_compare_outputs.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_compare_outputs.py index 1bca3bf7ee..02a9f60b76 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_compare_outputs.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_compare_outputs.py @@ -1,11 +1,14 @@ # # Tests for the asymptotic convergence of the simplified models # -from tests import TestCase -import pybamm -import numpy as np +from __future__ import annotations + import unittest -from tests import StandardOutputComparison + +import numpy as np + +import pybamm +from tests import StandardOutputComparison, TestCase class TestCompareOutputs(TestCase): diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_full.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_full.py index 640b3da5f6..88001ee811 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_full.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_full.py @@ -1,13 +1,16 @@ # # Tests for the lead-acid Full model # -from tests import TestCase -import pybamm -import tests +from __future__ import annotations import unittest + import numpy as np +import pybamm +import tests +from tests import TestCase + class TestLeadAcidFull(TestCase): def test_basic_processing(self): diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_loqs.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_loqs.py index f800aa0a4e..58df701b2a 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_loqs.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_loqs.py @@ -1,13 +1,16 @@ # # Tests for the lead-acid LOQS model # -from tests import TestCase -import pybamm -import tests +from __future__ import annotations import unittest + import numpy as np +import pybamm +import tests +from tests import TestCase + class TestLOQS(TestCase): def test_basic_processing(self): diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_loqs_surface_form.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_loqs_surface_form.py index b646031907..52723ff16f 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_loqs_surface_form.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_loqs_surface_form.py @@ -1,14 +1,16 @@ # # Tests for the lead-acid LOQS model with capacitance # -from tests import TestCase -import pybamm -import tests +from __future__ import annotations import unittest import numpy as np +import pybamm +import tests +from tests import TestCase + class TestLeadAcidLoqsSurfaceForm(TestCase): def test_basic_processing(self): diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_full_side_reactions.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_full_side_reactions.py index 41bd47dd4b..8c14983572 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_full_side_reactions.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_full_side_reactions.py @@ -1,13 +1,16 @@ # # Tests for the lead-acid Full model # -from tests import TestCase -import pybamm -import tests +from __future__ import annotations import unittest + import numpy as np +import pybamm +import tests +from tests import TestCase + class TestLeadAcidFullSideReactions(TestCase): def test_basic_processing(self): diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_loqs_side_reactions.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_loqs_side_reactions.py index 501689af69..2d3f09b1cf 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_loqs_side_reactions.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_loqs_side_reactions.py @@ -1,10 +1,13 @@ # # Tests for the lead-acid LOQS model # -from tests import TestCase +from __future__ import annotations + +import unittest + import pybamm import tests -import unittest +from tests import TestCase class TestLeadAcidLOQSWithSideReactions(TestCase): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py index 5dc5b2dc94..c223c1d22e 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py @@ -1,8 +1,10 @@ # # Base integration tests for lithium-ion half-cell battery models. # -import tests +from __future__ import annotations + import pybamm +import tests class BaseIntegrationTestLithiumIonHalfCell: diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py index 4db5ddea61..de374fd41a 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py @@ -1,11 +1,13 @@ # # Base integration tests for lithium-ion models # -import pybamm -import tests +from __future__ import annotations import numpy as np +import pybamm +import tests + class BaseIntegrationTestLithiumIon: def run_basic_processing_test(self, options, **kwargs): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_basic_half_cell_models.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_basic_half_cell_models.py index 0d69fbae28..a0c9881b6b 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_basic_half_cell_models.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_basic_half_cell_models.py @@ -1,12 +1,15 @@ # # Test basic half-cell model with different parameter values # -from tests import TestCase -import pybamm +from __future__ import annotations -import numpy as np import unittest +import numpy as np + +import pybamm +from tests import TestCase + class TestBasicHalfCellModels(TestCase): def test_runs_Xu2019(self): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_compare_basic_models.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_compare_basic_models.py index 58d6f1c202..0fd6aac30d 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_compare_basic_models.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_compare_basic_models.py @@ -1,12 +1,15 @@ # # Compare basic models with full models # -from tests import TestCase -import pybamm +from __future__ import annotations -import numpy as np import unittest +import numpy as np + +import pybamm +from tests import TestCase + class TestCompareBasicModels(TestCase): def test_compare_dfns(self): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_compare_outputs.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_compare_outputs.py index 136350fe65..2cc5274a28 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_compare_outputs.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_compare_outputs.py @@ -1,11 +1,14 @@ # # Tests for the surface formulation # -from tests import TestCase -import pybamm -import numpy as np +from __future__ import annotations + import unittest -from tests import StandardOutputComparison + +import numpy as np + +import pybamm +from tests import StandardOutputComparison, TestCase class TestCompareOutputs(TestCase): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_compare_outputs_two_phase.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_compare_outputs_two_phase.py index b82c726e75..c6057d254e 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_compare_outputs_two_phase.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_compare_outputs_two_phase.py @@ -1,9 +1,13 @@ # # Tests for the surface formulation # -import pybamm -import numpy as np +from __future__ import annotations + import unittest + +import numpy as np + +import pybamm from tests import TestCase diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py index 083e3b648b..b56d015ef6 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py @@ -1,12 +1,15 @@ # # Tests for the lithium-ion DFN model # -from tests import TestCase +from __future__ import annotations + +import unittest + +import numpy as np + import pybamm import tests -import numpy as np -import unittest -from tests import BaseIntegrationTestLithiumIon +from tests import BaseIntegrationTestLithiumIon, TestCase class TestDFN(BaseIntegrationTestLithiumIon, TestCase): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_dfn_half_cell.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_dfn_half_cell.py index 8e5b0ae0a5..93188e93aa 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_dfn_half_cell.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_dfn_half_cell.py @@ -1,10 +1,12 @@ # # Tests for the lithium-ion DFN half-cell model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest -from tests import BaseIntegrationTestLithiumIonHalfCell + +import pybamm +from tests import BaseIntegrationTestLithiumIonHalfCell, TestCase class TestDFNHalfCell(BaseIntegrationTestLithiumIonHalfCell, TestCase): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_external/test_external_temperature.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_external/test_external_temperature.py index e03a38cfe9..aacb90677a 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_external/test_external_temperature.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_external/test_external_temperature.py @@ -1,11 +1,15 @@ # # Tests for inputting a temperature profile # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest + import numpy as np +import pybamm +from tests import TestCase + class TestInputLumpedTemperature(TestCase): def test_input_lumped_temperature(self): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_initial_soc.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_initial_soc.py index 42973aa9a9..b67e77f1ef 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_initial_soc.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_initial_soc.py @@ -1,10 +1,13 @@ # # Test edge cases for initial SOC # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestInitialSOC(TestCase): def test_interpolant_parameter_sets(self): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_mpm.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_mpm.py index e217a11d75..424b71f2a2 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_mpm.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_mpm.py @@ -1,11 +1,15 @@ # # Tests for the lithium-ion MPM model # -from tests import TestCase +from __future__ import annotations + +import unittest + +import numpy as np + import pybamm import tests -import numpy as np -import unittest +from tests import TestCase class TestMPM(TestCase): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_newman_tobias.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_newman_tobias.py index 44fbaa25d4..9fd61864cd 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_newman_tobias.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_newman_tobias.py @@ -1,10 +1,12 @@ # # Tests for the lithium-ion Newman-Tobias model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest -from tests import BaseIntegrationTestLithiumIon + +import pybamm +from tests import BaseIntegrationTestLithiumIon, TestCase class TestNewmanTobias(BaseIntegrationTestLithiumIon, TestCase): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spm.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spm.py index 6caa1cc3eb..2303654f38 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spm.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spm.py @@ -1,10 +1,12 @@ # # Tests for the lithium-ion SPM model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest -from tests import BaseIntegrationTestLithiumIon + +import pybamm +from tests import BaseIntegrationTestLithiumIon, TestCase class TestSPM(BaseIntegrationTestLithiumIon, TestCase): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spm_half_cell.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spm_half_cell.py index b8b2d2f0dd..0dfe68976a 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spm_half_cell.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spm_half_cell.py @@ -1,10 +1,12 @@ # # Tests for the half-cell lithium-ion SPM model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest -from tests import BaseIntegrationTestLithiumIonHalfCell + +import pybamm +from tests import BaseIntegrationTestLithiumIonHalfCell, TestCase class TestSPMHalfCell(BaseIntegrationTestLithiumIonHalfCell, TestCase): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py index 7ab4dc12ec..0bfde70c67 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py @@ -1,10 +1,12 @@ # # Tests for the lithium-ion SPMe model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest -from tests import BaseIntegrationTestLithiumIon + +import pybamm +from tests import BaseIntegrationTestLithiumIon, TestCase class TestSPMe(BaseIntegrationTestLithiumIon, TestCase): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme_half_cell.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme_half_cell.py index c8098ff3d4..9fbb04f01c 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme_half_cell.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme_half_cell.py @@ -1,10 +1,12 @@ # # Tests for the half-cell lithium-ion SPMe model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest -from tests import BaseIntegrationTestLithiumIonHalfCell + +import pybamm +from tests import BaseIntegrationTestLithiumIonHalfCell, TestCase class TestSPMeHalfCell(BaseIntegrationTestLithiumIonHalfCell, TestCase): diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_thermal_models.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_thermal_models.py index 4d2f50e8d5..900529b526 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_thermal_models.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_thermal_models.py @@ -2,9 +2,13 @@ # Tests for the thermal lithium-ion models produce consistent # thermal response # -import pybamm -import numpy as np +from __future__ import annotations + import unittest + +import numpy as np + +import pybamm from tests import TestCase diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_yang2017.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_yang2017.py index ae4208117f..c652efd385 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_yang2017.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_yang2017.py @@ -1,5 +1,8 @@ -import pybamm +from __future__ import annotations + import unittest + +import pybamm import tests from tests import TestCase diff --git a/tests/integration/test_models/test_submodels/test_external_circuit/test_function_control.py b/tests/integration/test_models/test_submodels/test_external_circuit/test_function_control.py index 8909367892..d5ddd0a7dd 100644 --- a/tests/integration/test_models/test_submodels/test_external_circuit/test_function_control.py +++ b/tests/integration/test_models/test_submodels/test_external_circuit/test_function_control.py @@ -1,10 +1,14 @@ # # Test function control submodel # -from tests import TestCase +from __future__ import annotations + +import unittest + import numpy as np + import pybamm -import unittest +from tests import TestCase class TestFunctionControl(TestCase): diff --git a/tests/integration/test_models/test_submodels/test_interface/test_butler_volmer.py b/tests/integration/test_models/test_submodels/test_interface/test_butler_volmer.py index 536573bad1..4711604d9a 100644 --- a/tests/integration/test_models/test_submodels/test_interface/test_butler_volmer.py +++ b/tests/integration/test_models/test_submodels/test_interface/test_butler_volmer.py @@ -1,13 +1,15 @@ # # Tests for the electrode-electrolyte interface equations # -from tests import TestCase -import pybamm -from tests import get_discretisation_for_testing +from __future__ import annotations import unittest + import numpy as np +import pybamm +from tests import TestCase, get_discretisation_for_testing + class TestButlerVolmer(TestCase): def setUp(self): diff --git a/tests/integration/test_models/test_submodels/test_interface/test_lead_acid.py b/tests/integration/test_models/test_submodels/test_interface/test_lead_acid.py index daf05ff6ca..66a97077e1 100644 --- a/tests/integration/test_models/test_submodels/test_interface/test_lead_acid.py +++ b/tests/integration/test_models/test_submodels/test_interface/test_lead_acid.py @@ -1,11 +1,13 @@ # # Tests for the electrode-electrolyte interface equations for lead-acid models # -from tests import TestCase -import pybamm -from tests import get_discretisation_for_testing +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase, get_discretisation_for_testing + class TestMainReaction(TestCase): def setUp(self): diff --git a/tests/integration/test_models/test_submodels/test_interface/test_lithium_ion.py b/tests/integration/test_models/test_submodels/test_interface/test_lithium_ion.py index 90d27e2de7..cdb2e44937 100644 --- a/tests/integration/test_models/test_submodels/test_interface/test_lithium_ion.py +++ b/tests/integration/test_models/test_submodels/test_interface/test_lithium_ion.py @@ -1,13 +1,15 @@ # # Tests for the electrode-electrolyte interface equations for lithium-ion models # -from tests import TestCase -import pybamm -from tests import get_discretisation_for_testing +from __future__ import annotations import unittest + import numpy as np +import pybamm +from tests import TestCase, get_discretisation_for_testing + class TestExchangeCurrentDensity(TestCase): def setUp(self): diff --git a/tests/integration/test_solvers/test_idaklu.py b/tests/integration/test_solvers/test_idaklu.py index eecc5dfe2b..eb8c3e5dce 100644 --- a/tests/integration/test_solvers/test_idaklu.py +++ b/tests/integration/test_solvers/test_idaklu.py @@ -1,9 +1,13 @@ -import pybamm -import numpy as np +from __future__ import annotations + import sys -from tests import TestCase import unittest +import numpy as np + +import pybamm +from tests import TestCase + @unittest.skipIf(not pybamm.have_idaklu(), "idaklu solver is not installed") class TestIDAKLUSolver(TestCase): diff --git a/tests/integration/test_solvers/test_solution.py b/tests/integration/test_solvers/test_solution.py index d45df9fd4c..77a3ad9421 100644 --- a/tests/integration/test_solvers/test_solution.py +++ b/tests/integration/test_solvers/test_solution.py @@ -1,11 +1,15 @@ # # Tests for the Solution class # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest + import numpy as np +import pybamm +from tests import TestCase + class TestSolution(TestCase): def test_append(self): diff --git a/tests/integration/test_spatial_methods/test_finite_volume.py b/tests/integration/test_spatial_methods/test_finite_volume.py index 2f9f6ef1b0..9467c32d59 100644 --- a/tests/integration/test_spatial_methods/test_finite_volume.py +++ b/tests/integration/test_spatial_methods/test_finite_volume.py @@ -1,17 +1,20 @@ # # Test for the operator class # -from tests import TestCase +from __future__ import annotations + +import unittest + +import numpy as np + import pybamm from tests import ( + TestCase, + get_cylindrical_mesh_for_testing, get_mesh_for_testing, get_p2d_mesh_for_testing, - get_cylindrical_mesh_for_testing, ) -import numpy as np -import unittest - class TestFiniteVolumeConvergence(TestCase): def test_grad_div_broadcast(self): diff --git a/tests/integration/test_spatial_methods/test_spectral_volume.py b/tests/integration/test_spatial_methods/test_spectral_volume.py index 4b998cb0ed..f0255284ef 100644 --- a/tests/integration/test_spatial_methods/test_spectral_volume.py +++ b/tests/integration/test_spatial_methods/test_spectral_volume.py @@ -1,12 +1,15 @@ # # Test for the operator class # -from tests import TestCase -import pybamm +from __future__ import annotations -import numpy as np import unittest +import numpy as np + +import pybamm +from tests import TestCase + def get_mesh_for_testing( xpts=None, rpts=10, ypts=15, zpts=15, geometry=None, cc_submesh=None, order=2 diff --git a/tests/shared.py b/tests/shared.py index 1f0b033582..5868e611d8 100644 --- a/tests/shared.py +++ b/tests/shared.py @@ -1,9 +1,12 @@ # # Shared methods and classes for testing # -import pybamm +from __future__ import annotations + from scipy.sparse import eye +import pybamm + class SpatialMethodForTesting(pybamm.SpatialMethod): """Identity operators, no boundary conditions.""" diff --git a/tests/testcase.py b/tests/testcase.py index ae4019bcb3..a184869278 100644 --- a/tests/testcase.py +++ b/tests/testcase.py @@ -1,10 +1,13 @@ # # Custom TestCase class for pybamm # -import unittest +from __future__ import annotations + import hashlib +import unittest from functools import wraps from types import FunctionType + import numpy as np diff --git a/tests/unit/test_batch_study.py b/tests/unit/test_batch_study.py index 3471914417..017bfcfacd 100644 --- a/tests/unit/test_batch_study.py +++ b/tests/unit/test_batch_study.py @@ -1,13 +1,15 @@ """ Tests for the batch_study.py """ +from __future__ import annotations -from tests import TestCase import os -import pybamm import unittest from tempfile import TemporaryDirectory +import pybamm +from tests import TestCase + spm = pybamm.lithium_ion.SPM() spm_uniform = pybamm.lithium_ion.SPM({"particle": "uniform profile"}) casadi_safe = pybamm.CasadiSolver(mode="safe") diff --git a/tests/unit/test_callbacks.py b/tests/unit/test_callbacks.py index b36fef9ec6..46bf5006a5 100644 --- a/tests/unit/test_callbacks.py +++ b/tests/unit/test_callbacks.py @@ -1,11 +1,14 @@ # # Tests the citations class. # -from tests import TestCase -import pybamm -import unittest +from __future__ import annotations + import os +import unittest + +import pybamm from pybamm import callbacks +from tests import TestCase class DummyCallback(callbacks.Callback): diff --git a/tests/unit/test_citations.py b/tests/unit/test_citations.py index d8c1de3718..b711657945 100644 --- a/tests/unit/test_citations.py +++ b/tests/unit/test_citations.py @@ -1,15 +1,19 @@ # # Tests the citations class. # -import pybamm -import os +from __future__ import annotations + +import contextlib import io +import os import unittest -import contextlib import warnings -from pybtex.database import Entry from tempfile import NamedTemporaryFile +from pybtex.database import Entry + +import pybamm + @contextlib.contextmanager def temporary_filename(): diff --git a/tests/unit/test_discretisations/test_discretisation.py b/tests/unit/test_discretisations/test_discretisation.py index 48795c9318..eb7b26682d 100644 --- a/tests/unit/test_discretisations/test_discretisation.py +++ b/tests/unit/test_discretisations/test_discretisation.py @@ -1,22 +1,24 @@ # # Tests for the base model class # -from tests import TestCase -import pybamm +from __future__ import annotations -import numpy as np import unittest + +import numpy as np +from scipy.sparse import block_diag, csc_matrix +from scipy.sparse.linalg import inv + +import pybamm from tests import ( - get_mesh_for_testing, - get_discretisation_for_testing, + TestCase, get_1p1d_discretisation_for_testing, get_2p1d_mesh_for_testing, + get_discretisation_for_testing, + get_mesh_for_testing, ) from tests.shared import SpatialMethodForTesting -from scipy.sparse import block_diag, csc_matrix -from scipy.sparse.linalg import inv - class TestDiscretise(TestCase): def test_concatenate_in_order(self): diff --git a/tests/unit/test_doc_utils.py b/tests/unit/test_doc_utils.py index a7a4a1e5d5..e60c058fd6 100644 --- a/tests/unit/test_doc_utils.py +++ b/tests/unit/test_doc_utils.py @@ -2,12 +2,14 @@ # Unit tests for doc_utils. These do not test how the actual documentation # is generated, but rather that the docstrings are correctly modified # +from __future__ import annotations -import pybamm import unittest -from tests import TestCase from inspect import getmro + +import pybamm from pybamm.doc_utils import copy_parameter_doc_from_parent, doc_extend_parent +from tests import TestCase class TestDocUtils(TestCase): diff --git a/tests/unit/test_experiments/test_experiment.py b/tests/unit/test_experiments/test_experiment.py index 151b9658c2..430a79297e 100644 --- a/tests/unit/test_experiments/test_experiment.py +++ b/tests/unit/test_experiments/test_experiment.py @@ -1,10 +1,13 @@ # # Test the base experiment class # -from tests import TestCase +from __future__ import annotations + +import unittest from datetime import datetime + import pybamm -import unittest +from tests import TestCase class TestExperiment(TestCase): diff --git a/tests/unit/test_experiments/test_experiment_step_termination.py b/tests/unit/test_experiments/test_experiment_step_termination.py index ee45bcc9f8..ec96639122 100644 --- a/tests/unit/test_experiments/test_experiment_step_termination.py +++ b/tests/unit/test_experiments/test_experiment_step_termination.py @@ -1,9 +1,12 @@ # # Test the experiment step termination classes # -import pybamm +from __future__ import annotations + import unittest +import pybamm + class TestExperimentStepTermination(unittest.TestCase): def test_base_termination(self): diff --git a/tests/unit/test_experiments/test_experiment_steps.py b/tests/unit/test_experiments/test_experiment_steps.py index 7fc21bc14f..e356376982 100644 --- a/tests/unit/test_experiments/test_experiment_steps.py +++ b/tests/unit/test_experiments/test_experiment_steps.py @@ -1,10 +1,14 @@ # # Test the experiment steps # -import pybamm +from __future__ import annotations + import unittest -import numpy as np from datetime import datetime + +import numpy as np + +import pybamm from pybamm.experiment.step import _Step diff --git a/tests/unit/test_experiments/test_simulation_with_experiment.py b/tests/unit/test_experiments/test_simulation_with_experiment.py index c48b464b18..0f67ffc26f 100644 --- a/tests/unit/test_experiments/test_simulation_with_experiment.py +++ b/tests/unit/test_experiments/test_simulation_with_experiment.py @@ -1,14 +1,18 @@ # # Test setting up a simulation with an experiment # -from tests import TestCase -import casadi -import pybamm -import numpy as np +from __future__ import annotations + import os import unittest from datetime import datetime +import casadi +import numpy as np + +import pybamm +from tests import TestCase + class TestSimulationExperiment(TestCase): def test_set_up(self): diff --git a/tests/unit/test_expression_tree/test_array.py b/tests/unit/test_expression_tree/test_array.py index b75c313f47..73f62e8ed4 100644 --- a/tests/unit/test_expression_tree/test_array.py +++ b/tests/unit/test_expression_tree/test_array.py @@ -1,7 +1,8 @@ # # Tests for the Array class # -from tests import TestCase +from __future__ import annotations + import unittest import unittest.mock as mock @@ -9,6 +10,7 @@ import sympy import pybamm +from tests import TestCase class TestArray(TestCase): diff --git a/tests/unit/test_expression_tree/test_averages.py b/tests/unit/test_expression_tree/test_averages.py index 1351ee3c05..2a7fdb14d8 100644 --- a/tests/unit/test_expression_tree/test_averages.py +++ b/tests/unit/test_expression_tree/test_averages.py @@ -1,10 +1,14 @@ # # Tests for the Unary Operator classes # +from __future__ import annotations + import unittest -from tests import TestCase + import numpy as np + import pybamm +from tests import TestCase class TestUnaryOperators(TestCase): diff --git a/tests/unit/test_expression_tree/test_binary_operators.py b/tests/unit/test_expression_tree/test_binary_operators.py index b6cbe093eb..41bea34969 100644 --- a/tests/unit/test_expression_tree/test_binary_operators.py +++ b/tests/unit/test_expression_tree/test_binary_operators.py @@ -1,7 +1,8 @@ # # Tests for the Binary Operator classes # -from tests import TestCase +from __future__ import annotations + import unittest import unittest.mock as mock @@ -10,6 +11,7 @@ import pybamm from pybamm.util import have_optional_dependency +from tests import TestCase EMPTY_DOMAINS = { "primary": [], diff --git a/tests/unit/test_expression_tree/test_broadcasts.py b/tests/unit/test_expression_tree/test_broadcasts.py index be8fe1a677..49a59a9027 100644 --- a/tests/unit/test_expression_tree/test_broadcasts.py +++ b/tests/unit/test_expression_tree/test_broadcasts.py @@ -1,11 +1,14 @@ # # Tests for the Broadcast class # +from __future__ import annotations + import unittest -from tests import TestCase + import numpy as np import pybamm +from tests import TestCase class TestBroadcasts(TestCase): diff --git a/tests/unit/test_expression_tree/test_concatenations.py b/tests/unit/test_expression_tree/test_concatenations.py index 691b6a7ee2..e9457c242a 100644 --- a/tests/unit/test_expression_tree/test_concatenations.py +++ b/tests/unit/test_expression_tree/test_concatenations.py @@ -1,15 +1,16 @@ # # Tests for the Concatenation class and subclasses # +from __future__ import annotations + import unittest import unittest.mock as mock -from tests import TestCase import numpy as np import pybamm from pybamm.util import have_optional_dependency -from tests import get_discretisation_for_testing, get_mesh_for_testing +from tests import TestCase, get_discretisation_for_testing, get_mesh_for_testing class TestConcatenations(TestCase): diff --git a/tests/unit/test_expression_tree/test_d_dt.py b/tests/unit/test_expression_tree/test_d_dt.py index b5632f9f64..73eb376337 100644 --- a/tests/unit/test_expression_tree/test_d_dt.py +++ b/tests/unit/test_expression_tree/test_d_dt.py @@ -1,12 +1,15 @@ # # Tests for the Scalar class # -from tests import TestCase -import pybamm +from __future__ import annotations import unittest + import numpy as np +import pybamm +from tests import TestCase + class TestDDT(TestCase): def test_time_derivative(self): diff --git a/tests/unit/test_expression_tree/test_functions.py b/tests/unit/test_expression_tree/test_functions.py index 33e11459ab..f8363fc575 100644 --- a/tests/unit/test_expression_tree/test_functions.py +++ b/tests/unit/test_expression_tree/test_functions.py @@ -1,7 +1,8 @@ # # Tests for the Function classes # -from tests import TestCase +from __future__ import annotations + import unittest import unittest.mock as mock @@ -10,6 +11,7 @@ import pybamm from pybamm.util import have_optional_dependency +from tests import TestCase def test_function(arg): diff --git a/tests/unit/test_expression_tree/test_independent_variable.py b/tests/unit/test_expression_tree/test_independent_variable.py index b748a6fbe9..82830ea892 100644 --- a/tests/unit/test_expression_tree/test_independent_variable.py +++ b/tests/unit/test_expression_tree/test_independent_variable.py @@ -1,12 +1,13 @@ # # Tests for the Parameter class # -from tests import TestCase -import unittest +from __future__ import annotations +import unittest import pybamm from pybamm.util import have_optional_dependency +from tests import TestCase class TestIndependentVariable(TestCase): diff --git a/tests/unit/test_expression_tree/test_input_parameter.py b/tests/unit/test_expression_tree/test_input_parameter.py index a5fc79f2e2..0dd284ddcb 100644 --- a/tests/unit/test_expression_tree/test_input_parameter.py +++ b/tests/unit/test_expression_tree/test_input_parameter.py @@ -1,13 +1,16 @@ # # Tests for the InputParameter class # -from tests import TestCase -import numpy as np -import pybamm -import unittest +from __future__ import annotations +import unittest import unittest.mock as mock +import numpy as np + +import pybamm +from tests import TestCase + class TestInputParameter(TestCase): def test_input_parameter_init(self): diff --git a/tests/unit/test_expression_tree/test_interpolant.py b/tests/unit/test_expression_tree/test_interpolant.py index 1fed2d0239..66aca4d1cf 100644 --- a/tests/unit/test_expression_tree/test_interpolant.py +++ b/tests/unit/test_expression_tree/test_interpolant.py @@ -1,13 +1,16 @@ # # Tests for the Function classes # -from tests import TestCase -import pybamm +from __future__ import annotations import unittest import unittest.mock as mock + import numpy as np +import pybamm +from tests import TestCase + class TestInterpolant(TestCase): def test_errors(self): diff --git a/tests/unit/test_expression_tree/test_matrix.py b/tests/unit/test_expression_tree/test_matrix.py index 055902b15e..0694a70166 100644 --- a/tests/unit/test_expression_tree/test_matrix.py +++ b/tests/unit/test_expression_tree/test_matrix.py @@ -1,14 +1,17 @@ # # Tests for the Matrix class # -from tests import TestCase -import pybamm -import numpy as np -from scipy.sparse import csr_matrix +from __future__ import annotations import unittest import unittest.mock as mock +import numpy as np +from scipy.sparse import csr_matrix + +import pybamm +from tests import TestCase + class TestMatrix(TestCase): def setUp(self): diff --git a/tests/unit/test_expression_tree/test_operations/test_convert_to_casadi.py b/tests/unit/test_expression_tree/test_operations/test_convert_to_casadi.py index db50ac8c92..d16805a7a9 100644 --- a/tests/unit/test_expression_tree/test_operations/test_convert_to_casadi.py +++ b/tests/unit/test_expression_tree/test_operations/test_convert_to_casadi.py @@ -1,14 +1,17 @@ # # Test for the Simplify class # -from tests import TestCase +from __future__ import annotations + +import unittest + import casadi import numpy as np -import pybamm -import unittest -from tests import get_mesh_for_testing, get_1p1d_discretisation_for_testing from scipy import special +import pybamm +from tests import TestCase, get_1p1d_discretisation_for_testing, get_mesh_for_testing + class TestCasadiConverter(TestCase): def assert_casadi_equal(self, a, b, evalf=False): diff --git a/tests/unit/test_expression_tree/test_operations/test_copy.py b/tests/unit/test_expression_tree/test_operations/test_copy.py index 6800f9092f..894fe6d75c 100644 --- a/tests/unit/test_expression_tree/test_operations/test_copy.py +++ b/tests/unit/test_expression_tree/test_operations/test_copy.py @@ -1,11 +1,14 @@ # # Test for making copies # -from tests import TestCase +from __future__ import annotations + +import unittest + import numpy as np + import pybamm -import unittest -from tests import get_mesh_for_testing +from tests import TestCase, get_mesh_for_testing class TestCopy(TestCase): diff --git a/tests/unit/test_expression_tree/test_operations/test_evaluate_python.py b/tests/unit/test_expression_tree/test_operations/test_evaluate_python.py index 552e79bc7e..9b7e16caf7 100644 --- a/tests/unit/test_expression_tree/test_operations/test_evaluate_python.py +++ b/tests/unit/test_expression_tree/test_operations/test_evaluate_python.py @@ -1,14 +1,20 @@ # # Test for the evaluate-to-python functions # -from tests import TestCase -import pybamm +from __future__ import annotations -from tests import get_discretisation_for_testing, get_1p1d_discretisation_for_testing import unittest +from collections import OrderedDict + import numpy as np import scipy.sparse -from collections import OrderedDict + +import pybamm +from tests import ( + TestCase, + get_1p1d_discretisation_for_testing, + get_discretisation_for_testing, +) if pybamm.have_jax(): import jax diff --git a/tests/unit/test_expression_tree/test_operations/test_jac.py b/tests/unit/test_expression_tree/test_operations/test_jac.py index d3572cafdc..0eb3829982 100644 --- a/tests/unit/test_expression_tree/test_operations/test_jac.py +++ b/tests/unit/test_expression_tree/test_operations/test_jac.py @@ -1,13 +1,15 @@ # # Tests for the jacobian methods # -from tests import TestCase -import pybamm +from __future__ import annotations -import numpy as np import unittest + +import numpy as np from scipy.sparse import eye -from tests import get_mesh_for_testing + +import pybamm +from tests import TestCase, get_mesh_for_testing def test_multi_var_function(arg1, arg2): diff --git a/tests/unit/test_expression_tree/test_operations/test_jac_2D.py b/tests/unit/test_expression_tree/test_operations/test_jac_2D.py index 5dafef1309..af6f8641e2 100644 --- a/tests/unit/test_expression_tree/test_operations/test_jac_2D.py +++ b/tests/unit/test_expression_tree/test_operations/test_jac_2D.py @@ -1,13 +1,15 @@ # # Tests for the jacobian methods for two-dimensional objects # -from tests import TestCase -import pybamm +from __future__ import annotations -import numpy as np import unittest + +import numpy as np from scipy.sparse import eye -from tests import get_1p1d_discretisation_for_testing + +import pybamm +from tests import TestCase, get_1p1d_discretisation_for_testing def test_multi_var_function(arg1, arg2): diff --git a/tests/unit/test_expression_tree/test_operations/test_latexify.py b/tests/unit/test_expression_tree/test_operations/test_latexify.py index 7e0703534e..9bf4217b99 100644 --- a/tests/unit/test_expression_tree/test_operations/test_latexify.py +++ b/tests/unit/test_expression_tree/test_operations/test_latexify.py @@ -1,13 +1,15 @@ """ Tests for the latexify.py """ -from tests import TestCase +from __future__ import annotations + import os import platform import unittest import uuid import pybamm +from tests import TestCase class TestLatexify(TestCase): diff --git a/tests/unit/test_expression_tree/test_operations/test_unpack_symbols.py b/tests/unit/test_expression_tree/test_operations/test_unpack_symbols.py index ce669212ae..572da35445 100644 --- a/tests/unit/test_expression_tree/test_operations/test_unpack_symbols.py +++ b/tests/unit/test_expression_tree/test_operations/test_unpack_symbols.py @@ -1,10 +1,13 @@ # # Tests for the symbol unpacker # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestSymbolUnpacker(TestCase): def test_basic_symbols(self): diff --git a/tests/unit/test_expression_tree/test_parameter.py b/tests/unit/test_expression_tree/test_parameter.py index 6940ac38fe..d11c5d7737 100644 --- a/tests/unit/test_expression_tree/test_parameter.py +++ b/tests/unit/test_expression_tree/test_parameter.py @@ -1,12 +1,14 @@ # # Tests for the Parameter class # -from tests import TestCase +from __future__ import annotations + import numbers import unittest import pybamm from pybamm.util import have_optional_dependency +from tests import TestCase class TestParameter(TestCase): diff --git a/tests/unit/test_expression_tree/test_printing/test_print_name.py b/tests/unit/test_expression_tree/test_printing/test_print_name.py index 554e6567f1..d7ca55373e 100644 --- a/tests/unit/test_expression_tree/test_printing/test_print_name.py +++ b/tests/unit/test_expression_tree/test_printing/test_print_name.py @@ -1,10 +1,12 @@ """ Tests for the print_name.py """ -from tests import TestCase +from __future__ import annotations + import unittest import pybamm +from tests import TestCase class TestPrintName(TestCase): diff --git a/tests/unit/test_expression_tree/test_printing/test_sympy_overrides.py b/tests/unit/test_expression_tree/test_printing/test_sympy_overrides.py index de3ff08c43..c9d13699ac 100644 --- a/tests/unit/test_expression_tree/test_printing/test_sympy_overrides.py +++ b/tests/unit/test_expression_tree/test_printing/test_sympy_overrides.py @@ -1,12 +1,14 @@ """ Tests for the sympy_overrides.py """ -from tests import TestCase +from __future__ import annotations + import unittest import pybamm from pybamm.expression_tree.printing.sympy_overrides import custom_print_func from pybamm.util import have_optional_dependency +from tests import TestCase class TestCustomPrint(TestCase): diff --git a/tests/unit/test_expression_tree/test_scalar.py b/tests/unit/test_expression_tree/test_scalar.py index 34ea1aa514..175c37a15b 100644 --- a/tests/unit/test_expression_tree/test_scalar.py +++ b/tests/unit/test_expression_tree/test_scalar.py @@ -1,11 +1,13 @@ # # Tests for the Scalar class # -from tests import TestCase +from __future__ import annotations + import unittest import unittest.mock as mock import pybamm +from tests import TestCase class TestScalar(TestCase): diff --git a/tests/unit/test_expression_tree/test_state_vector.py b/tests/unit/test_expression_tree/test_state_vector.py index 18025c0aa3..a9eedaf5b7 100644 --- a/tests/unit/test_expression_tree/test_state_vector.py +++ b/tests/unit/test_expression_tree/test_state_vector.py @@ -1,13 +1,16 @@ # # Tests for the State Vector class # -from tests import TestCase -import pybamm -import numpy as np +from __future__ import annotations import unittest import unittest.mock as mock +import numpy as np + +import pybamm +from tests import TestCase + class TestStateVector(TestCase): def test_evaluate(self): diff --git a/tests/unit/test_expression_tree/test_symbol.py b/tests/unit/test_expression_tree/test_symbol.py index 9a7939c66d..522030a2e1 100644 --- a/tests/unit/test_expression_tree/test_symbol.py +++ b/tests/unit/test_expression_tree/test_symbol.py @@ -1,18 +1,20 @@ # # Test for the Symbol class # -from tests import TestCase +from __future__ import annotations + import os import unittest import unittest.mock as mock from tempfile import TemporaryDirectory import numpy as np -from scipy.sparse import csr_matrix, coo_matrix +from scipy.sparse import coo_matrix, csr_matrix import pybamm from pybamm.expression_tree.binary_operators import _Heaviside from pybamm.util import have_optional_dependency +from tests import TestCase class TestSymbol(TestCase): diff --git a/tests/unit/test_expression_tree/test_symbolic_diff.py b/tests/unit/test_expression_tree/test_symbolic_diff.py index a6493b66ce..0bfafbd47b 100644 --- a/tests/unit/test_expression_tree/test_symbolic_diff.py +++ b/tests/unit/test_expression_tree/test_symbolic_diff.py @@ -1,12 +1,16 @@ # # Tests for the symbolic differentiation methods # -from tests import TestCase -import numpy as np -import pybamm +from __future__ import annotations + import unittest + +import numpy as np from numpy import testing +import pybamm +from tests import TestCase + class TestSymbolicDifferentiation(TestCase): def test_advanced(self): diff --git a/tests/unit/test_expression_tree/test_unary_operators.py b/tests/unit/test_expression_tree/test_unary_operators.py index 6ae6b62d05..004405fb75 100644 --- a/tests/unit/test_expression_tree/test_unary_operators.py +++ b/tests/unit/test_expression_tree/test_unary_operators.py @@ -1,8 +1,9 @@ # # Tests for the Unary Operator classes # +from __future__ import annotations + import unittest -from tests import TestCase import unittest.mock as mock import numpy as np @@ -10,6 +11,7 @@ import pybamm from pybamm.util import have_optional_dependency +from tests import TestCase class TestUnaryOperators(TestCase): diff --git a/tests/unit/test_expression_tree/test_variable.py b/tests/unit/test_expression_tree/test_variable.py index 0d5aa251d2..e1da416922 100644 --- a/tests/unit/test_expression_tree/test_variable.py +++ b/tests/unit/test_expression_tree/test_variable.py @@ -1,13 +1,15 @@ # # Tests for the Variable class # -from tests import TestCase +from __future__ import annotations + import unittest import numpy as np import pybamm from pybamm.util import have_optional_dependency +from tests import TestCase class TestVariable(TestCase): diff --git a/tests/unit/test_expression_tree/test_vector.py b/tests/unit/test_expression_tree/test_vector.py index 34f817cf9c..2435688435 100644 --- a/tests/unit/test_expression_tree/test_vector.py +++ b/tests/unit/test_expression_tree/test_vector.py @@ -1,12 +1,15 @@ # # Tests for the Vector class # -from tests import TestCase -import pybamm -import numpy as np +from __future__ import annotations import unittest +import numpy as np + +import pybamm +from tests import TestCase + class TestVector(TestCase): def setUp(self): diff --git a/tests/unit/test_geometry/test_battery_geometry.py b/tests/unit/test_geometry/test_battery_geometry.py index 57d638e5ef..b38b4d927b 100644 --- a/tests/unit/test_geometry/test_battery_geometry.py +++ b/tests/unit/test_geometry/test_battery_geometry.py @@ -1,10 +1,13 @@ # # Tests for the base model class # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestBatteryGeometry(TestCase): def test_geometry_keys(self): diff --git a/tests/unit/test_logger.py b/tests/unit/test_logger.py index 0897bc5835..0e9ec43635 100644 --- a/tests/unit/test_logger.py +++ b/tests/unit/test_logger.py @@ -1,10 +1,13 @@ # # Tests the logger class. # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestLogger(TestCase): def test_logger(self): diff --git a/tests/unit/test_meshes/test_meshes.py b/tests/unit/test_meshes/test_meshes.py index 3066d14534..e9bd55ff1b 100644 --- a/tests/unit/test_meshes/test_meshes.py +++ b/tests/unit/test_meshes/test_meshes.py @@ -1,11 +1,15 @@ # # Test for the Finite Volume Mesh class # -from tests import TestCase -import pybamm -import numpy as np +from __future__ import annotations + import unittest +import numpy as np + +import pybamm +from tests import TestCase + def get_param(): return pybamm.ParameterValues( diff --git a/tests/unit/test_meshes/test_one_dimensional_submesh.py b/tests/unit/test_meshes/test_one_dimensional_submesh.py index 514de4248b..18e98a4b35 100644 --- a/tests/unit/test_meshes/test_one_dimensional_submesh.py +++ b/tests/unit/test_meshes/test_one_dimensional_submesh.py @@ -1,6 +1,10 @@ -import pybamm +from __future__ import annotations + import unittest + import numpy as np + +import pybamm from tests import TestCase diff --git a/tests/unit/test_meshes/test_scikit_fem_submesh.py b/tests/unit/test_meshes/test_scikit_fem_submesh.py index 83c0192d30..6e2c00019c 100644 --- a/tests/unit/test_meshes/test_scikit_fem_submesh.py +++ b/tests/unit/test_meshes/test_scikit_fem_submesh.py @@ -1,11 +1,15 @@ # # Test for the scikit-fem Finite Element Mesh class # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest + import numpy as np +import pybamm +from tests import TestCase + def get_param(): return pybamm.ParameterValues( diff --git a/tests/unit/test_meshes/test_zero_dimensional_submesh.py b/tests/unit/test_meshes/test_zero_dimensional_submesh.py index 8bc1bc2e75..b794c03615 100644 --- a/tests/unit/test_meshes/test_zero_dimensional_submesh.py +++ b/tests/unit/test_meshes/test_zero_dimensional_submesh.py @@ -1,5 +1,8 @@ -import pybamm +from __future__ import annotations + import unittest + +import pybamm from tests import TestCase diff --git a/tests/unit/test_models/test_base_model.py b/tests/unit/test_models/test_base_model.py index 538765c48d..94ef1b0040 100644 --- a/tests/unit/test_models/test_base_model.py +++ b/tests/unit/test_models/test_base_model.py @@ -1,7 +1,8 @@ # # Tests for the base model class # -from tests import TestCase +from __future__ import annotations + import os import platform import subprocess # nosec @@ -12,6 +13,7 @@ from numpy import testing import pybamm +from tests import TestCase class TestBaseModel(TestCase): diff --git a/tests/unit/test_models/test_event.py b/tests/unit/test_models/test_event.py index 84b0dcde84..f7d6d7dbe4 100644 --- a/tests/unit/test_models/test_event.py +++ b/tests/unit/test_models/test_event.py @@ -1,11 +1,15 @@ # # Tests Event class # -from tests import TestCase -import pybamm -import numpy as np +from __future__ import annotations + import unittest +import numpy as np + +import pybamm +from tests import TestCase + class TestEvent(TestCase): def test_event(self): diff --git a/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py b/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py index c56cd2304c..00e6fa5402 100644 --- a/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py +++ b/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py @@ -1,13 +1,16 @@ # # Tests for the base battery model class # -from tests import TestCase -from pybamm.models.full_battery_models.base_battery_model import BatteryModelOptions -import pybamm -import unittest +from __future__ import annotations + import io -from contextlib import redirect_stdout import os +import unittest +from contextlib import redirect_stdout + +import pybamm +from pybamm.models.full_battery_models.base_battery_model import BatteryModelOptions +from tests import TestCase OPTIONS_DICT = { "surface form": "differential", diff --git a/tests/unit/test_models/test_full_battery_models/test_equivalent_circuit/test_thevenin.py b/tests/unit/test_models/test_full_battery_models/test_equivalent_circuit/test_thevenin.py index 95365fb42b..57583fc852 100644 --- a/tests/unit/test_models/test_full_battery_models/test_equivalent_circuit/test_thevenin.py +++ b/tests/unit/test_models/test_full_battery_models/test_equivalent_circuit/test_thevenin.py @@ -1,10 +1,13 @@ # # Tests for the Thevenin equivalant circuit model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestThevenin(TestCase): def test_standard_model(self): diff --git a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_base_lead_acid_model.py b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_base_lead_acid_model.py index ec280cdd1f..5b904f2d68 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_base_lead_acid_model.py +++ b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_base_lead_acid_model.py @@ -1,10 +1,13 @@ # # Tests for the base lead acid model class # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestBaseLeadAcidModel(TestCase): def test_default_geometry(self): diff --git a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_basic_models.py b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_basic_models.py index 65b9f6bc9f..c52bcdc248 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_basic_models.py +++ b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_basic_models.py @@ -1,10 +1,13 @@ # # Tests for the basic lead acid models # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestBasicModels(TestCase): def test_basic_full_lead_acid_well_posed(self): diff --git a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_full.py b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_full.py index c07c5c84c6..e00d313bcb 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_full.py +++ b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_full.py @@ -1,10 +1,13 @@ # # Tests for the lead-acid Full model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestLeadAcidFull(TestCase): def test_well_posed(self): diff --git a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_loqs.py b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_loqs.py index c20626856b..94bbef4719 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_loqs.py +++ b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_loqs.py @@ -1,10 +1,13 @@ # # Tests for the lead-acid LOQS model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestLeadAcidLOQS(TestCase): def test_well_posed(self): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py index 24ccd55d79..1a904c660d 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py @@ -2,6 +2,7 @@ # Base unit tests for lithium-ion half-cell models # This is achieved by using the {"working electrdode": "positive"} option # +from __future__ import annotations class BaseUnitTestLithiumIonHalfCell: diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py index de7d2bfe83..9e8814912b 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py @@ -1,6 +1,8 @@ # # Base unit tests for the lithium-ion models # +from __future__ import annotations + import pybamm diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_Yang2017.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_Yang2017.py index 9631cf9f82..aaefeeaea0 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_Yang2017.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_Yang2017.py @@ -1,10 +1,13 @@ # # Tests for the lithium-ion DFN model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestYang2017(TestCase): def test_well_posed(self): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_base_lithium_ion_model.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_base_lithium_ion_model.py index fbc916d4a5..f40df5ed56 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_base_lithium_ion_model.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_base_lithium_ion_model.py @@ -1,10 +1,13 @@ # # Tests for the base lead acid model class # -from tests import TestCase -import pybamm -import unittest +from __future__ import annotations + import os +import unittest + +import pybamm +from tests import TestCase class TestBaseLithiumIonModel(TestCase): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_basic_models.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_basic_models.py index f2f5a5ef40..879aa7dd68 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_basic_models.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_basic_models.py @@ -1,10 +1,13 @@ # # Tests for the basic lithium-ion models # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestBasicModels(TestCase): def test_dfn_well_posed(self): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py index d7e95247e0..98218e1ec8 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py @@ -1,10 +1,12 @@ # # Tests for the lithium-ion DFN model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest -from tests import BaseUnitTestLithiumIon + +import pybamm +from tests import BaseUnitTestLithiumIon, TestCase class TestDFN(BaseUnitTestLithiumIon, TestCase): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_dfn_half_cell.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_dfn_half_cell.py index 78d9ebda94..d84027577a 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_dfn_half_cell.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_dfn_half_cell.py @@ -1,10 +1,12 @@ # # Tests for the lithium-ion half-cell DFN model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest -from tests import BaseUnitTestLithiumIonHalfCell + +import pybamm +from tests import BaseUnitTestLithiumIonHalfCell, TestCase class TestDFNHalfCell(BaseUnitTestLithiumIonHalfCell, TestCase): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_electrode_soh.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_electrode_soh.py index bebdedd825..584494395b 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_electrode_soh.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_electrode_soh.py @@ -1,10 +1,13 @@ # # Tests for the lithium-ion electrode-specific SOH model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestElectrodeSOH(TestCase): def test_known_solution(self): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_mpm.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_mpm.py index 88049c0c63..08424a9f25 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_mpm.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_mpm.py @@ -1,10 +1,13 @@ # # Tests for the lithium-ion MPM model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestMPM(TestCase): def test_well_posed(self): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_mpm_half_cell.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_mpm_half_cell.py index 77d51f6cf7..eedcf560dd 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_mpm_half_cell.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_mpm_half_cell.py @@ -1,10 +1,13 @@ # # Tests for the lithium-ion MPM model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestMPM(TestCase): def test_well_posed(self): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_msmr.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_msmr.py index 96369fbac2..3570e1b12c 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_msmr.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_msmr.py @@ -1,10 +1,13 @@ # # Tests for the lithium-ion MSMR model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestMSMR(TestCase): def test_well_posed(self): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_newman_tobias.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_newman_tobias.py index 4d65804156..c0c6442220 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_newman_tobias.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_newman_tobias.py @@ -1,10 +1,12 @@ # # Tests for the lithium-ion Newman-Tobias model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest -from tests import BaseUnitTestLithiumIon + +import pybamm +from tests import BaseUnitTestLithiumIon, TestCase class TestNewmanTobias(BaseUnitTestLithiumIon, TestCase): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm.py index 45cf00877b..e9b2f7358b 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm.py @@ -1,10 +1,12 @@ # # Tests for the lithium-ion SPM model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest -from tests import BaseUnitTestLithiumIon + +import pybamm +from tests import BaseUnitTestLithiumIon, TestCase class TestSPM(BaseUnitTestLithiumIon, TestCase): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm_half_cell.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm_half_cell.py index 0d6ba93ce0..5f483f9522 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm_half_cell.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm_half_cell.py @@ -1,10 +1,12 @@ # # Tests for the lithium-ion half-cell SPM model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest -from tests import BaseUnitTestLithiumIonHalfCell + +import pybamm +from tests import BaseUnitTestLithiumIonHalfCell, TestCase class TestSPMHalfCell(BaseUnitTestLithiumIonHalfCell, TestCase): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme.py index 72222ee060..03b992c308 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme.py @@ -1,10 +1,12 @@ # # Tests for the lithium-ion SPMe model # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest -from tests import BaseUnitTestLithiumIon + +import pybamm +from tests import BaseUnitTestLithiumIon, TestCase class TestSPMe(BaseUnitTestLithiumIon, TestCase): diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme_half_cell.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme_half_cell.py index f1930df026..1eb55a3715 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme_half_cell.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme_half_cell.py @@ -2,10 +2,12 @@ # Tests for the lithium-ion half-cell SPMe model # This is achieved by using the {"working electrode": "positive"} option # -import pybamm +from __future__ import annotations + import unittest -from tests import TestCase -from tests import BaseUnitTestLithiumIonHalfCell + +import pybamm +from tests import BaseUnitTestLithiumIonHalfCell, TestCase class TestSPMeHalfCell(BaseUnitTestLithiumIonHalfCell, TestCase): diff --git a/tests/unit/test_models/test_model_info.py b/tests/unit/test_models/test_model_info.py index 144d763bf1..79150101fa 100644 --- a/tests/unit/test_models/test_model_info.py +++ b/tests/unit/test_models/test_model_info.py @@ -1,10 +1,13 @@ # # Tests getting model info # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestModelInfo(TestCase): def test_find_parameter_info(self): diff --git a/tests/unit/test_models/test_submodels/test_base_submodel.py b/tests/unit/test_models/test_submodels/test_base_submodel.py index 1519a2fea2..1e26b7ba8a 100644 --- a/tests/unit/test_models/test_submodels/test_base_submodel.py +++ b/tests/unit/test_models/test_submodels/test_base_submodel.py @@ -1,11 +1,13 @@ # # Test base submodel # -from tests import TestCase +from __future__ import annotations -import pybamm import unittest +import pybamm +from tests import TestCase + class TestBaseSubModel(TestCase): def test_domain(self): diff --git a/tests/unit/test_models/test_submodels/test_effective_current_collector.py b/tests/unit/test_models/test_submodels/test_effective_current_collector.py index cbab3134d4..c118c152a8 100644 --- a/tests/unit/test_models/test_submodels/test_effective_current_collector.py +++ b/tests/unit/test_models/test_submodels/test_effective_current_collector.py @@ -1,11 +1,15 @@ # # Tests for the Effective Current Collector Resistance models # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest + import numpy as np +import pybamm +from tests import TestCase + class TestEffectiveResistance(TestCase): def test_well_posed(self): diff --git a/tests/unit/test_models/test_submodels/test_particle_polynomial_profile.py b/tests/unit/test_models/test_submodels/test_particle_polynomial_profile.py index 787230d9f3..deccd0623d 100644 --- a/tests/unit/test_models/test_submodels/test_particle_polynomial_profile.py +++ b/tests/unit/test_models/test_submodels/test_particle_polynomial_profile.py @@ -1,10 +1,13 @@ # # Tests for the polynomial profile submodel # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestParticlePolynomialProfile(TestCase): def test_errors(self): diff --git a/tests/unit/test_parameters/test_base_parameters.py b/tests/unit/test_parameters/test_base_parameters.py index 11879f01ce..1cdb8a526b 100644 --- a/tests/unit/test_parameters/test_base_parameters.py +++ b/tests/unit/test_parameters/test_base_parameters.py @@ -1,10 +1,13 @@ """ Tests for the base_parameters.py """ -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestBaseParameters(TestCase): def test_getattr__(self): diff --git a/tests/unit/test_parameters/test_bpx.py b/tests/unit/test_parameters/test_bpx.py index dbaa2b36c0..5f1a7104f1 100644 --- a/tests/unit/test_parameters/test_bpx.py +++ b/tests/unit/test_parameters/test_bpx.py @@ -1,13 +1,15 @@ # # Tests for the create_from_bpx function # -from tests import TestCase +from __future__ import annotations +import copy +import json import tempfile import unittest -import json + import pybamm -import copy +from tests import TestCase class TestBPX(TestCase): diff --git a/tests/unit/test_parameters/test_current_functions.py b/tests/unit/test_parameters/test_current_functions.py index 10a311fc2c..436334a002 100644 --- a/tests/unit/test_parameters/test_current_functions.py +++ b/tests/unit/test_parameters/test_current_functions.py @@ -1,14 +1,18 @@ # # Tests for current input functions # -from tests import TestCase -import pybamm +from __future__ import annotations + import numbers +import os import unittest + import numpy as np -import os import pandas as pd +import pybamm +from tests import TestCase + class TestCurrentFunctions(TestCase): def test_constant_current(self): diff --git a/tests/unit/test_parameters/test_ecm_parameters.py b/tests/unit/test_parameters/test_ecm_parameters.py index 4764409e4e..d104607e9b 100644 --- a/tests/unit/test_parameters/test_ecm_parameters.py +++ b/tests/unit/test_parameters/test_ecm_parameters.py @@ -1,10 +1,12 @@ # # Tests for the equivalent circuit parameters # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase values = { "Initial SoC": 0.5, diff --git a/tests/unit/test_parameters/test_electrical_parameters.py b/tests/unit/test_parameters/test_electrical_parameters.py index 92bceaf632..ee72132cec 100644 --- a/tests/unit/test_parameters/test_electrical_parameters.py +++ b/tests/unit/test_parameters/test_electrical_parameters.py @@ -1,11 +1,13 @@ # # Tests for the electrical parameters # -from tests import TestCase -import pybamm +from __future__ import annotations import unittest +import pybamm +from tests import TestCase + class TestElectricalParameters(TestCase): def test_current_functions(self): diff --git a/tests/unit/test_parameters/test_geometric_parameters.py b/tests/unit/test_parameters/test_geometric_parameters.py index 6e59259a12..f277f0d441 100644 --- a/tests/unit/test_parameters/test_geometric_parameters.py +++ b/tests/unit/test_parameters/test_geometric_parameters.py @@ -1,10 +1,13 @@ # # Tests for the standard parameters # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestGeometricParameters(TestCase): def test_macroscale_parameters(self): diff --git a/tests/unit/test_parameters/test_lead_acid_parameters.py b/tests/unit/test_parameters/test_lead_acid_parameters.py index ddc73f61ee..0a2ca814cb 100644 --- a/tests/unit/test_parameters/test_lead_acid_parameters.py +++ b/tests/unit/test_parameters/test_lead_acid_parameters.py @@ -1,12 +1,14 @@ # # Test for the standard lead acid parameters # +from __future__ import annotations + import os -from tests import TestCase -import pybamm -from tests import get_discretisation_for_testing -from tempfile import TemporaryDirectory import unittest +from tempfile import TemporaryDirectory + +import pybamm +from tests import TestCase, get_discretisation_for_testing class TestStandardParametersLeadAcid(TestCase): diff --git a/tests/unit/test_parameters/test_lithium_ion_parameters.py b/tests/unit/test_parameters/test_lithium_ion_parameters.py index 0c46eec16e..049f22ffbf 100644 --- a/tests/unit/test_parameters/test_lithium_ion_parameters.py +++ b/tests/unit/test_parameters/test_lithium_ion_parameters.py @@ -1,13 +1,17 @@ # # Tests lithium-ion parameters load and give expected values # +from __future__ import annotations + import os -from tests import TestCase -import pybamm -from tempfile import TemporaryDirectory import unittest +from tempfile import TemporaryDirectory + import numpy as np +import pybamm +from tests import TestCase + class TestLithiumIonParameterValues(TestCase): def test_print_parameters(self): diff --git a/tests/unit/test_parameters/test_parameter_sets/test_Ai2020.py b/tests/unit/test_parameters/test_parameter_sets/test_Ai2020.py index 8816551ab6..ac1e7ab078 100644 --- a/tests/unit/test_parameters/test_parameter_sets/test_Ai2020.py +++ b/tests/unit/test_parameters/test_parameter_sets/test_Ai2020.py @@ -1,10 +1,13 @@ # # Tests for Ai (2020) Enertech parameter set loads # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestAi2020(TestCase): def test_functions(self): diff --git a/tests/unit/test_parameters/test_parameter_sets/test_Ecker2015.py b/tests/unit/test_parameters/test_parameter_sets/test_Ecker2015.py index f239764743..d49c940db7 100644 --- a/tests/unit/test_parameters/test_parameter_sets/test_Ecker2015.py +++ b/tests/unit/test_parameters/test_parameter_sets/test_Ecker2015.py @@ -1,10 +1,13 @@ # # Tests for O'Kane (2022) parameter set # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestEcker2015(TestCase): def test_functions(self): diff --git a/tests/unit/test_parameters/test_parameter_sets/test_Ecker2015_graphite_halfcell.py b/tests/unit/test_parameters/test_parameter_sets/test_Ecker2015_graphite_halfcell.py index 862ac8295b..a19f8f1cdb 100644 --- a/tests/unit/test_parameters/test_parameter_sets/test_Ecker2015_graphite_halfcell.py +++ b/tests/unit/test_parameters/test_parameter_sets/test_Ecker2015_graphite_halfcell.py @@ -1,10 +1,13 @@ # # Tests for O'Kane (2022) parameter set # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestEcker2015_graphite_halfcell(TestCase): def test_functions(self): diff --git a/tests/unit/test_parameters/test_parameter_sets/test_LCO_Ramadass2004.py b/tests/unit/test_parameters/test_parameter_sets/test_LCO_Ramadass2004.py index 2de67b9e62..f9c959cbb1 100644 --- a/tests/unit/test_parameters/test_parameter_sets/test_LCO_Ramadass2004.py +++ b/tests/unit/test_parameters/test_parameter_sets/test_LCO_Ramadass2004.py @@ -1,10 +1,13 @@ # # Tests for Ai (2020) Enertech parameter set loads # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestRamadass2004(TestCase): def test_functions(self): diff --git a/tests/unit/test_parameters/test_parameter_sets/test_LGM50_ORegan2022.py b/tests/unit/test_parameters/test_parameter_sets/test_LGM50_ORegan2022.py index f878b7d790..fb3703e037 100644 --- a/tests/unit/test_parameters/test_parameter_sets/test_LGM50_ORegan2022.py +++ b/tests/unit/test_parameters/test_parameter_sets/test_LGM50_ORegan2022.py @@ -1,10 +1,13 @@ # # Tests for LG M50 parameter set loads # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestORegan2022(TestCase): def test_functions(self): diff --git a/tests/unit/test_parameters/test_parameter_sets/test_OKane2022.py b/tests/unit/test_parameters/test_parameter_sets/test_OKane2022.py index 1ab7e7930e..d0c7ca3c05 100644 --- a/tests/unit/test_parameters/test_parameter_sets/test_OKane2022.py +++ b/tests/unit/test_parameters/test_parameter_sets/test_OKane2022.py @@ -1,10 +1,13 @@ # # Tests for O'Kane (2022) parameter set # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestOKane2022(TestCase): def test_functions(self): diff --git a/tests/unit/test_parameters/test_parameter_sets/test_OKane2022_negative_halfcell.py b/tests/unit/test_parameters/test_parameter_sets/test_OKane2022_negative_halfcell.py index 04a19e1002..1cf976d089 100644 --- a/tests/unit/test_parameters/test_parameter_sets/test_OKane2022_negative_halfcell.py +++ b/tests/unit/test_parameters/test_parameter_sets/test_OKane2022_negative_halfcell.py @@ -1,10 +1,13 @@ # # Tests for O'Kane (2022) parameter set # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestOKane2022_graphite_SiOx_halfcell(TestCase): def test_functions(self): diff --git a/tests/unit/test_parameters/test_parameter_sets/test_parameters_with_default_models.py b/tests/unit/test_parameters/test_parameter_sets/test_parameters_with_default_models.py index 4e18f1ef50..f727600c44 100644 --- a/tests/unit/test_parameters/test_parameter_sets/test_parameters_with_default_models.py +++ b/tests/unit/test_parameters/test_parameter_sets/test_parameters_with_default_models.py @@ -1,10 +1,13 @@ # # Tests each parameter set with the standard model associated with that parameter set # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestParameterValuesWithModel(TestCase): def test_parameter_values_with_model(self): diff --git a/tests/unit/test_parameters/test_parameter_sets_class.py b/tests/unit/test_parameters/test_parameter_sets_class.py index b14000f987..602d8a7345 100644 --- a/tests/unit/test_parameters/test_parameter_sets_class.py +++ b/tests/unit/test_parameters/test_parameter_sets_class.py @@ -1,11 +1,13 @@ # # Tests for the ParameterSets class # -from tests import TestCase +from __future__ import annotations -import pybamm import unittest +import pybamm +from tests import TestCase + class TestParameterSets(TestCase): def test_name_interface(self): diff --git a/tests/unit/test_parameters/test_parameter_values.py b/tests/unit/test_parameters/test_parameter_values.py index 7b5fd38bf0..96e1225a2d 100644 --- a/tests/unit/test_parameters/test_parameter_values.py +++ b/tests/unit/test_parameters/test_parameter_values.py @@ -1,22 +1,23 @@ # # Tests for the Base Parameter Values class # -from tests import TestCase +from __future__ import annotations import os import unittest +import casadi import numpy as np import pandas as pd import pybamm import tests.shared as shared +from pybamm.expression_tree.exceptions import OptionError from pybamm.input.parameters.lithium_ion.Marquis2019 import ( - lico2_ocp_Dualfoil1998, lico2_diffusivity_Dualfoil1998, + lico2_ocp_Dualfoil1998, ) -from pybamm.expression_tree.exceptions import OptionError -import casadi +from tests import TestCase class TestParameterValues(TestCase): diff --git a/tests/unit/test_parameters/test_process_parameter_data.py b/tests/unit/test_parameters/test_process_parameter_data.py index 22f83a6bdb..ba2490bd70 100644 --- a/tests/unit/test_parameters/test_process_parameter_data.py +++ b/tests/unit/test_parameters/test_process_parameter_data.py @@ -1,13 +1,15 @@ # # Tests for the parameter processing functions # -from tests import TestCase +from __future__ import annotations import os +import unittest + import numpy as np -import pybamm -import unittest +import pybamm +from tests import TestCase class TestProcessParameterData(TestCase): diff --git a/tests/unit/test_parameters/test_size_distribution_parameters.py b/tests/unit/test_parameters/test_size_distribution_parameters.py index 5deeaa62be..c9a4d1795e 100644 --- a/tests/unit/test_parameters/test_size_distribution_parameters.py +++ b/tests/unit/test_parameters/test_size_distribution_parameters.py @@ -2,9 +2,13 @@ # Tests particle size distribution parameters are loaded into a parameter set # and give expected values # -import pybamm +from __future__ import annotations + import unittest + import numpy as np + +import pybamm from tests import TestCase diff --git a/tests/unit/test_plotting/test_plot.py b/tests/unit/test_plotting/test_plot.py index 2b5bb9cb17..e76661578a 100644 --- a/tests/unit/test_plotting/test_plot.py +++ b/tests/unit/test_plotting/test_plot.py @@ -1,8 +1,12 @@ -import pybamm +from __future__ import annotations + import unittest + +import matplotlib.pyplot as plt import numpy as np + +import pybamm from tests import TestCase -import matplotlib.pyplot as plt class TestPlot(TestCase): diff --git a/tests/unit/test_plotting/test_plot_summary_variables.py b/tests/unit/test_plotting/test_plot_summary_variables.py index e896b1f468..3ccae38035 100644 --- a/tests/unit/test_plotting/test_plot_summary_variables.py +++ b/tests/unit/test_plotting/test_plot_summary_variables.py @@ -1,6 +1,10 @@ -import pybamm +from __future__ import annotations + import unittest + import numpy as np + +import pybamm from tests import TestCase diff --git a/tests/unit/test_plotting/test_plot_voltage_components.py b/tests/unit/test_plotting/test_plot_voltage_components.py index 928a15655d..0898b5fae4 100644 --- a/tests/unit/test_plotting/test_plot_voltage_components.py +++ b/tests/unit/test_plotting/test_plot_voltage_components.py @@ -1,8 +1,12 @@ -import pybamm +from __future__ import annotations + import unittest + +import matplotlib.pyplot as plt import numpy as np + +import pybamm from tests import TestCase -import matplotlib.pyplot as plt class TestPlotVoltageComponents(TestCase): diff --git a/tests/unit/test_plotting/test_quick_plot.py b/tests/unit/test_plotting/test_quick_plot.py index 7b3511ed63..2cf122e6d6 100644 --- a/tests/unit/test_plotting/test_quick_plot.py +++ b/tests/unit/test_plotting/test_quick_plot.py @@ -1,10 +1,14 @@ +from __future__ import annotations + import os -import pybamm import unittest -from tests import TestCase -import numpy as np from tempfile import TemporaryDirectory +import numpy as np + +import pybamm +from tests import TestCase + class TestQuickPlot(TestCase): def test_simple_ode_model(self): diff --git a/tests/unit/test_serialisation/test_serialisation.py b/tests/unit/test_serialisation/test_serialisation.py index c0c1bd22cb..1389a08b49 100644 --- a/tests/unit/test_serialisation/test_serialisation.py +++ b/tests/unit/test_serialisation/test_serialisation.py @@ -1,17 +1,20 @@ # # Tests for the serialisation class # -from tests import TestCase +from __future__ import annotations + import json import os import unittest import unittest.mock as mock from datetime import datetime -import numpy as np -import pybamm +import numpy as np from numpy import testing + +import pybamm from pybamm.expression_tree.operations.serialise import Serialise +from tests import TestCase def scalar_var_dict(): diff --git a/tests/unit/test_settings.py b/tests/unit/test_settings.py index a3b62f8ee4..3c58fd4646 100644 --- a/tests/unit/test_settings.py +++ b/tests/unit/test_settings.py @@ -1,10 +1,13 @@ # # Tests the settings class. # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest +import pybamm +from tests import TestCase + class TestSettings(TestCase): def test_simplify(self): diff --git a/tests/unit/test_simulation.py b/tests/unit/test_simulation.py index 734f22eb35..7e4b8a8556 100644 --- a/tests/unit/test_simulation.py +++ b/tests/unit/test_simulation.py @@ -1,13 +1,17 @@ -import pybamm -import numpy as np -import pandas as pd -from tests import TestCase +from __future__ import annotations + import os import sys import unittest import uuid from tempfile import TemporaryDirectory +import numpy as np +import pandas as pd + +import pybamm +from tests import TestCase + class TestSimulation(TestCase): def test_simple_model(self): diff --git a/tests/unit/test_solvers/test_algebraic_solver.py b/tests/unit/test_solvers/test_algebraic_solver.py index 22017f8cf8..96299e640b 100644 --- a/tests/unit/test_solvers/test_algebraic_solver.py +++ b/tests/unit/test_solvers/test_algebraic_solver.py @@ -1,11 +1,14 @@ # # Tests for the Algebraic Solver class # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest + import numpy as np -from tests import get_discretisation_for_testing + +import pybamm +from tests import TestCase, get_discretisation_for_testing class TestAlgebraicSolver(TestCase): diff --git a/tests/unit/test_solvers/test_base_solver.py b/tests/unit/test_solvers/test_base_solver.py index 577e50e68b..312af0cabf 100644 --- a/tests/unit/test_solvers/test_base_solver.py +++ b/tests/unit/test_solvers/test_base_solver.py @@ -1,13 +1,16 @@ # # Tests for the Base Solver class # -from tests import TestCase +from __future__ import annotations + +import unittest + import casadi -import pybamm import numpy as np from scipy.sparse import csr_matrix -import unittest +import pybamm +from tests import TestCase class TestBaseSolver(TestCase): diff --git a/tests/unit/test_solvers/test_casadi_algebraic_solver.py b/tests/unit/test_solvers/test_casadi_algebraic_solver.py index eaf873c5c7..912237cd55 100644 --- a/tests/unit/test_solvers/test_casadi_algebraic_solver.py +++ b/tests/unit/test_solvers/test_casadi_algebraic_solver.py @@ -1,13 +1,17 @@ # # Tests for the Casadi Algebraic Solver class # -from tests import TestCase -import casadi -import pybamm +from __future__ import annotations + import unittest + +import casadi import numpy as np from scipy.optimize import least_squares + +import pybamm import tests +from tests import TestCase class TestCasadiAlgebraicSolver(TestCase): diff --git a/tests/unit/test_solvers/test_casadi_solver.py b/tests/unit/test_solvers/test_casadi_solver.py index 3030f80af0..40ccd676e7 100644 --- a/tests/unit/test_solvers/test_casadi_solver.py +++ b/tests/unit/test_solvers/test_casadi_solver.py @@ -1,13 +1,16 @@ # # Tests for the Casadi Solver class # -from tests import TestCase -import pybamm +from __future__ import annotations + import unittest + import numpy as np -from tests import get_mesh_for_testing, get_discretisation_for_testing from scipy.sparse import eye +import pybamm +from tests import TestCase, get_discretisation_for_testing, get_mesh_for_testing + class TestCasadiSolver(TestCase): def test_bad_mode(self): diff --git a/tests/unit/test_solvers/test_dummy_solver.py b/tests/unit/test_solvers/test_dummy_solver.py index 7c7b9a35f7..36967f3959 100644 --- a/tests/unit/test_solvers/test_dummy_solver.py +++ b/tests/unit/test_solvers/test_dummy_solver.py @@ -1,11 +1,15 @@ # # Tests for the Dummy Solver class # -from tests import TestCase -import pybamm -import numpy as np -import unittest +from __future__ import annotations + import sys +import unittest + +import numpy as np + +import pybamm +from tests import TestCase class TestDummySolver(TestCase): diff --git a/tests/unit/test_solvers/test_idaklu_jax.py b/tests/unit/test_solvers/test_idaklu_jax.py index c2d29c31ae..4c46553e7c 100644 --- a/tests/unit/test_solvers/test_idaklu_jax.py +++ b/tests/unit/test_solvers/test_idaklu_jax.py @@ -1,18 +1,21 @@ # # Tests for the KLU-Jax interface class # -from tests import TestCase +from __future__ import annotations + +import unittest + +import numpy as np from parameterized import parameterized import pybamm -import numpy as np -import unittest +from tests import TestCase testcase = [] if pybamm.have_idaklu() and pybamm.have_jax(): - from jax.tree_util import tree_flatten import jax import jax.numpy as jnp + from jax.tree_util import tree_flatten inputs = { "a": 0.1, diff --git a/tests/unit/test_solvers/test_idaklu_solver.py b/tests/unit/test_solvers/test_idaklu_solver.py index 8423c16b68..9f18482974 100644 --- a/tests/unit/test_solvers/test_idaklu_solver.py +++ b/tests/unit/test_solvers/test_idaklu_solver.py @@ -1,15 +1,16 @@ # # Tests for the KLU Solver class # -from tests import TestCase -from contextlib import redirect_stdout +from __future__ import annotations + import io import unittest +from contextlib import redirect_stdout import numpy as np import pybamm -from tests import get_discretisation_for_testing +from tests import TestCase, get_discretisation_for_testing @unittest.skipIf(not pybamm.have_idaklu(), "idaklu solver is not installed") diff --git a/tests/unit/test_solvers/test_jax_bdf_solver.py b/tests/unit/test_solvers/test_jax_bdf_solver.py index 92fb710ea9..098d647879 100644 --- a/tests/unit/test_solvers/test_jax_bdf_solver.py +++ b/tests/unit/test_solvers/test_jax_bdf_solver.py @@ -1,11 +1,14 @@ -import pybamm -import unittest -from tests import get_mesh_for_testing -from tests import TestCase +from __future__ import annotations + import sys import time +import unittest + import numpy as np +import pybamm +from tests import TestCase, get_mesh_for_testing + if pybamm.have_jax(): import jax diff --git a/tests/unit/test_solvers/test_jax_solver.py b/tests/unit/test_solvers/test_jax_solver.py index c6b482e3f9..a036f878d9 100644 --- a/tests/unit/test_solvers/test_jax_solver.py +++ b/tests/unit/test_solvers/test_jax_solver.py @@ -1,11 +1,14 @@ -import pybamm -import unittest -from tests import get_mesh_for_testing -from tests import TestCase +from __future__ import annotations + import sys import time +import unittest + import numpy as np +import pybamm +from tests import TestCase, get_mesh_for_testing + if pybamm.have_jax(): import jax diff --git a/tests/unit/test_solvers/test_lrudict.py b/tests/unit/test_solvers/test_lrudict.py index a5378da786..bd1c073e32 100644 --- a/tests/unit/test_solvers/test_lrudict.py +++ b/tests/unit/test_solvers/test_lrudict.py @@ -1,10 +1,13 @@ # # Tests for the LRUDict class # +from __future__ import annotations + import unittest -from pybamm.solvers.lrudict import LRUDict from collections import OrderedDict +from pybamm.solvers.lrudict import LRUDict + class TestLRUDict(unittest.TestCase): def test_lrudict_defaultbehaviour(self): diff --git a/tests/unit/test_solvers/test_processed_variable.py b/tests/unit/test_solvers/test_processed_variable.py index d8b4ccfd0c..1cfb71d08f 100644 --- a/tests/unit/test_solvers/test_processed_variable.py +++ b/tests/unit/test_solvers/test_processed_variable.py @@ -1,13 +1,16 @@ # # Tests for the Processed Variable class # -from tests import TestCase +from __future__ import annotations + +import unittest + import casadi +import numpy as np + import pybamm import tests - -import numpy as np -import unittest +from tests import TestCase def to_casadi(var_pybamm, y, inputs=None): diff --git a/tests/unit/test_solvers/test_processed_variable_computed.py b/tests/unit/test_solvers/test_processed_variable_computed.py index b5f105b34b..9b0e649a23 100644 --- a/tests/unit/test_solvers/test_processed_variable_computed.py +++ b/tests/unit/test_solvers/test_processed_variable_computed.py @@ -5,13 +5,16 @@ # by the idaklu solver, and does not possesses any capability to calculate # values itself since it does not have access to the full state vector # -from tests import TestCase +from __future__ import annotations + +import unittest + import casadi +import numpy as np + import pybamm import tests - -import numpy as np -import unittest +from tests import TestCase def to_casadi(var_pybamm, y, inputs=None): diff --git a/tests/unit/test_solvers/test_scikits_solvers.py b/tests/unit/test_solvers/test_scikits_solvers.py index db07678a3d..94a5da4a2d 100644 --- a/tests/unit/test_solvers/test_scikits_solvers.py +++ b/tests/unit/test_solvers/test_scikits_solvers.py @@ -1,13 +1,16 @@ # # Tests for the Scikits Solver classes # -from tests import TestCase -import pybamm -import numpy as np +from __future__ import annotations + +import sys import unittest import warnings -from tests import get_mesh_for_testing, get_discretisation_for_testing -import sys + +import numpy as np + +import pybamm +from tests import TestCase, get_discretisation_for_testing, get_mesh_for_testing @unittest.skipIf(not pybamm.have_scikits_odes(), "scikits.odes not installed") diff --git a/tests/unit/test_solvers/test_scipy_solver.py b/tests/unit/test_solvers/test_scipy_solver.py index fad6651d55..8ee51829f0 100644 --- a/tests/unit/test_solvers/test_scipy_solver.py +++ b/tests/unit/test_solvers/test_scipy_solver.py @@ -1,12 +1,15 @@ # Tests for the Scipy Solver class # -import pybamm -from tests import TestCase +from __future__ import annotations + +import sys import unittest -import numpy as np -from tests import get_mesh_for_testing, get_discretisation_for_testing import warnings -import sys + +import numpy as np + +import pybamm +from tests import TestCase, get_discretisation_for_testing, get_mesh_for_testing class TestScipySolver(TestCase): diff --git a/tests/unit/test_solvers/test_solution.py b/tests/unit/test_solvers/test_solution.py index ecc8d1bd8e..5721a1936e 100644 --- a/tests/unit/test_solvers/test_solution.py +++ b/tests/unit/test_solvers/test_solution.py @@ -1,16 +1,19 @@ # # Tests for the Solution class # -import os -from tests import TestCase +from __future__ import annotations + import json -import pybamm +import os import unittest +from tempfile import TemporaryDirectory + import numpy as np import pandas as pd from scipy.io import loadmat -from tests import get_discretisation_for_testing -from tempfile import TemporaryDirectory + +import pybamm +from tests import TestCase, get_discretisation_for_testing class TestSolution(TestCase): diff --git a/tests/unit/test_spatial_methods/test_base_spatial_method.py b/tests/unit/test_spatial_methods/test_base_spatial_method.py index d48ea69a7b..22e5a9a293 100644 --- a/tests/unit/test_spatial_methods/test_base_spatial_method.py +++ b/tests/unit/test_spatial_methods/test_base_spatial_method.py @@ -1,13 +1,17 @@ # # Test for the base Spatial Method class # -from tests import TestCase +from __future__ import annotations + +import unittest + import numpy as np + import pybamm -import unittest from tests import ( - get_mesh_for_testing, + TestCase, get_1p1d_mesh_for_testing, + get_mesh_for_testing, get_size_distribution_mesh_for_testing, ) diff --git a/tests/unit/test_spatial_methods/test_finite_volume/test_extrapolation.py b/tests/unit/test_spatial_methods/test_finite_volume/test_extrapolation.py index 86597e6a1c..e8fdf5f359 100644 --- a/tests/unit/test_spatial_methods/test_finite_volume/test_extrapolation.py +++ b/tests/unit/test_spatial_methods/test_finite_volume/test_extrapolation.py @@ -1,15 +1,19 @@ # # Test for the extrapolations in the finite volume class # -from tests import TestCase +from __future__ import annotations + +import unittest + +import numpy as np + import pybamm from tests import ( + TestCase, + get_1p1d_mesh_for_testing, get_mesh_for_testing, get_p2d_mesh_for_testing, - get_1p1d_mesh_for_testing, ) -import numpy as np -import unittest def errors(pts, function, method_options, bcs=None): diff --git a/tests/unit/test_spatial_methods/test_finite_volume/test_finite_volume.py b/tests/unit/test_spatial_methods/test_finite_volume/test_finite_volume.py index 16a3bbde2c..ca74b52b70 100644 --- a/tests/unit/test_spatial_methods/test_finite_volume/test_finite_volume.py +++ b/tests/unit/test_spatial_methods/test_finite_volume/test_finite_volume.py @@ -1,16 +1,20 @@ # # Tests for the Finite Volume Method # -from tests import TestCase +from __future__ import annotations + +import unittest + +import numpy as np +from scipy.sparse import eye, kron + import pybamm from tests import ( + TestCase, + get_1p1d_mesh_for_testing, get_mesh_for_testing, get_p2d_mesh_for_testing, - get_1p1d_mesh_for_testing, ) -import numpy as np -from scipy.sparse import kron, eye -import unittest class TestFiniteVolume(TestCase): diff --git a/tests/unit/test_spatial_methods/test_finite_volume/test_ghost_nodes_and_neumann.py b/tests/unit/test_spatial_methods/test_finite_volume/test_ghost_nodes_and_neumann.py index 5651a9dd1e..57698e9990 100644 --- a/tests/unit/test_spatial_methods/test_finite_volume/test_ghost_nodes_and_neumann.py +++ b/tests/unit/test_spatial_methods/test_finite_volume/test_ghost_nodes_and_neumann.py @@ -1,12 +1,15 @@ # # Test for adding ghost nodes in finite volumes class # -from tests import TestCase -import pybamm -from tests import get_mesh_for_testing, get_p2d_mesh_for_testing -import numpy as np +from __future__ import annotations + import unittest +import numpy as np + +import pybamm +from tests import TestCase, get_mesh_for_testing, get_p2d_mesh_for_testing + class TestGhostNodes(TestCase): def test_add_ghost_nodes(self): diff --git a/tests/unit/test_spatial_methods/test_finite_volume/test_grad_div_shapes.py b/tests/unit/test_spatial_methods/test_finite_volume/test_grad_div_shapes.py index 24132f5cc1..9ce7750e67 100644 --- a/tests/unit/test_spatial_methods/test_finite_volume/test_grad_div_shapes.py +++ b/tests/unit/test_spatial_methods/test_finite_volume/test_grad_div_shapes.py @@ -1,16 +1,20 @@ # # Test for the gradient and divergence in Finite Volumes # -from tests import TestCase +from __future__ import annotations + +import unittest + +import numpy as np + import pybamm from tests import ( - get_mesh_for_testing, - get_p2d_mesh_for_testing, + TestCase, get_1p1d_mesh_for_testing, get_cylindrical_mesh_for_testing, + get_mesh_for_testing, + get_p2d_mesh_for_testing, ) -import numpy as np -import unittest class TestFiniteVolumeGradDiv(TestCase): diff --git a/tests/unit/test_spatial_methods/test_finite_volume/test_integration.py b/tests/unit/test_spatial_methods/test_finite_volume/test_integration.py index f1908b1238..0995137b46 100644 --- a/tests/unit/test_spatial_methods/test_finite_volume/test_integration.py +++ b/tests/unit/test_spatial_methods/test_finite_volume/test_integration.py @@ -1,15 +1,19 @@ # # Tests for integration using Finite Volume method # -from tests import TestCase +from __future__ import annotations + +import unittest + +import numpy as np + import pybamm from tests import ( - get_mesh_for_testing, + TestCase, get_1p1d_mesh_for_testing, get_cylindrical_mesh_for_testing, + get_mesh_for_testing, ) -import numpy as np -import unittest class TestFiniteVolumeIntegration(TestCase): diff --git a/tests/unit/test_spatial_methods/test_scikit_finite_element.py b/tests/unit/test_spatial_methods/test_scikit_finite_element.py index 05b424e053..e4a1969682 100644 --- a/tests/unit/test_spatial_methods/test_scikit_finite_element.py +++ b/tests/unit/test_spatial_methods/test_scikit_finite_element.py @@ -1,12 +1,15 @@ # # Test for the operator class # -from tests import TestCase -import pybamm -from tests import get_2p1d_mesh_for_testing, get_unit_2p1D_mesh_for_testing -import numpy as np +from __future__ import annotations + import unittest +import numpy as np + +import pybamm +from tests import TestCase, get_2p1d_mesh_for_testing, get_unit_2p1D_mesh_for_testing + class TestScikitFiniteElement(TestCase): def test_not_implemented(self): diff --git a/tests/unit/test_spatial_methods/test_spectral_volume.py b/tests/unit/test_spatial_methods/test_spectral_volume.py index 3988bdd266..28e0d3a1b1 100644 --- a/tests/unit/test_spatial_methods/test_spectral_volume.py +++ b/tests/unit/test_spatial_methods/test_spectral_volume.py @@ -1,11 +1,15 @@ # # Test for the operator class # -from tests import TestCase -import pybamm -import numpy as np +from __future__ import annotations + import unittest +import numpy as np + +import pybamm +from tests import TestCase + def get_mesh_for_testing( xpts=None, rpts=10, ypts=15, zpts=15, geometry=None, cc_submesh=None, order=2 diff --git a/tests/unit/test_spatial_methods/test_zero_dimensional_method.py b/tests/unit/test_spatial_methods/test_zero_dimensional_method.py index b3ec859412..0b81ada36d 100644 --- a/tests/unit/test_spatial_methods/test_zero_dimensional_method.py +++ b/tests/unit/test_spatial_methods/test_zero_dimensional_method.py @@ -1,11 +1,14 @@ # # Test for the base Spatial Method class # -from tests import TestCase +from __future__ import annotations + +import unittest + import numpy as np + import pybamm -import unittest -from tests import get_mesh_for_testing, get_discretisation_for_testing +from tests import TestCase, get_discretisation_for_testing, get_mesh_for_testing class TestZeroDimensionalSpatialMethod(TestCase): diff --git a/tests/unit/test_timer.py b/tests/unit/test_timer.py index 228cdd5dce..2bef01cf7f 100644 --- a/tests/unit/test_timer.py +++ b/tests/unit/test_timer.py @@ -4,8 +4,11 @@ # The code in this file is adapted from Pints # (see https://github.com/pints-team/pints) # -import pybamm +from __future__ import annotations + import unittest + +import pybamm from tests import TestCase diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py index 24f204b6df..0d214fcf2a 100644 --- a/tests/unit/test_util.py +++ b/tests/unit/test_util.py @@ -1,16 +1,20 @@ # # Tests the utility functions. # -from tests import TestCase -import numpy as np +from __future__ import annotations + import os import sys -import pybamm import tempfile import unittest -from unittest.mock import patch from io import StringIO from tempfile import TemporaryDirectory +from unittest.mock import patch + +import numpy as np + +import pybamm +from tests import TestCase anytree = sys.modules["anytree"]