Skip to content

Commit be78e13

Browse files
Merge branch 'main' into axis_api
2 parents 622f492 + 451bab2 commit be78e13

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

activestorage/active.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ def hfix(x):
114114

115115
_FillValue = hfix(ds.attrs.get('_FillValue'))
116116
missing_value = ds.attrs.get('missing_value')
117+
# see https://github.com/NCAS-CMS/PyActiveStorage/pull/303
118+
if isinstance(missing_value, np.ndarray):
119+
missing_value = missing_value[0]
117120
valid_min = hfix(ds.attrs.get('valid_min'))
118121
valid_max = hfix(ds.attrs.get('valid_max'))
119122
valid_range = hfix(ds.attrs.get('valid_range'))

tests/unit/test_active.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from botocore.exceptions import NoCredentialsError as NoCredsExc
99
from netCDF4 import Dataset
1010

11-
from activestorage.active import Active, load_from_s3
11+
from activestorage.active import Active, load_from_s3, get_missing_attributes
1212
from activestorage.config import *
1313

1414

@@ -32,6 +32,13 @@ def test_uri_nonexistent():
3232
assert str(exc.value) == expected
3333

3434

35+
def test_get_missing_attributes():
36+
"""Test get missing attributes."""
37+
ds = pyfive.File("tests/test_data/cesm2_native.nc")["TREFHT"]
38+
missing_attrs = get_missing_attributes(ds)
39+
assert missing_attrs == (np.float32(-900.0), np.float32(-900.0), None, None)
40+
41+
3542
def test_getitem():
3643
"""Unit test for class:Active."""
3744
# no variable passed

0 commit comments

Comments
 (0)