Skip to content

Commit

Permalink
pybamm-team#4120 improved error message (pybamm-team#4208)
Browse files Browse the repository at this point in the history
* pybamm-team#4120 improved error message

* style: pre-commit fixes

* updated test

* Update tests/unit/test_parameters/test_parameter_values.py

Co-authored-by: Eric G. Kratz <[email protected]>

* Update pybamm/parameters/parameter_values.py

Co-authored-by: Robert Timms <[email protected]>

* Update pybamm/parameters/parameter_values.py

Co-authored-by: Eric G. Kratz <[email protected]>

---------

Co-authored-by: Ubham16 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Arjun Verma <[email protected]>
Co-authored-by: Eric G. Kratz <[email protected]>
Co-authored-by: Robert Timms <[email protected]>
  • Loading branch information
6 people authored Jun 25, 2024
1 parent 9b57669 commit 7ba74dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pybamm/parameters/parameter_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def __init__(self, values, chemistry=None):
values.pop("chemistry", None)
self.update(values, check_already_exists=False)
else:
raise ValueError("Invalid Parameter Value")
valid_sets = "\n".join(pybamm.parameter_sets.keys())
raise ValueError(
f"'{values}' is not a valid parameter set. Parameter set must be one of:\n{valid_sets}"
)

# Initialise empty _processed_symbols dict (for caching)
self._processed_symbols = {}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_parameters/test_parameter_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_init(self):
pybamm.ParameterValues(None, chemistry="lithium-ion")

# junk param values rejected
with self.assertRaisesRegex(ValueError, "Invalid Parameter Value"):
with self.assertRaisesRegex(ValueError, "'Junk' is not a valid parameter set."):
pybamm.ParameterValues("Junk")

def test_repr(self):
Expand Down

0 comments on commit 7ba74dc

Please sign in to comment.