gafusion / omas

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

omas can't deepcopy certain sub-ODSs #200

Closed jmcclena closed 8 months ago

jmcclena commented 2 years ago

example:

ods= ODS()
ods['equilibrium.time_slice.0'] = ODS()
ods2 = ODS()
ods2['equilibrium.time_slice'] = copy.deepcopy(ods['equilibrium.time_slice'])

returns the following error:

Error in "OMFIT command box #2" at line  8
    ods2['equilibrium.time_slice'] = copy.deepcopy(ods['equilibrium.time_slice'])
LookupError: Not a valid IMAS 3.36.0 location: equilibrium.time_slice
                                                           ^^^^^^^^^^
Did you mean: time_slice, time, ids_properties, vacuum_toroidal_field, grids_ggd, ...

Press <F6> to see full error report...

Traceback (most recent call last):
  File "/home/mcclenaghanj/omas/omas/omas_core.py", line 874, in __setitem__
    self._validate(value, structure)
  File "/home/mcclenaghanj/omas/omas/omas_core.py", line 793, in _validate
    structure_key = o2u(key)
  File "omas/omas/omas_cython.pyx", line 92, in omas.omas_cython.o2u
TypeError: argument of type 'int' is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mcclenaghanj/OMFIT-source2/omfit/omfit_classes/OMFITx.py", line 4608, in manage_user_errors
    tmp = command(**kw)
  File "/home/mcclenaghanj/OMFIT-source2/omfit/utils_tk.py", line 1180, in GlobLoc_tk
    return py.run(_relLoc=self.namespace, _OMFITscriptsDict=False, _OMFITconsoleDict=True, noGUI=None)
  File "/home/mcclenaghanj/OMFIT-source2/omfit/omfit_classes/omfit_python.py", line 1101, in run
    result = self.__run__(**kw)
  File "/home/mcclenaghanj/OMFIT-source2/omfit/omfit_classes/omfit_python.py", line 950, in __run__
    self, userDict=kw, inputDict=_relLoc, persistentDict=OMFITconsoleDict, runDict={}, prerun=prerun, postrun=postrun
  File "/home/mcclenaghanj/OMFIT-source2/omfit/omfit_classes/omfit_python.py", line 129, in f_locked
    return f(*args, **kw)
  File "/home/mcclenaghanj/OMFIT-source2/omfit/omfit_classes/omfit_python.py", line 374, in execGlobLoc
    exec(compile(execString, filename, "exec"), GlobLoc)
  File "/local-scratch/mcclenaghanj/OMFIT/OMFIT_2022-06-14_09_58_29_893004/project/OMFIT command box #2", line 8, in <module>
    ods2['equilibrium.time_slice'] = copy.deepcopy(ods['equilibrium.time_slice'])
  File "/home/mcclenaghanj/omas/omas/omas_core.py", line 1056, in __setitem__
    self.getraw(key[0])[key[1:]] = pass_on_value
  File "/home/mcclenaghanj/omas/omas/omas_core.py", line 900, in __setitem__
    raise LookupError(underline_last(txt, len('LookupError: ')) + '\n' + options)
LookupError: Not a valid IMAS 3.36.0 location: equilibrium.time_slice
                                                           ^^^^^^^^^^
Did you mean: time_slice, time, ids_properties, vacuum_toroidal_field, grids_ggd, ...
orso82 commented 2 years ago

@jmcclena the error is not on the deep-copy end, but at the time of insertion. This will work:

ods= ODS()
ods['equilibrium.time_slice.0'] = ODS()

ods2 = ODS()
ods2['equilibrium.time_slice'] = ODS()
ods2['equilibrium.time_slice'].update(copy.deepcopy(ods['equilibrium.time_slice']))

I agree this is not ideal, and I can look more closely why the error happens.

github-actions[bot] commented 1 year ago

Stale issue message

github-actions[bot] commented 11 months ago

Stale issue message

github-actions[bot] commented 8 months ago

Stale issue message