gafusion / omas

Ordered Multidimensional Array Structure
http://gafusion.github.io/omas
MIT License
32 stars 15 forks source link

Assignment of incorrect data type does not raise warning/error #317

Open hassec opened 1 month ago

hassec commented 1 month ago

Simple reproducer with omas 0.94:

import omas
ods = omas.ODS()
ods["summary.global_quantities.r0.value"] = "potato"
print(ods)

This will not raise any errors. The schema says this should be a FLT_0D and I assumed that OMAS would raise an error, similarly to how it does when dimensions or path names are incorrect.

Schema:

 "summary.global_quantities.r0.value": {
  "data_type": "FLT_0D",
  "documentation": "Value",
  "full_path": "summary/global_quantities/r0/value",
  "lifecycle_status": "active",
  "type": "constant",
  "units": "m"
 },

Does OMAS not assert that the assigned data type matches the schema?

orso82 commented 1 month ago

@hassec take a look at the consistency_checker() function. It looks like it doesn't do much when a string is inserted

https://github.com/gafusion/omas/blob/2c9824eced7d5e6d44d66c96bd397f8c1737266e/omas/omas_core.py#L76

Would you be willing to draft a fix, and open a PR? Thanks.

hassec commented 1 month ago

@orso82 Thanks for the pointer. I'll try to find some time to investigate this, but it will have to wait until I have some more idle time.