Skip to content

Commit

Permalink
Merge branch 'develop' into composite_mechanics
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammedasher authored Oct 15, 2024
2 parents 27d34ec + 9eb4bc7 commit f133412
Show file tree
Hide file tree
Showing 22 changed files with 79 additions and 72 deletions.
21 changes: 21 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lychee_url_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/periodic_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
LD_LIBRARY_PATH: $HOME/.local/lib

- name: Upload results as artifact
uses: actions/[email protected].1
uses: actions/[email protected].3
with:
name: asv_periodic_results
path: results
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected].1
uses: actions/[email protected].3
with:
name: wheels_windows
path: ./wheelhouse/*.whl
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
python -m pytest -m cibw {project}/tests/unit
- name: Upload wheels for Linux
uses: actions/[email protected].1
uses: actions/[email protected].3
with:
name: wheels_manylinux
path: ./wheelhouse/*.whl
Expand Down Expand Up @@ -261,7 +261,7 @@ jobs:
python -m pytest -m cibw {project}/tests/unit
- name: Upload wheels for macOS (amd64, arm64)
uses: actions/[email protected].1
uses: actions/[email protected].3
with:
name: wheels_${{ matrix.os }}
path: ./wheelhouse/*.whl
Expand All @@ -281,7 +281,7 @@ jobs:
run: pipx run build --sdist

- name: Upload SDist
uses: actions/[email protected].1
uses: actions/[email protected].3
with:
name: sdist
path: ./dist/*.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_benchmarks_over_history.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
${{ github.event.inputs.commit_start }}..${{ github.event.inputs.commit_end }}
- name: Upload results as artifact
uses: actions/[email protected].1
uses: actions/[email protected].3
with:
name: asv_over_history_results
path: results
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ coverage.xml
htmlcov/

# virtual environment
.venv
env/
venv/
venv3.5/
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.*]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-BADGE:START - Do not remove or modify this section -->
[![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)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

</div>
Expand Down
4 changes: 4 additions & 0 deletions all_contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="14.28%"><a href="https://github.com/pipliggins"><img src="https://avatars.githubusercontent.com/u/55396775?v=4?s=100" width="100px;" alt="Pip Liggins"/><br /><sub><b>Pip Liggins</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=pipliggins" title="Code">💻</a> <a href="https://github.com/pybamm-team/PyBaMM/commits?author=pipliggins" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/medha-14"><img src="https://avatars.githubusercontent.com/u/143182673?v=4?s=100" width="100px;" alt="Medha Bhardwaj"/><br /><sub><b>Medha Bhardwaj</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=medha-14" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="http://marcberliner.com"><img src="https://avatars.githubusercontent.com/u/34451391?v=4?s=100" width="100px;" alt="Marc Berliner"/><br /><sub><b>Marc Berliner</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=MarcBerliner" title="Code">💻</a> <a href="https://github.com/pybamm-team/PyBaMM/commits?author=MarcBerliner" title="Documentation">📖</a> <a href="#infra-MarcBerliner" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-MarcBerliner" title="Maintenance">🚧</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Aswinr24"><img src="https://avatars.githubusercontent.com/u/135364633?v=4?s=100" width="100px;" alt="Aswinr24"/><br /><sub><b>Aswinr24</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=Aswinr24" title="Tests">⚠️</a></td>
</tr>
</tbody>
</table>

Expand Down
2 changes: 1 addition & 1 deletion src/pybamm/CITATIONS.bib
Original file line number Diff line number Diff line change
Expand Up @@ -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},
}
Expand Down
4 changes: 2 additions & 2 deletions src/pybamm/solvers/jax_bdf_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions src/pybamm/solvers/jax_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class JaxSolver(pybamm.BaseSolver):
extra_options : dict, optional
Any options to pass to the solver.
Please consult `JAX documentation
<https://github.com/google/jax/blob/master/jax/experimental/ode.py>`_
<https://github.com/jax-ml/jax/blob/master/jax/experimental/ode.py>`_
for details.
"""

Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions tests/unit/test_parameters/test_bpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@


class TestBPX:
@pytest.fixture(autouse=True)
def setUp(self):
def setup_method(self):
self.base = {
"Header": {
"BPX": 1.0,
Expand Down
64 changes: 28 additions & 36 deletions tests/unit/test_parameters/test_process_parameter_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down

0 comments on commit f133412

Please sign in to comment.