Skip to content

Commit

Permalink
Merge pull request #290 from hassec/extra_structures_fix
Browse files Browse the repository at this point in the history
fix(structure): ensure add_extra_structures resets all required caches
  • Loading branch information
orso82 authored Feb 15, 2024
2 parents 6ed6238 + 56b6f02 commit c3ee9ff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions omas/omas_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ def add_extra_structures(extra_structures, lifecycle_status='tmp'):
# reset structure caches
omas_utils._structures = {}
omas_utils._structures_dict = {}
omas_utils._ods_structure_cache = {}

# add _structures
for _ids in extra_structures:
Expand Down
21 changes: 21 additions & 0 deletions omas/tests/test_omas_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,27 @@ def test_relax(self):
assert ods1['core_profiles.profiles_1d.0.ion.0.element[0].z_n'] == 1.5
assert ods1['equilibrium.time_slice[0].profiles_2d[0].psi'][0, 1] == 1.5

def test_add_extra_structures(self):
from omas.omas_structure import add_extra_structures, imas_structure

original = imas_structure("3.39.0", "wall.description_2d.0.limiter.unit.0")
extension = {
"wall": {
"wall.description_2d[:].limiter.unit[:].test_field": {
"data_type": "STR_0D",
"documentation": "Test field Name",
"full_path": "wall/description_2d(i1)/limiter/unit(i2)/test_field",
"type": "static",
}
}
}
add_extra_structures(extension)
extended = imas_structure("3.39.0", "wall.description_2d.0.limiter.unit.0")

assert 'test_field' not in original
assert 'test_field' in extended


# End of TestOmasCore class


Expand Down

0 comments on commit c3ee9ff

Please sign in to comment.