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

BPX parser raises irrelevant validation errors #52

Open
ejfdickinson opened this issue May 21, 2024 · 2 comments
Open

BPX parser raises irrelevant validation errors #52

ejfdickinson opened this issue May 21, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ejfdickinson
Copy link
Collaborator

ejfdickinson commented May 21, 2024

In the presence of an invalid BPX object, the BPX parser reports non-existent errors in addition to real errors.

Repeat

import bpx
bpx.parse_bpx_file("examples/nmc_pouch_cell_BPX.json", v_tol=1)

Here, the file is parsed with no errors (valid BPX).

  1. Delete line 10 from nmc_pouch_cell_BPX.json:
"Ambient temperature [K]": 298.15,
import bpx
bpx.parse_bpx_file("examples/nmc_pouch_cell_BPX.json", v_tol=1)

The parser raises 40 errors, most of which are not correctly identified (missing or extra fields). The only real error (missing required field ["Parameterisation"]["Cell"]["Ambient temperature [K]"]) is raised twice, as the first and last reported error.

@ejfdickinson ejfdickinson added the bug Something isn't working label May 21, 2024
@ejfdickinson
Copy link
Collaborator Author

@rtimms @martinjrobins

@rtimms
Copy link
Collaborator

rtimms commented Jul 9, 2024

Maybe related, it seems like some optional fields are not validated correctly. E.g. the below test fails (no ValidationError is raised even though title should be a string!)

    def test_bad_title(self):
        test = copy.copy(self.base)
        test["Header"]["Title"] = 1
        with self.assertRaises(ValidationError):
            parse_obj_as(BPX, test)

@Ubham16 can you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants