Skip to content

Commit

Permalink
default masked value to None if integer type given
Browse files Browse the repository at this point in the history
  • Loading branch information
observingClouds authored Aug 4, 2024
1 parent 8be933f commit ecd4766
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion xbitinfo/xbitinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,13 @@ def _get_bitinformation_kwargs_handler(da, kwargs):
"""Helper function to preprocess kwargs args of :py:func:`xbitinfo.xbitinfo.get_bitinformation`."""
kwargs_var = kwargs.copy()
if "masked_value" not in kwargs_var:
kwargs_var["masked_value"] = f"convert({str(da.dtype).capitalize()},NaN)"
if da.dtype.kind == 'i':
logging.warning('No masked value given for integer type variable. Assuming no mask to apply.')
kwargs_var["masked_value"] = "nothing"
elif da.dtype.kind == 'f':
kwargs_var["masked_value"] = f"convert({str(da.dtype).capitalize()},NaN)"
else:
raise ValueError(f'Dtype kind ({da.dtype.kind}) not supported.')
elif kwargs_var["masked_value"] is None:
kwargs_var["masked_value"] = "nothing"
if "set_zero_insignificant" not in kwargs_var:
Expand Down

0 comments on commit ecd4766

Please sign in to comment.