Skip to content

Commit 825eb39

Browse files
committed
update values in unit tests to pass post xarray v2024.03.0 decoding changes
1 parent 6ba2e80 commit 825eb39

8 files changed

+18537
-18520
lines changed

tests/unit/static/cocip-contrail-output.json

Lines changed: 1480 additions & 1480 deletions
Large diffs are not rendered by default.

tests/unit/static/cocip-contrail-output2.json

Lines changed: 12961 additions & 12961 deletions
Large diffs are not rendered by default.

tests/unit/static/cocip-flight-output.json

Lines changed: 522 additions & 522 deletions
Large diffs are not rendered by default.

tests/unit/static/cocip-flight-output2.json

Lines changed: 3549 additions & 3549 deletions
Large diffs are not rendered by default.

tests/unit/test_cocip.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,15 @@ def test_eval_persistent(cocip_persistent: Cocip, regenerate_results: bool) -> N
698698
rtol=1e-2,
699699
)
700700
continue
701+
if key in ["tau_cirrus", "specific_cloud_ice_water_content"]:
702+
np.testing.assert_allclose(
703+
cocip_persistent.source.get_data_or_attr(key),
704+
flight_output[key],
705+
err_msg=key,
706+
rtol=rtol,
707+
atol=1e-14, # for trace cloud ice
708+
)
709+
continue
701710
np.testing.assert_allclose(
702711
cocip_persistent.source.get_data_or_attr(key),
703712
flight_output[key],
@@ -761,7 +770,7 @@ def test_eval_persistent2(cocip_persistent2: Cocip, regenerate_results: bool) ->
761770
contrail_output["age"] = pd.to_timedelta(contrail_output["age"])
762771
contrail_output["dt_integration"] = pd.to_timedelta(contrail_output["dt_integration"])
763772

764-
rtol = 1e-3
773+
rtol = 1e-4
765774
for key in flight_output:
766775
if key in ["time", "flight_id"]:
767776
assert np.all(cocip_persistent2.source[key] == flight_output[key])
@@ -771,7 +780,15 @@ def test_eval_persistent2(cocip_persistent2: Cocip, regenerate_results: bool) ->
771780
cocip_persistent2.source.level, flight_output[key], err_msg=key
772781
)
773782
continue
774-
783+
if key in ["tau_cirrus", "specific_cloud_ice_water_content"]:
784+
np.testing.assert_allclose(
785+
cocip_persistent2.source[key],
786+
flight_output[key],
787+
err_msg=key,
788+
rtol=rtol,
789+
atol=1e-14, # for trace cloud ice
790+
)
791+
continue
775792
np.testing.assert_allclose(
776793
cocip_persistent2.source[key], flight_output[key], err_msg=key, rtol=rtol
777794
)
@@ -935,9 +952,9 @@ def test_cocip_contrail_contrail_overlapping(
935952
out = cocip.eval(fleet)
936953

937954
if contrail_contrail_overlapping:
938-
assert out["ef"].sum() == pytest.approx(621504.7e8, abs=8e7)
955+
assert out["ef"].sum() == pytest.approx(621498.2e8, abs=8e7)
939956
else:
940-
assert out["ef"].sum() == pytest.approx(621506.7e8, abs=8e7)
957+
assert out["ef"].sum() == pytest.approx(621500.2e8, abs=8e7)
941958

942959

943960
# ------

tests/unit/test_humidity_scaling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def test_histogram_matching_reanalysis(
347347

348348
# Check that the two methods give different results
349349
diff = np.abs(np.log(q1) - np.log(q0))
350-
assert diff.min() >= 1e-6
350+
assert diff.min() >= 5e-7
351351
assert diff.max() <= 2
352352
assert 0.02 < diff.mean() < 0.1
353353

tests/unit/test_interpolation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def test_scipy19_interpolation_methods(mda: MetDataArray, method: str) -> None:
320320

321321
# Pin the RMSE (out of curiosity)
322322
rmse = (np.mean((out1 - out2) ** 2)) ** 0.5
323-
assert rmse == pytest.approx(3.3319390877860893, rel=1e-10)
323+
assert rmse == pytest.approx(3.3319389446, rel=1e-10)
324324

325325

326326
@pytest.fixture()

tests/unit/test_tau_cirrus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def test_implementations_close(met_cocip1: MetDataset) -> None:
5858
assert (da1 <= 2 * da2).all()
5959

6060
# Pin the mean values of each
61-
assert da1.mean() == 0.01444357167929411
62-
assert da2.mean().item() == 0.008129739202558994
61+
assert da1.mean() == pytest.approx(0.014443565160, rel=1e-10)
62+
assert da2.mean() == pytest.approx(0.0081297373399, rel=1e-10)
6363

6464

6565
def test_geopotential_approximation(met_cocip1: MetDataset):

0 commit comments

Comments
 (0)