Skip to content

Commit

Permalink
update values in unit tests to pass post xarray v2024.03.0 decoding c…
Browse files Browse the repository at this point in the history
…hanges
  • Loading branch information
thabbott committed Apr 5, 2024
1 parent 6ba2e80 commit 825eb39
Show file tree
Hide file tree
Showing 8 changed files with 18,537 additions and 18,520 deletions.
2,960 changes: 1,480 additions & 1,480 deletions tests/unit/static/cocip-contrail-output.json

Large diffs are not rendered by default.

25,922 changes: 12,961 additions & 12,961 deletions tests/unit/static/cocip-contrail-output2.json

Large diffs are not rendered by default.

1,044 changes: 522 additions & 522 deletions tests/unit/static/cocip-flight-output.json

Large diffs are not rendered by default.

7,098 changes: 3,549 additions & 3,549 deletions tests/unit/static/cocip-flight-output2.json

Large diffs are not rendered by default.

25 changes: 21 additions & 4 deletions tests/unit/test_cocip.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,15 @@ def test_eval_persistent(cocip_persistent: Cocip, regenerate_results: bool) -> N
rtol=1e-2,
)
continue
if key in ["tau_cirrus", "specific_cloud_ice_water_content"]:
np.testing.assert_allclose(
cocip_persistent.source.get_data_or_attr(key),
flight_output[key],
err_msg=key,
rtol=rtol,
atol=1e-14, # for trace cloud ice
)
continue
np.testing.assert_allclose(
cocip_persistent.source.get_data_or_attr(key),
flight_output[key],
Expand Down Expand Up @@ -761,7 +770,7 @@ def test_eval_persistent2(cocip_persistent2: Cocip, regenerate_results: bool) ->
contrail_output["age"] = pd.to_timedelta(contrail_output["age"])
contrail_output["dt_integration"] = pd.to_timedelta(contrail_output["dt_integration"])

rtol = 1e-3
rtol = 1e-4
for key in flight_output:
if key in ["time", "flight_id"]:
assert np.all(cocip_persistent2.source[key] == flight_output[key])
Expand All @@ -771,7 +780,15 @@ def test_eval_persistent2(cocip_persistent2: Cocip, regenerate_results: bool) ->
cocip_persistent2.source.level, flight_output[key], err_msg=key
)
continue

if key in ["tau_cirrus", "specific_cloud_ice_water_content"]:
np.testing.assert_allclose(
cocip_persistent2.source[key],
flight_output[key],
err_msg=key,
rtol=rtol,
atol=1e-14, # for trace cloud ice
)
continue
np.testing.assert_allclose(
cocip_persistent2.source[key], flight_output[key], err_msg=key, rtol=rtol
)
Expand Down Expand Up @@ -935,9 +952,9 @@ def test_cocip_contrail_contrail_overlapping(
out = cocip.eval(fleet)

if contrail_contrail_overlapping:
assert out["ef"].sum() == pytest.approx(621504.7e8, abs=8e7)
assert out["ef"].sum() == pytest.approx(621498.2e8, abs=8e7)
else:
assert out["ef"].sum() == pytest.approx(621506.7e8, abs=8e7)
assert out["ef"].sum() == pytest.approx(621500.2e8, abs=8e7)


# ------
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_humidity_scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def test_histogram_matching_reanalysis(

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

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_scipy19_interpolation_methods(mda: MetDataArray, method: str) -> None:

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


@pytest.fixture()
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_tau_cirrus.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def test_implementations_close(met_cocip1: MetDataset) -> None:
assert (da1 <= 2 * da2).all()

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


def test_geopotential_approximation(met_cocip1: MetDataset):
Expand Down

0 comments on commit 825eb39

Please sign in to comment.