Skip to content

Commit e437691

Browse files
committed
fix: revert to float64 and old tolerances
1 parent ced3acb commit e437691

File tree

5 files changed

+48
-48
lines changed

5 files changed

+48
-48
lines changed

tests/extreme/_data.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
273.621521,
5656
]
5757
)
58-
ens = ens[:, np.newaxis].astype(np.float32)
58+
ens = ens[:, np.newaxis]
5959

6060
ens_eps = np.array(
6161
[
@@ -112,7 +112,7 @@
112112
0.005218505859375,
113113
]
114114
)
115-
ens_eps = ens_eps[:, np.newaxis].astype(np.float32)
115+
ens_eps = ens_eps[:, np.newaxis]
116116

117117
clim = np.array(
118118
[
@@ -219,7 +219,7 @@
219219
274.55859375,
220220
]
221221
)
222-
clim = clim[:, np.newaxis].astype(np.float32)
222+
clim = clim[:, np.newaxis]
223223

224224
clim_eps = np.array(
225225
[
@@ -326,7 +326,7 @@
326326
0.02294921875,
327327
]
328328
)
329-
clim_eps = clim_eps[:, np.newaxis].astype(np.float32)
329+
clim_eps = clim_eps[:, np.newaxis]
330330

331331
ens_eps2 = np.array(
332332
[
@@ -383,7 +383,7 @@
383383
1.5535354614257812,
384384
]
385385
)
386-
ens_eps2 = ens_eps2[:, np.newaxis].astype(np.float32)
386+
ens_eps2 = ens_eps2[:, np.newaxis]
387387

388388
clim_eps2 = np.array(
389389
[
@@ -490,4 +490,4 @@
490490
0.48828125,
491491
]
492492
)
493-
clim_eps2 = clim_eps2[:, np.newaxis].astype(np.float32)
493+
clim_eps2 = clim_eps2[:, np.newaxis]

tests/extreme/test_extreme.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ def test_sot_highlevel(xp, device, clim, ens, v_ref):
9898

9999
v_ref = xp.asarray(v_ref, dtype=sot_upper.dtype)
100100

101-
assert xp.allclose(sot_upper[0], v_ref[0], rtol=1e-4)
102-
assert xp.allclose(sot_lower[0], v_ref[1], rtol=1e-4)
101+
assert xp.allclose(sot_upper[0], v_ref[0])
102+
assert xp.allclose(sot_lower[0], v_ref[1])
103103

104104

105105
@pytest.mark.parametrize("xp, device", NAMESPACE_DEVICES)
@@ -119,8 +119,8 @@ def test_sot_core(xp, device, clim, ens, v_ref):
119119

120120
v_ref = xp.asarray(v_ref, dtype=sot_upper.dtype)
121121

122-
assert xp.allclose(sot_upper[0], v_ref[0], rtol=1e-4)
123-
assert xp.allclose(sot_lower[0], v_ref[1], rtol=1e-4)
122+
assert xp.allclose(sot_upper[0], v_ref[0])
123+
assert xp.allclose(sot_lower[0], v_ref[1])
124124

125125

126126
@pytest.mark.parametrize("xp, device", NAMESPACE_DEVICES)

tests/stats/_quantile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@
5656
[0.6474237082, 0.7014179041, np.nan, 0.3952555796, 0.2498164288, np.nan],
5757
],
5858
]
59-
).astype(np.float32)
59+
)

tests/thermo/test_thermo.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def __init__(self, xp, device, file_name="t_hum_p_data.csv"):
5555

5656
d = read_data_file(self.file_name)
5757

58-
self.t = xp.asarray(d["t"].astype(np.float32), device=device)
59-
self.td = xp.asarray(d["td"].astype(np.float32), device=device)
60-
self.r = xp.asarray(d["r"].astype(np.float32), device=device)
61-
self.q = xp.asarray(d["q"].astype(np.float32), device=device)
62-
self.p = xp.asarray(d["p"].astype(np.float32), device=device)
58+
self.t = xp.asarray(d["t"], device=device)
59+
self.td = xp.asarray(d["td"], device=device)
60+
self.r = xp.asarray(d["r"], device=device)
61+
self.q = xp.asarray(d["q"], device=device)
62+
self.p = xp.asarray(d["p"], device=device)
6363

6464

6565
# high level method call
@@ -179,8 +179,8 @@ def test_saturation_vapour_pressure_1(xp, device, phase):
179179

180180
d = read_data_file(ref_file)
181181

182-
t = xp.asarray(d["t"].astype(np.float32), device=device)
183-
v_ref = xp.asarray(d[phase].astype(np.float32), device=device)
182+
t = xp.asarray(d["t"], device=device)
183+
v_ref = xp.asarray(d[phase], device=device)
184184

185185
svp = thermo.array.saturation_vapour_pressure(t, phase=phase)
186186
assert xp.allclose(svp, v_ref)
@@ -219,9 +219,9 @@ def test_saturation_mixing_ratio(phase, xp, device):
219219
# save_test_reference(ref_file, o)
220220

