Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions lib/ncdata/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,23 @@ def __init__(self, name: str, value): # noqa: D107
#: attribute name
self.name: str = name
# Attribute values are arraylike, have dtype
# TODO: may need to regularise string representations?
if not hasattr(value, "dtype"):
value = np.asanyarray(value)
#: attribute value
self.value: np.ndarray = value

@property
def value(self): # noqa: D102
return self._value

@value.setter
def value(self, value):
if not hasattr(value, "dtype"):
value = np.asanyarray(value)
if value.ndim > 1:
raise ValueError(
"Attribute value should only be 0- or 1-dimensional."
)
self._value = value

def as_python_value(self):
"""
Return the content, but converting any character data to Python strings.
Expand Down
2 changes: 1 addition & 1 deletion lib/ncdata/utils/_compare_nc_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def getdata(var):
isnans, isnans2 = (np.isnan(arr) for arr in (flatdata, flatdata2))
if np.any(isnans) or np.any(isnans2):
nandiffs = np.where(isnans != isnans2)[0]
if nandiffs:
if nandiffs.size > 0:
flat_diff_inds += list(nandiffs)
anynans = isnans | isnans2
flatdata[anynans] = safe_fill_const
Expand Down
Loading