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
3 changes: 3 additions & 0 deletions activestorage/active.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ def hfix(x):

_FillValue = hfix(ds.attrs.get('_FillValue'))
missing_value = ds.attrs.get('missing_value')
# see https://github.com/NCAS-CMS/PyActiveStorage/pull/303
if isinstance(missing_value, np.ndarray):
missing_value = missing_value[0]
valid_min = hfix(ds.attrs.get('valid_min'))
valid_max = hfix(ds.attrs.get('valid_max'))
valid_range = hfix(ds.attrs.get('valid_range'))
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/test_active.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from botocore.exceptions import NoCredentialsError as NoCredsExc
from netCDF4 import Dataset

from activestorage.active import Active, load_from_s3
from activestorage.active import Active, load_from_s3, get_missing_attributes
from activestorage.config import *


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


def test_get_missing_attributes():
"""Test get missing attributes."""
ds = pyfive.File("tests/test_data/cesm2_native.nc")["TREFHT"]
missing_attrs = get_missing_attributes(ds)
assert missing_attrs == (np.float32(-900.0), np.float32(-900.0), None, None)


def test_getitem():
"""Unit test for class:Active."""
# no variable passed
Expand Down
Loading