221221
d = read_data_file(ref_file)
222-
t = xp.asarray(d["t"].astype(np.float32), device=device)
223-
p = xp.asarray(d["p"].astype(np.float32), device=device)
224-
v_ref = xp.asarray(d[phase].astype(np.float32), device=device)
222+
t = xp.asarray(d["t"], device=device)
223+
p = xp.asarray(d["p"], device=device)
224+
v_ref = xp.asarray(d[phase], device=device)
225225

226226
mr = thermo.array.saturation_mixing_ratio(t, p, phase=phase)
227227
assert xp.allclose(mr, v_ref)
@@ -243,9 +243,9 @@ def test_saturation_specific_humidity(phase, xp, device):
243243
# save_test_reference(ref_file, o)
244244

245245
d = read_data_file(ref_file)
246-
t = xp.asarray(d["t"].astype(np.float32), device=device)
247-
p = xp.asarray(d["p"].astype(np.float32), device=device)
248-
v_ref = xp.asarray(d[phase].astype(np.float32), device=device)
246+
t = xp.asarray(d["t"], device=device)
247+
p = xp.asarray(d["p"], device=device)
248+
v_ref = xp.asarray(d[phase], device=device)
249249

250250
q = thermo.array.saturation_specific_humidity(t, p, phase=phase)
251251
assert xp.allclose(q, v_ref)
@@ -262,8 +262,8 @@ def test_saturation_vapour_pressure_slope(phase, xp, device):
262262
# save_test_reference(ref_file, o)
263263

264264
d = read_data_file(ref_file)
265-
t = xp.asarray(d["t"].astype(np.float32), device=device)
266-
v_ref = xp.asarray(d[phase].astype(np.float32), device=device)
265+
t = xp.asarray(d["t"], device=device)
266+
v_ref = xp.asarray(d[phase], device=device)
267267

268268
svp = thermo.array.saturation_vapour_pressure_slope(t, phase=phase)
269269
assert xp.allclose(svp, v_ref)
@@ -285,9 +285,9 @@ def test_saturation_mixing_ratio_slope_1(phase, xp, device):
285285
# save_test_reference(ref_file, o)
286286

287287
d = read_data_file(ref_file)
288-
t = xp.asarray(d["t"].astype(np.float32), device=device)
289-
p = xp.asarray(d["p"].astype(np.float32), device=device)
290-
v_ref = xp.asarray(d[phase].astype(np.float32), device=device)
288+
t = xp.asarray(d["t"], device=device)
289+
p = xp.asarray(d["p"], device=device)
290+
v_ref = xp.asarray(d[phase], device=device)
291291

292292
svp = thermo.array.saturation_mixing_ratio_slope(t, p, phase=phase)
293293
assert xp.allclose(svp, v_ref)
@@ -323,9 +323,9 @@ def test_saturation_specific_humidity_slope_1(phase, xp, device):
323323
# save_test_reference(ref_file, o)
324324

325325
d = read_data_file(ref_file)
326-
t = xp.asarray(d["t"].astype(np.float32), device=device)
327-
p = xp.asarray(d["p"].astype(np.float32), device=device)
328-
v_ref = xp.asarray(d[phase].astype(np.float32), device=device)
326+
t = xp.asarray(d["t"], device=device)
327+
p = xp.asarray(d["p"], device=device)
328+
v_ref = xp.asarray(d[phase], device=device)
329329

330330
svp = thermo.array.saturation_specific_humidity_slope(t, p, phase=phase)
331331
assert xp.allclose(svp, v_ref)
@@ -349,8 +349,8 @@ def test_temperature_from_saturation_vapour_pressure_1(xp, device):
349349
ref_file = "sat_vp.csv"
350350
d = read_data_file(ref_file)
351351

352-
svp = xp.asarray(d["water"].astype(np.float32), device=device)
353-
v_ref = xp.asarray(d["t"].astype(np.float32), device=device)
352+
svp = xp.asarray(d["water"], device=device)
353+
v_ref = xp.asarray(d["t"], device=device)
354354

355355
t = thermo.array.temperature_from_saturation_vapour_pressure(svp)
356356
assert xp.allclose(t, v_ref, equal_nan=True)
@@ -721,11 +721,11 @@ def test_ept(method, xp, device):
721721
ref = read_data_file(ref_file)
722722

723723
pt = thermo.array.ept_from_dewpoint(data.t, data.td, data.p, method=method)
724-
v_ref = xp.asarray(ref[method + "_td"].astype(np.float32), device=device)
724+
v_ref = xp.asarray(ref[method + "_td"], device=device)
725725
assert xp.allclose(pt, v_ref), f"td {method=}"
726726

