Skip to content

Commit

Permalink
allow None to be supplied as unit in set_unit
Browse files Browse the repository at this point in the history
  • Loading branch information
robertjwilson committed Jun 14, 2024
1 parent b498d48 commit 892fa8f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions nctoolkit/setters.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,13 @@ def set_units(self, unit_dict=None, **kwargs):

# change the units in turn. This doesn't seem to be something you can chain?
for i in unit_dict:
if not isinstance(i, str):
raise TypeError("key,values in unit_dict are not strings")
if not isinstance(unit_dict[i], str):
raise TypeError("key,values in unit_dict are not strings")
if unit_dict[i] is not None:
if not isinstance(i, str):
raise TypeError("key,values in unit_dict are not strings")
if not isinstance(unit_dict[i], str):
raise TypeError("key,values in unit_dict are not strings")

cdo_command = f'-setattribute,{i}@units="{unit_dict[i]}"'
cdo_command = f'-setattribute,{i}@units="{unit_dict[str(i)]}"'
self.cdo_command(cdo_command, ensemble=False)


Expand Down

0 comments on commit 892fa8f

Please sign in to comment.