diff --git a/.all-contributorsrc b/.all-contributorsrc index caadc74b78..dcde101e80 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -970,6 +970,27 @@ "contributions": [ "code" ] + }, + { + "login": "MarcBerliner", + "name": "Marc Berliner", + "avatar_url": "https://avatars.githubusercontent.com/u/34451391?v=4", + "profile": "http://marcberliner.com", + "contributions": [ + "code", + "doc", + "infra", + "maintenance" + ] + }, + { + "login": "Aswinr24", + "name": "Aswinr24", + "avatar_url": "https://avatars.githubusercontent.com/u/135364633?v=4", + "profile": "https://github.com/Aswinr24", + "contributions": [ + "test" + ] } ], "contributorsPerLine": 7, diff --git a/.github/workflows/lychee_url_checker.yml b/.github/workflows/lychee_url_checker.yml index 9a636fda8a..b93743619b 100644 --- a/.github/workflows/lychee_url_checker.yml +++ b/.github/workflows/lychee_url_checker.yml @@ -28,7 +28,7 @@ jobs: # use stable version for now to avoid breaking changes - name: Lychee URL checker - uses: lycheeverse/lychee-action@v1.10.0 + uses: lycheeverse/lychee-action@v2.0.2 with: # arguments with file types to check args: >- diff --git a/.github/workflows/periodic_benchmarks.yml b/.github/workflows/periodic_benchmarks.yml index ef66cec238..14f97c55d8 100644 --- a/.github/workflows/periodic_benchmarks.yml +++ b/.github/workflows/periodic_benchmarks.yml @@ -51,7 +51,7 @@ jobs: LD_LIBRARY_PATH: $HOME/.local/lib - name: Upload results as artifact - uses: actions/upload-artifact@v4.4.1 + uses: actions/upload-artifact@v4.4.3 with: name: asv_periodic_results path: results diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 27e6d1162f..64c8a3a777 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -92,7 +92,7 @@ jobs: python -c "import pybamm; print(pybamm.IDAKLUSolver())" python -m pytest -m cibw {project}/tests/unit - name: Upload Windows wheels - uses: actions/upload-artifact@v4.4.1 + uses: actions/upload-artifact@v4.4.3 with: name: wheels_windows path: ./wheelhouse/*.whl @@ -129,7 +129,7 @@ jobs: python -m pytest -m cibw {project}/tests/unit - name: Upload wheels for Linux - uses: actions/upload-artifact@v4.4.1 + uses: actions/upload-artifact@v4.4.3 with: name: wheels_manylinux path: ./wheelhouse/*.whl @@ -261,7 +261,7 @@ jobs: python -m pytest -m cibw {project}/tests/unit - name: Upload wheels for macOS (amd64, arm64) - uses: actions/upload-artifact@v4.4.1 + uses: actions/upload-artifact@v4.4.3 with: name: wheels_${{ matrix.os }} path: ./wheelhouse/*.whl @@ -281,7 +281,7 @@ jobs: run: pipx run build --sdist - name: Upload SDist - uses: actions/upload-artifact@v4.4.1 + uses: actions/upload-artifact@v4.4.3 with: name: sdist path: ./dist/*.tar.gz diff --git a/.github/workflows/run_benchmarks_over_history.yml b/.github/workflows/run_benchmarks_over_history.yml index ce8eb72ce0..d66704a635 100644 --- a/.github/workflows/run_benchmarks_over_history.yml +++ b/.github/workflows/run_benchmarks_over_history.yml @@ -46,7 +46,7 @@ jobs: ${{ github.event.inputs.commit_start }}..${{ github.event.inputs.commit_end }} - name: Upload results as artifact - uses: actions/upload-artifact@v4.4.1 + uses: actions/upload-artifact@v4.4.3 with: name: asv_over_history_results path: results diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index beb849e9fc..cb7e552857 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -59,7 +59,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@604373da6381bf24206979c74d06a550515601b9 # v4.4.1 + uses: actions/upload-artifact@184d73b71b93c222403b2e7f1ffebe4508014249 # v4.4.1 with: name: SARIF file path: results.sarif @@ -68,6 +68,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard (optional). # Commenting out will disable upload of results to your repo's Code Scanning dashboard - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12 + uses: github/codeql-action/upload-sarif@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13 with: sarif_file: results.sarif diff --git a/.gitignore b/.gitignore index 7e558a9eb1..9ef761b487 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ coverage.xml htmlcov/ # virtual environment +.venv env/ venv/ venv3.5/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b66b38b4db..2fc6b76539 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: types_or: [python, pyi, jupyter] - repo: https://github.com/adamchainz/blacken-docs - rev: "1.18.0" + rev: "1.19.0" hooks: - id: blacken-docs additional_dependencies: [black==23.*] diff --git a/README.md b/README.md index 611d8adcfe..2b5250d856 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/pybamm-team/PyBaMM/badge)](https://scorecard.dev/viewer/?uri=github.com/pybamm-team/PyBaMM) -[![All Contributors](https://img.shields.io/badge/all_contributors-91-orange.svg)](#-contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-93-orange.svg)](#-contributors) diff --git a/all_contributors.md b/all_contributors.md index b701ef2a13..d4a41ba8e1 100644 --- a/all_contributors.md +++ b/all_contributors.md @@ -122,6 +122,10 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Pip Liggins
Pip Liggins