727727
pt = thermo.array.ept_from_specific_humidity(data.t, data.q, data.p, method=method)
728-
v_ref = xp.asarray(ref[method + "_q"].astype(np.float32), device=device)
728+
v_ref = xp.asarray(ref[method + "_q"], device=device)
729729
assert xp.allclose(pt, v_ref), f"q {method=}"
730730

731731

@@ -744,7 +744,7 @@ def test_saturation_ept(method, xp, device):
744744
ref = read_data_file(ref_file)
745745

746746
pt = thermo.array.saturation_ept(data.t, data.p, method=method)
747-
v_ref = xp.asarray(ref[method].astype(np.float32), device=device)
747+
v_ref = xp.asarray(ref[method], device=device)
748748
assert xp.allclose(pt, v_ref), f"{method=}"
749749

750750

@@ -765,12 +765,12 @@ def test_temperature_on_moist_adiabat(ept_method, t_method, xp, device):
765765
# save_test_reference(ref_file, o)
766766

767767
ref = read_data_file(ref_file)
768-
ept = xp.asarray(ref["ept"].astype(np.float32), device=device)
769-
p = xp.asarray(ref["p"].astype(np.float32), device=device)
768+
ept = xp.asarray(ref["ept"], device=device)
769+
p = xp.asarray(ref["p"], device=device)
770770

771771
pt = thermo.array.temperature_on_moist_adiabat(ept, p, ept_method=ept_method, t_method=t_method)
772-
v_ref = xp.asarray(ref[f"{ept_method}_{t_method}"].astype(np.float32), device=device)
773-
assert xp.allclose(pt, v_ref, equal_nan=True, rtol=1e-4), f"{ept_method=} {t_method=}"
772+
v_ref = xp.asarray(ref[f"{ept_method}_{t_method}"], device=device)
773+
assert xp.allclose(pt, v_ref, equal_nan=True), f"{ept_method=} {t_method=}"
774774

775775

776776
@pytest.mark.parametrize("xp, device", NAMESPACE_DEVICES)
@@ -798,15 +798,15 @@ def test_wet_bulb_temperature(ept_method, t_method, xp, device):
798798
data.t, data.td, data.p, ept_method=ept_method, t_method=t_method
799799
)
800800

801-
v_ref = xp.asarray(ref[f"{ept_method}_{t_method}_td"].astype(np.float32), device=device)
802-
assert xp.allclose(pt, v_ref, rtol=1e-01, atol=0, equal_nan=True), f"td {ept_method=} {t_method=}"
801+
v_ref = xp.asarray(ref[f"{ept_method}_{t_method}_td"], device=device)
802+
assert xp.allclose(pt, v_ref, rtol=1e-03, atol=0, equal_nan=True), f"td {ept_method=} {t_method=}"
803803

804804
pt = thermo.array.wet_bulb_temperature_from_specific_humidity(
805805
data.t, data.q, data.p, ept_method=ept_method, t_method=t_method
806806
)
807807

808-
v_ref = xp.asarray(ref[f"{ept_method}_{t_method}_q"].astype(np.float32), device=device)
809-
assert xp.allclose(pt, v_ref, rtol=1e-01, atol=0, equal_nan=True), f"q {ept_method=} {t_method=}"
808+
v_ref = xp.asarray(ref[f"{ept_method}_{t_method}_q"], device=device)
809+
assert xp.allclose(pt, v_ref, rtol=1e-03, atol=0, equal_nan=True), f"q {ept_method=} {t_method=}"
810810

811811

812812
@pytest.mark.parametrize("xp, device", NAMESPACE_DEVICES)
@@ -838,14 +838,14 @@ def test_wet_bulb_potential_temperature(ept_method, t_method, xp, device):
838838
data.t, data.td, data.p, ept_method=ept_method, t_method=t_method
839839
)
840840

841-
v_ref = xp.asarray(ref[f"{ept_method}_{t_method}_td"].astype(np.float32), device=device)
841+
v_ref = xp.asarray(ref[f"{ept_method}_{t_method}_td"], device=device)
842842
assert xp.allclose(pt, v_ref, rtol=1e-03, atol=0, equal_nan=True), f"td {ept_method=} {t_method=}"
843843

844844
pt = thermo.array.wet_bulb_potential_temperature_from_specific_humidity(
845845
data.t, data.q, data.p, ept_method=ept_method, t_method=t_method
846846
)
847847

848-
v_ref = xp.asarray(ref[f"{ept_method}_{t_method}_q"].astype(np.float32), device=device)
848+
v_ref = xp.asarray(ref[f"{ept_method}_{t_method}_q"], device=device)
849849
assert xp.allclose(pt, v_ref, rtol=1e-03, atol=0, equal_nan=True), f"q {ept_method=} {t_method=}"
850850

851851

tests/wind/test_wind.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def test_coriolis(lat, v_ref, xp, device):
257257
1.0000000000,
258258
],
259259
]
260-
).astype(np.float32)
260+
)
261261
* 100
262262
/ 11.0,
263263
[

0 commit comments

Comments
 (0)