From 9bc8ea966af7396fe1f0714d8efb2c3abce9f6cb Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 6 Jan 2026 15:34:12 +0000 Subject: [PATCH 1/3] extract mask element from array --- activestorage/active.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/activestorage/active.py b/activestorage/active.py index 7ffe141c..9468f153 100644 --- a/activestorage/active.py +++ b/activestorage/active.py @@ -114,6 +114,8 @@ def hfix(x): _FillValue = hfix(ds.attrs.get('_FillValue')) missing_value = ds.attrs.get('missing_value') + 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')) From ddde9a66afe5d0cd861240669cd8c63530f66148 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 6 Jan 2026 15:34:22 +0000 Subject: [PATCH 2/3] add test --- tests/unit/test_active.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_active.py b/tests/unit/test_active.py index 30453e5b..d2f5c600 100644 --- a/tests/unit/test_active.py +++ b/tests/unit/test_active.py @@ -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 * @@ -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 From 531ff1cb9ad3dfdbbf63486300c8155a156a6b13 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 6 Jan 2026 16:28:02 +0000 Subject: [PATCH 3/3] add inline ref to pr --- activestorage/active.py | 1 + 1 file changed, 1 insertion(+) diff --git a/activestorage/active.py b/activestorage/active.py index 9468f153..fb963f32 100644 --- a/activestorage/active.py +++ b/activestorage/active.py @@ -114,6 +114,7 @@ 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'))