💻 ⚠️ Medha Bhardwaj
Medha Bhardwaj

💻 + + Marc Berliner
Marc Berliner

💻 📖 🚇 🚧 + Aswinr24
Aswinr24

⚠️ + diff --git a/src/pybamm/CITATIONS.bib b/src/pybamm/CITATIONS.bib index 26919f7c66..62b4b1003e 100644 --- a/src/pybamm/CITATIONS.bib +++ b/src/pybamm/CITATIONS.bib @@ -291,7 +291,7 @@ @article{Hindmarsh2005 @misc{jax2018, author = {James Bradbury and Roy Frostig and Peter Hawkins and Matthew James Johnson and Chris Leary and Dougal Maclaurin and Skye Wanderman-Milne}, title = {{JAX: composable transformations of Python+NumPy programs}}, - url = {http://github.com/google/jax}, + url = {http://github.com/jax-ml/jax}, version = {0.2.5}, year = {2018}, } diff --git a/src/pybamm/solvers/jax_bdf_solver.py b/src/pybamm/solvers/jax_bdf_solver.py index a07ad8505b..3fd3f2384e 100644 --- a/src/pybamm/solvers/jax_bdf_solver.py +++ b/src/pybamm/solvers/jax_bdf_solver.py @@ -28,7 +28,7 @@ MIN_FACTOR = 0.2 MAX_FACTOR = 10 - # https://github.com/google/jax/issues/4572#issuecomment-709809897 + # https://github.com/jax-ml/jax/issues/4572#issuecomment-709809897 def some_hash_function(x): return hash(str(x)) @@ -711,7 +711,7 @@ def block_fun(i, j, Ai, Aj): return onp.block(blocks) # NOTE: the code below (except the docstring on jax_bdf_integrate and other minor - # edits), has been modified from the JAX library at https://github.com/google/jax. + # edits), has been modified from the JAX library at https://github.com/jax-ml/jax. # The main difference is the addition of support for semi-explicit dae index 1 # problems via the addition of a mass matrix. # This is under an Apache license, a short form of which is given here: diff --git a/src/pybamm/solvers/jax_solver.py b/src/pybamm/solvers/jax_solver.py index a1f1733ed6..c4f5a60a64 100644 --- a/src/pybamm/solvers/jax_solver.py +++ b/src/pybamm/solvers/jax_solver.py @@ -46,7 +46,7 @@ class JaxSolver(pybamm.BaseSolver): extra_options : dict, optional Any options to pass to the solver. Please consult `JAX documentation - `_ + `_ for details. """ @@ -263,8 +263,8 @@ async def solve_model_async(inputs_v): # sparse matrix support in JAX resulting in high memory usage, or a bug # in the BDF solver. # - # This issue on guthub appears related: - # https://github.com/google/jax/discussions/13930 + # This issue on GitHub appears related: + # https://github.com/jax-ml/jax/discussions/13930 # # # Split input list based on the number of available xla devices # device_count = jax.local_device_count() 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 cddd59c352..973a0f348b 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 @@ -7,8 +7,7 @@ class TestDFN(BaseUnitTestLithiumIon): - @pytest.fixture(autouse=True) - def setUp(self): + def setup_method(self): self.model = pybamm.lithium_ion.DFN def test_electrolyte_options(self): 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 389fcf9429..395c6f54b9 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 @@ -4,10 +4,8 @@ import pybamm from tests import BaseUnitTestLithiumIonHalfCell -import pytest class TestDFNHalfCell(BaseUnitTestLithiumIonHalfCell): - @pytest.fixture(autouse=True) - def setUp(self): + def setup_method(self): self.model = pybamm.lithium_ion.DFN 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 ea641ee7cc..58149a69de 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 @@ -7,8 +7,7 @@ class TestNewmanTobias(BaseUnitTestLithiumIon): - @pytest.fixture(autouse=True) - def setUp(self): + def setup_method(self): self.model = pybamm.lithium_ion.NewmanTobias def test_electrolyte_options(self): 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 99affc7ddd..8551967dad 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 @@ -7,8 +7,7 @@ class TestSPM(BaseUnitTestLithiumIon): - @pytest.fixture(autouse=True) - def setUp(self): + def setup_method(self): self.model = pybamm.lithium_ion.SPM def test_electrolyte_options(self): 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 c1b6b34745..8ca0c7a7b9 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 @@ -3,10 +3,8 @@ # import pybamm from tests import BaseUnitTestLithiumIonHalfCell -import pytest class TestSPMHalfCell(BaseUnitTestLithiumIonHalfCell): - @pytest.fixture(autouse=True) - def setUp(self): + def setup_method(self): self.model = pybamm.lithium_ion.SPM 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 b0d38fa9c7..ecab4384fc 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 @@ -7,8 +7,7 @@ class TestSPMe(BaseUnitTestLithiumIon): - @pytest.fixture(autouse=True) - def setUp(self): + def setup_method(self): self.model = pybamm.lithium_ion.SPMe # def test_external_variables(self): 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 2a814c113e..f09f42a5a6 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 @@ -4,10 +4,8 @@ # import pybamm from tests import BaseUnitTestLithiumIonHalfCell -import pytest class TestSPMeHalfCell(BaseUnitTestLithiumIonHalfCell): - @pytest.fixture(autouse=True) - def setUp(self): + def setup_method(self): self.model = pybamm.lithium_ion.SPMe diff --git a/tests/unit/test_parameters/test_bpx.py b/tests/unit/test_parameters/test_bpx.py index aeb249cbc0..3e0e32d1fd 100644 --- a/tests/unit/test_parameters/test_bpx.py +++ b/tests/unit/test_parameters/test_bpx.py @@ -7,8 +7,7 @@ class TestBPX: - @pytest.fixture(autouse=True) - def setUp(self): + def setup_method(self): self.base = { "Header": { "BPX": 1.0, diff --git a/tests/unit/test_parameters/test_process_parameter_data.py b/tests/unit/test_parameters/test_process_parameter_data.py index 9352894c5c..dc363b862b 100644 --- a/tests/unit/test_parameters/test_process_parameter_data.py +++ b/tests/unit/test_parameters/test_process_parameter_data.py @@ -2,56 +2,48 @@ # Tests for the parameter processing functions # - -import os import numpy as np import pybamm - import pytest +from pathlib import Path -class TestProcessParameterData: - def test_process_1D_data(self): - name = "lico2_ocv_example" - path = os.path.abspath(os.path.dirname(__file__)) - processed = pybamm.parameters.process_1D_data(name, path) - assert processed[0] == name - assert isinstance(processed[1], tuple) - assert isinstance(processed[1][0][0], np.ndarray) - assert isinstance(processed[1][1], np.ndarray) +@pytest.fixture +def parameters_path(): + return Path(__file__).parent.resolve() - def test_process_2D_data(self): - name = "lico2_diffusivity_Dualfoil1998_2D" - path = os.path.abspath(os.path.dirname(__file__)) - processed = pybamm.parameters.process_2D_data(name, path) - assert processed[0] == name - assert isinstance(processed[1], tuple) - assert isinstance(processed[1][0][0], np.ndarray) - assert isinstance(processed[1][0][1], np.ndarray) - assert isinstance(processed[1][1], np.ndarray) - def test_process_2D_data_csv(self): - name = "data_for_testing_2D" - path = os.path.abspath(os.path.dirname(__file__)) - processed = pybamm.parameters.process_2D_data_csv(name, path) +@pytest.fixture( + params=[ + ("lico2_ocv_example", pybamm.parameters.process_1D_data), + ("lico2_diffusivity_Dualfoil1998_2D", pybamm.parameters.process_2D_data), + ("data_for_testing_2D", pybamm.parameters.process_2D_data_csv), + ("data_for_testing_3D", pybamm.parameters.process_3D_data_csv), + ] +) +def parameter_data(request, parameters_path): + name, processing_function = request.param + processed = processing_function(name, parameters_path) + return name, processed + +class TestProcessParameterData: + def test_processed_name(self, parameter_data): + name, processed = parameter_data assert processed[0] == name + + def test_processed_structure(self, parameter_data): + name, processed = parameter_data assert isinstance(processed[1], tuple) assert isinstance(processed[1][0][0], np.ndarray) - assert isinstance(processed[1][0][1], np.ndarray) assert isinstance(processed[1][1], np.ndarray) - def test_process_3D_data_csv(self): - name = "data_for_testing_3D" - path = os.path.abspath(os.path.dirname(__file__)) - processed = pybamm.parameters.process_3D_data_csv(name, path) + if len(processed[1][0]) > 1: + assert isinstance(processed[1][0][1], np.ndarray) - assert processed[0] == name - assert isinstance(processed[1], tuple) - assert isinstance(processed[1][0][0], np.ndarray) - assert isinstance(processed[1][0][1], np.ndarray) - assert isinstance(processed[1][0][2], np.ndarray) - assert isinstance(processed[1][1], np.ndarray) + elif len(processed[1]) == 3: + assert isinstance(processed[1][0][1], np.ndarray) + assert isinstance(processed[1][0][2], np.ndarray) def test_error(self): with pytest.raises(FileNotFoundError, match="Could not find file"):