Repository: pybamm-team/PyBaMM
Pull request #3132 (2023-07-10 05:10:36)

Raise error for unknown parameter_values
added else statement to inform user of an invalid parameter set

# Description

Added else statement to inform user of an invalid parameter set in parameter_values.py

In response to #3063 - Raise error for unknown parameter sets


Fixes # (3063)

## Type of change

Please add a line in the relevant section of [CHANGELOG.md](https://github.com/pybamm-team/PyBaMM/blob/develop/CHANGELOG.md) to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

- [ ] New feature (non-breaking change which adds functionality)
- [ ] Optimization (back-end change that speeds up the code)
- [x] Bug fix (non-breaking change which fixes an issue)

# Key checklist:

- [x] No style issues: `$ pre-commit run` (see [CONTRIBUTING.md](https://github.com/pybamm-team/PyBaMM/blob/develop/CONTRIBUTING.md#installing-and-using-pre-commit) for how to set this up to run automatically when committing locally, in just two lines of code)
- [x] All tests pass: `$ python run-tests.py --all`
- [x] The documentation builds: `$ python run-tests.py --doctest`

You can run unit and doctests together at once, using `$ python run-tests.py --quick`.

## Further checks:

- [ ] Code is commented, particularly in hard-to-understand areas
- [ ] Tests added that prove fix is effective or that feature works



Patch:
diff --git a/.github/release_checklist.md b/.github/release_checklist.md
index f461d471e..812d7ef32 100644
--- a/.github/release_checklist.md
+++ b/.github/release_checklist.md
@@ -5,8 +5,6 @@
     - `docs/conf.py`
     - `CITATION.cff`
     - `vcpkg.json`
-    - `docs/source/_static/versions.json`, and check if any links fail
-
   - Update baseline of registries in `vcpkg-configuration.json` as the latest commit id from [pybamm-team/sundials-vcpkg-registry](https://github.com/pybamm-team/sundials-vcpkg-registry)
   - Update `CHANGELOG.md` with a summary of the release
 
diff --git a/CHANGELOG.md b/CHANGELOG.md
index af7f75d28..31a1ddbca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@
 ## Bug fixes
 
 - Parameters in `Prada2013` have been updated to better match those given in the paper, which is a 2.3 Ah cell, instead of the mix-and-match with the 1.1 Ah cell from Lain2019.
+- Error generated when invalid parameter values are passed.
 
 # [v23.5](https://github.com/pybamm-team/PyBaMM/tree/v23.5) - 2023-06-18
 
diff --git a/docs/source/_static/versions.json b/docs/source/_static/versions.json
index 5c9bba7c1..cf4385bd2 100644
--- a/docs/source/_static/versions.json
+++ b/docs/source/_static/versions.json
@@ -2,166 +2,135 @@
     {
         "name": "latest",
         "version": "latest",
-        "url": "https://docs.pybamm.org/en/latest/"
+        "url": "https://pybamm.readthedocs.io/en/latest/"
     },
     {
         "name": "stable",
         "version": "stable",
-        "url": "https://docs.pybamm.org/en/stable/"
+        "url": "https://pybamm.readthedocs.io/en/stable/"
     },
     {
-        "name": "v23.5",
-        "version": "23.5",
-        "url": "https://docs.pybamm.org/en/v23.5_a/"
+        "version": "v23.5",
+        "url": "https://pybamm.readthedocs.io/en/v23.5/"
     },
     {
-        "name": "v23.4.1",
-        "version": "23.4.1",
-        "url": "https://docs.pybamm.org/en/v23.4.1/"
+        "version": "v23.4.1",
+        "url": "https://pybamm.readthedocs.io/en/v23.4.1/"
     },
     {
-        "name": "v23.4",
-        "version": "23.4",
-        "url": "https://docs.pybamm.org/en/v23.4/"
+        "version": "v23.4",
+        "url": "https://pybamm.readthedocs.io/en/v23.4/"
     },
     {
-        "name": "v23.3",
-        "version": "23.3",
-        "url": "https://docs.pybamm.org/en/v23.3/"
+        "version": "v23.3",
+        "url": "https://pybamm.readthedocs.io/en/v23.3/"
     },
     {
-        "name": "v23.2",
-        "version": "23.2",
-        "url": "https://docs.pybamm.org/en/v23.2/"
+        "version": "v23.2",
+        "url": "https://pybamm.readthedocs.io/en/v23.2/"
     },
     {
-        "name": "v23.1",
-        "version": "23.1",
-        "url": "https://docs.pybamm.org/en/v23.1/"
+        "version": "v23.1",
+        "url": "https://pybamm.readthedocs.io/en/v23.1/"
     },
     {
-        "name": "v22.12",
-        "version": "22.12",
-        "url": "https://docs.pybamm.org/en/v22.12/"
+        "version": "v22.12",
+        "url": "https://pybamm.readthedocs.io/en/v22.12/"
     },
     {
-        "name": "v22.11.1",
-        "version": "22.11.1",
-        "url": "https://docs.pybamm.org/en/v22.11.1/"
+        "version": "v22.11.1",
+        "url": "https://pybamm.readthedocs.io/en/v22.11.1/"
     },
     {
-        "name": "v22.11",
-        "version": "22.11",
-        "url": "https://docs.pybamm.org/en/v22.11/"
+        "version": "v22.11",
+        "url": "https://pybamm.readthedocs.io/en/v22.11/"
     },
     {
-        "name": "v22.10",
-        "version": "22.10",
-        "url": "https://docs.pybamm.org/en/v22.10/"
+        "version": "v22.10",
+        "url": "https://pybamm.readthedocs.io/en/v22.10/"
     },
     {
-        "name": "v22.9",
-        "version": "22.9",
-        "url": "https://docs.pybamm.org/en/v22.9/"
+        "version": "v22.9",
+        "url": "https://pybamm.readthedocs.io/en/v22.9/"
     },
     {
-        "name": "v22.8",
-        "version": "22.8",
-        "url": "https://docs.pybamm.org/en/v22.8/"
+        "version": "v22.8",
+        "url": "https://pybamm.readthedocs.io/en/v22.8/"
     },
     {
-        "name": "v22.7",
-        "version": "22.7",
-        "url": "https://docs.pybamm.org/en/v22.7/"
+        "version": "v22.7",
+        "url": "https://pybamm.readthedocs.io/en/v22.7/"
     },
     {
-        "name": "v22.6",
-        "version": "22.6",
-        "url": "https://docs.pybamm.org/en/v22.6/"
+        "version": "v22.6",
+        "url": "https://pybamm.readthedocs.io/en/v22.6/"
     },
     {
-        "name": "v22.5",
-        "version": "22.5",
-        "url": "https://docs.pybamm.org/en/v22.5/"
+        "version": "v22.5",
+        "url": "https://pybamm.readthedocs.io/en/v22.5/"
     },
     {
-        "name": "v22.4",
-        "version": "22.4",
-        "url": "https://docs.pybamm.org/en/v22.4/"
+        "version": "v22.4",
+        "url": "https://pybamm.readthedocs.io/en/v22.4/"
     },
     {
-        "name": "v22.3",
-        "version": "22.3",
-        "url": "https://docs.pybamm.org/en/v22.3/"
+        "version": "v22.3",
+        "url": "https://pybamm.readthedocs.io/en/v22.3/"
     },
     {
-        "name": "v22.2",
-        "version": "22.2",
-        "url": "https://docs.pybamm.org/en/v22.3/"
+        "version": "v22.2",
+        "url": "https://pybamm.readthedocs.io/en/v22.3/"
     },
     {
-        "name": "v22.1",
-        "version": "22.1",
-        "url": "https://docs.pybamm.org/en/v22.1/"
+        "version": "v22.1",
+        "url": "https://pybamm.readthedocs.io/en/v22.1/"
     },
     {
-        "name": "v21.12",
-        "version": "21.12",
-        "url": "https://docs.pybamm.org/en/v21.12/"
+        "version": "v21.12",
+        "url": "https://pybamm.readthedocs.io/en/v21.12/"
     },
     {
-        "name": "v21.11",
-        "version": "21.11",
-        "url": "https://docs.pybamm.org/en/v21.11/"
+        "version": "v21.11",
+        "url": "https://pybamm.readthedocs.io/en/v21.11/"
     },
     {
-        "name": "v21.10",
-        "version": "21.10",
-        "url": "https://docs.pybamm.org/en/v21.10/"
+        "version": "v21.10",
+        "url": "https://pybamm.readthedocs.io/en/v21.10/"
     },
     {
-        "name": "v21.9",
-        "version": "21.9",
-        "url": "https://docs.pybamm.org/en/v21.9/"
+        "version": "v21.9",
+        "url": "https://pybamm.readthedocs.io/en/v21.9/"
     },
     {
-        "name": "v21.08",
-        "version": "21.08",
-        "url": "https://docs.pybamm.org/en/v21.08/"
+        "version": "v21.08",
+        "url": "https://pybamm.readthedocs.io/en/v21.08/"
     },
     {
-        "name": "v0.4.0",
-        "version": "0.4.0",
-        "url": "https://docs.pybamm.org/en/v0.4.0/"
+        "version": "v0.4.0",
+        "url": "https://pybamm.readthedocs.io/en/v0.4.0/"
     },
     {
-        "name": "v0.3.0",
-        "version": "0.3.0",
-        "url": "https://docs.pybamm.org/en/v0.3.0/"
+        "version": "v0.3.0",
+        "url": "https://pybamm.readthedocs.io/en/v0.3.0/"
     },
     {
-        "name": "v0.2.3",
-        "version": "0.2.3",
-        "url": "https://docs.pybamm.org/en/v0.2.3/"
+        "version": "v0.2.3",
+        "url": "https://pybamm.readthedocs.io/en/v0.2.3/"
     },
     {
-        "name": "v0.2.2",
-        "version": "0.2.2",
-        "url": "https://docs.pybamm.org/en/v0.2.2/"
+        "version": "v0.2.2",
+        "url": "https://pybamm.readthedocs.io/en/v0.2.2/"
     },
     {
-        "name": "v0.2.1",
-        "version": "0.2.1",
-        "url": "https://docs.pybamm.org/en/v0.2.1/"
+        "version": "v0.2.1",
+        "url": "https://pybamm.readthedocs.io/en/v0.2.1/"
     },
     {
-        "name": "v0.2.0",
-        "version": "0.2.0",
-        "url": "https://docs.pybamm.org/en/v0.2.0/"
+        "version": "v0.2.0",
+        "url": "https://pybamm.readthedocs.io/en/v0.2.0/"
     },
     {
-        "name": "v0.1.0",
-        "version": "0.1.0",
-        "url": "https://docs.pybamm.org/en/v0.1.0/"
+        "version": "v0.1.0",
+        "url": "https://pybamm.readthedocs.io/en/v0.1.0/"
     }
-]
+]
\ No newline at end of file
diff --git a/docs/sphinxext/inheritance_diagram.py b/docs/sphinxext/inheritance_diagram.py
index 048921bff..29c60726c 100644
--- a/docs/sphinxext/inheritance_diagram.py
+++ b/docs/sphinxext/inheritance_diagram.py
@@ -35,8 +35,3 @@ def add_diagram(app, what, name, obj, options, lines):
 
 def setup(app):
     app.connect("autodoc-process-docstring", add_diagram)
-    return {
-        "version": "0.1.0",
-        "parallel_read_safe": True,
-        "parallel_write_safe": True,
-    }
diff --git a/pybamm/parameters/parameter_values.py b/pybamm/parameters/parameter_values.py
index 858c6e7c3..c78cb70c9 100644
--- a/pybamm/parameters/parameter_values.py
+++ b/pybamm/parameters/parameter_values.py
@@ -60,10 +60,12 @@ class ParameterValues:
             self.update(values, check_already_exists=False)
         else:
             # Check if values is a named parameter set
-            if isinstance(values, str) and values in pybamm.parameter_sets:
+            if isinstance(values, str) and values in pybamm.parameter_sets.keys():
                 values = pybamm.parameter_sets[values]
                 values.pop("chemistry", None)
                 self.update(values, check_already_exists=False)
+            else:
+                raise ValueError("Invalid Parameter Value")
 
         # Initialise empty _processed_symbols dict (for caching)
         self._processed_symbols = {}
diff --git a/scripts/update_version.py b/scripts/update_version.py
index 4a5f60d8d..807db57fa 100644
--- a/scripts/update_version.py
+++ b/scripts/update_version.py
@@ -50,11 +50,10 @@ def update_version():
         json_data.insert(
             2,
             {
-                "name": f"v{release_version}",
-                "version": f"{release_version}",
-                "url": f"https://docs.pybamm.org/en/v{release_version}/",
+                "version": f"v{release_version}",
+                "url": f"https://pybamm.readthedocs.io/en/v{release_version}/",
             },
-        )
+        )  # noqa: E501
         file.truncate(0)
         file.seek(0)
         file.write(json.dumps(json_data, indent=4))


Test patch:
diff --git a/tests/unit/test_parameters/test_parameter_values.py b/tests/unit/test_parameters/test_parameter_values.py
index ba2a548d0..def4c339f 100644
--- a/tests/unit/test_parameters/test_parameter_values.py
+++ b/tests/unit/test_parameters/test_parameter_values.py
@@ -41,6 +41,10 @@ class TestParameterValues(TestCase):
         ):
             pybamm.ParameterValues(None, chemistry="lithium-ion")
 
+        # junk param values rejected
+        with self.assertRaisesRegex(ValueError, "Invalid Parameter Value"):
+            pybamm.ParameterValues("Junk")
+
     def test_repr(self):
         param = pybamm.ParameterValues({"a": 1})
         self.assertEqual(