comet-toolkit / obsarray

Measurement uncertainty handling in Python
GNU Lesser General Public License v3.0
7 stars 1 forks source link

Enable unc_comps to be string as well as list #15

Open madsted opened 1 year ago

madsted commented 1 year ago

Some obsarray functionality raises an error for uncertainty variables where the unc_comp attribute is a string rather than a list. This can arise when there is only one uncertainty component for a variable. Obsarray should be able to handle unc_comps as a list or a string.

e.g. line run:

del ds.unc[obs_var][var]

error: Traceback (most recent call last): File "C:\Users\mes\Anaconda3\envs\eoio\lib\site-packages\IPython\core\interactiveshell.py", line 3508, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in del ds.unc[obs_var][var] File "c:\users\mes\code\pycharmprojects\obsarray\obsarray\unc_accessor.py", line 424, in delitem self._obj.unc._remove_unc_var(self._var_name, unc_var) File "c:\users\mes\code\pycharmprojects\obsarray\obsarray\unc_accessor.py", line 898, in _remove_unc_var self._obj[obs_var].attrs["unc_comps"].remove(unc_var) AttributeError: 'str' object has no attribute 'remove'