Skip to content

Commit

Permalink
pybop-team#123 moving forward with PyBaMM parameter set check
Browse files Browse the repository at this point in the history
Coverage is already up for this, this is just for PyBaMM 23.5
  • Loading branch information
agriyakhetarpal committed Feb 14, 2024
1 parent 08c72b1 commit 937aea4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pybop/parameters/parameter_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,10 @@ def pybamm(cls, name):
pybamm.ParameterValues
A PyBaMM parameter set corresponding to the provided name.
"""

msg = f"Parameter set '{name}' is not a valid PyBaMM parameter set. Available parameter sets are: {list(pybamm.parameter_sets)}"

if name not in list(pybamm.parameter_sets):
raise ValueError(msg)

return pybamm.ParameterValues(name).copy()
2 changes: 1 addition & 1 deletion tests/unit/test_parameter_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TestParameterSets:

@pytest.mark.unit
def test_parameter_set(self):
# Tests parameter set creation
# Tests parameter set creation and validation
with pytest.raises(ValueError):
pybop.ParameterSet.pybamm("sChen2010s")

Expand Down

0 comments on commit 937aea4

Please sign in to comment.