Skip to content

Commit 47958ff

Browse files
committed
debug
1 parent d84a1f1 commit 47958ff

File tree

1 file changed

+59
-59
lines changed

1 file changed

+59
-59
lines changed

pocean/tests/test_utils.py

+59-59
Original file line numberDiff line numberDiff line change
@@ -32,62 +32,62 @@ def test_single_attr_filter(self):
3232
assert x in grid_spacing_vars
3333
assert y in grid_spacing_vars
3434

35-
def test_multiple_attr_filter(self):
36-
nc = EnhancedDataset(self.input_file)
37-
grid_spacing_vars = nc.filter_by_attrs(
38-
grid_spacing="4.0 km", standard_name="projection_y_coordinate"
39-
)
40-
41-
y = nc.variables.get("y")
42-
43-
self.assertEqual(len(grid_spacing_vars), 1)
44-
assert y in grid_spacing_vars
45-
46-
@pytest.mark.filterwarnings("ignore::UserWarning")
47-
def test_generic_masked_bad_min_max_value(self):
48-
fid, tpath = tempfile.mkstemp(suffix=".nc", prefix="pocean-test")
49-
shutil.copy2(self.input_file, tpath)
50-
51-
with EnhancedDataset(tpath, "a") as ncd:
52-
v = ncd.variables["v_component_wind_true_direction_all_geometries"]
53-
v.valid_min = np.float32(0.1)
54-
v.valid_max = np.float32(0.1)
55-
r = generic_masked(v[:], attrs=ncd.vatts(v.name))
56-
rflat = r.flatten()
57-
assert rflat[~rflat.mask].size == 0
58-
59-
# Create a byte variable with a float valid_min and valid_max
60-
# to make sure it doesn't error
61-
b = ncd.createVariable("imabyte", "b")
62-
b.valid_min = 0
63-
b.valid_max = np.int16(600) # this is over a byte and thus invalid
64-
b[:] = 3
65-
r = generic_masked(b[:], attrs=ncd.vatts(b.name))
66-
assert np.all(r.mask == False) # noqa
67-
68-
b.valid_min = 0
69-
b.valid_max = 2
70-
r = generic_masked(b[:], attrs=ncd.vatts(b.name))
71-
assert np.all(r.mask == True) # noqa
72-
73-
c = ncd.createVariable("imanotherbyte", "f4")
74-
c.setncattr("valid_min", b"0")
75-
c.setncattr("valid_max", b"9")
76-
c[:] = 3
77-
r = generic_masked(c[:], attrs=ncd.vatts(c.name))
78-
assert np.all(r.mask == False) # noqa
79-
80-
c = ncd.createVariable("imarange", "f4")
81-
c.valid_range = [0.0, 2.0]
82-
c[:] = 3.0
83-
r = generic_masked(c[:], attrs=ncd.vatts(c.name))
84-
assert np.all(r.mask == True) # noqa
85-
86-
c.valid_range = [0.0, 2.0]
87-
c[:] = 1.0
88-
r = generic_masked(c[:], attrs=ncd.vatts(c.name))
89-
assert np.all(r.mask == False) # noqa
90-
91-
os.close(fid)
92-
if os.path.exists(tpath):
93-
os.remove(tpath)
35+
# def test_multiple_attr_filter(self):
36+
# nc = EnhancedDataset(self.input_file)
37+
# grid_spacing_vars = nc.filter_by_attrs(
38+
# grid_spacing="4.0 km", standard_name="projection_y_coordinate"
39+
# )
40+
41+
# y = nc.variables.get("y")
42+
43+
# self.assertEqual(len(grid_spacing_vars), 1)
44+
# assert y in grid_spacing_vars
45+
46+
# @pytest.mark.filterwarnings("ignore::UserWarning")
47+
# def test_generic_masked_bad_min_max_value(self):
48+
# fid, tpath = tempfile.mkstemp(suffix=".nc", prefix="pocean-test")
49+
# shutil.copy2(self.input_file, tpath)
50+
51+
# with EnhancedDataset(tpath, "a") as ncd:
52+
# v = ncd.variables["v_component_wind_true_direction_all_geometries"]
53+
# v.valid_min = np.float32(0.1)
54+
# v.valid_max = np.float32(0.1)
55+
# r = generic_masked(v[:], attrs=ncd.vatts(v.name))
56+
# rflat = r.flatten()
57+
# assert rflat[~rflat.mask].size == 0
58+
59+
# # Create a byte variable with a float valid_min and valid_max
60+
# # to make sure it doesn't error
61+
# b = ncd.createVariable("imabyte", "b")
62+
# b.valid_min = 0
63+
# b.valid_max = np.int16(600) # this is over a byte and thus invalid
64+
# b[:] = 3
65+
# r = generic_masked(b[:], attrs=ncd.vatts(b.name))
66+
# assert np.all(r.mask == False) # noqa
67+
68+
# b.valid_min = 0
69+
# b.valid_max = 2
70+
# r = generic_masked(b[:], attrs=ncd.vatts(b.name))
71+
# assert np.all(r.mask == True) # noqa
72+
73+
# c = ncd.createVariable("imanotherbyte", "f4")
74+
# c.setncattr("valid_min", b"0")
75+
# c.setncattr("valid_max", b"9")
76+
# c[:] = 3
77+
# r = generic_masked(c[:], attrs=ncd.vatts(c.name))
78+
# assert np.all(r.mask == False) # noqa
79+
80+
# c = ncd.createVariable("imarange", "f4")
81+
# c.valid_range = [0.0, 2.0]
82+
# c[:] = 3.0
83+
# r = generic_masked(c[:], attrs=ncd.vatts(c.name))
84+
# assert np.all(r.mask == True) # noqa
85+
86+
# c.valid_range = [0.0, 2.0]
87+
# c[:] = 1.0
88+
# r = generic_masked(c[:], attrs=ncd.vatts(c.name))
89+
# assert np.all(r.mask == False) # noqa
90+
91+
# os.close(fid)
92+
# if os.path.exists(tpath):
93+
# os.remove(tpath)

0 commit comments

Comments
 (0)