Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect error message #4672

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/pybamm/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,16 @@
) from error
best_matches = self.get_best_matches(key)
for k in best_matches:
if key in k and k.endswith("]"):
if key in k and k.endswith("]") and not key.endswith("]"):
raise KeyError(
f"'{key}' not found. Use the dimensional version '{k}' instead."
) from error
elif key in k and (
k.startswith("Primary") or k.startswith("Secondary")
):
raise KeyError(

Check warning on line 104 in src/pybamm/util.py

View check run for this annotation

Codecov / codecov/patch

src/pybamm/util.py#L104

Added line #L104 was not covered by tests
f"'{key}' not found. If you are using a composite model, you may need to use {k} instead. Otherwise, best matches are {best_matches}"
) from error
raise KeyError(
f"'{key}' not found. Best matches are {best_matches}"
) from error
Expand Down
Loading