From 54ac9c16bb0bd42cc7f3a1079890709a8046657d Mon Sep 17 00:00:00 2001 From: scivision Date: Thu, 19 Dec 2024 16:15:35 -0500 Subject: [PATCH] test forecast values change over time --- src/msise00/tests/test_grid.py | 6 +++--- src/msise00/tests/test_module.py | 15 +++------------ src/msise00/tests/test_point.py | 6 +++--- src/msise00/tests/test_time_grid.py | 6 +++--- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/msise00/tests/test_grid.py b/src/msise00/tests/test_grid.py index 1f2b465..b6ff250 100644 --- a/src/msise00/tests/test_grid.py +++ b/src/msise00/tests/test_grid.py @@ -7,7 +7,7 @@ import subprocess import pytest import xarray -import xarray.tests +import xarray.testing import importlib.resources import msise00 @@ -29,7 +29,7 @@ def test_one_alt_one_time(): dat_mod = msise00.run(time, altkm, lat, lon).squeeze() except ConnectionError: pytest.skip("unable to download RecentIndices.txt") - xarray.tests.assert_allclose(ref, dat_mod) + xarray.testing.assert_allclose(ref, dat_mod) def test_script(tmp_path): @@ -44,4 +44,4 @@ def test_script(tmp_path): subprocess.check_call(cmd) dat = xarray.open_dataset(fn) - xarray.tests.assert_allclose(ref, dat) + xarray.testing.assert_allclose(ref, dat) diff --git a/src/msise00/tests/test_module.py b/src/msise00/tests/test_module.py index bc5f300..994d83f 100755 --- a/src/msise00/tests/test_module.py +++ b/src/msise00/tests/test_module.py @@ -38,7 +38,7 @@ def test_past(): def test_forecast(): - t = datetime(2023, 3, 31, 12) + t = datetime(2029, 3, 31, 12) altkm = 150.0 glat = 65.0 glon = -148.0 @@ -50,16 +50,7 @@ def test_forecast(): dims = list(atmos.dims) assert ["time", "alt_km", "lat", "lon"] == dims - assert atmos["He"].item() == approx(4.3926901e12) - assert atmos["O"].item() == approx(4.5728936e15) - assert atmos["N2"].item() == approx(3.7001117e16) - assert atmos["O2"].item() == approx(8.1215314e15) - assert atmos["Ar"].item() == approx(3.3594181e14) - assert atmos["Total"].item() == approx(2.2950717e-09) - assert atmos["N"].item() == approx(2.155302e12) - assert atmos["AnomalousO"].item() == approx(8.7590428e-16) - assert atmos.species == ["He", "O", "N2", "O2", "Ar", "Total", "H", "N", "AnomalousO"] - assert atmos["Tn"].item() == approx(667.06, abs=0.01) - assert atmos["Texo"].item() == approx(922.28, abs=0.01) + assert atmos["Tn"].item() == approx(616.09, abs=0.1) + assert atmos["Texo"].item() == approx(769.82, abs=0.01) diff --git a/src/msise00/tests/test_point.py b/src/msise00/tests/test_point.py index 2cad96d..b93b371 100644 --- a/src/msise00/tests/test_point.py +++ b/src/msise00/tests/test_point.py @@ -9,7 +9,7 @@ import subprocess import pytest import xarray -import xarray.tests +import xarray.testing import msise00 import msise00.worldgrid @@ -29,7 +29,7 @@ def test_one_loc_one_time(altkm, reffn): dat_mod = msise00.run(time, altkm, lat, lon).squeeze() except ConnectionError: pytest.skip("unable to download RecentIndices.txt") - xarray.tests.assert_allclose(ref, dat_mod) + xarray.testing.assert_allclose(ref, dat_mod) @pytest.mark.parametrize("altkm,reffn", [(100.0, "ref5.nc"), (200.0, "ref6.nc")]) @@ -45,4 +45,4 @@ def test_script(altkm, reffn, tmp_path): subprocess.check_call(cmd) dat = xarray.open_dataset(fn) - xarray.tests.assert_allclose(ref, dat) + xarray.testing.assert_allclose(ref, dat) diff --git a/src/msise00/tests/test_time_grid.py b/src/msise00/tests/test_time_grid.py index b4a74d1..d479391 100644 --- a/src/msise00/tests/test_time_grid.py +++ b/src/msise00/tests/test_time_grid.py @@ -8,7 +8,7 @@ import subprocess import pytest import xarray -import xarray.tests +import xarray.testing import msise00 import msise00.worldgrid @@ -28,7 +28,7 @@ def test_multiple_time(): dat_mod = msise00.run(time, altkm, lat, lon).squeeze() except ConnectionError: pytest.skip("unable to download RecentIndices.txt") - xarray.tests.assert_allclose(ref, dat_mod) + xarray.testing.assert_allclose(ref, dat_mod) def test_script(tmp_path): @@ -43,4 +43,4 @@ def test_script(tmp_path): subprocess.check_call(cmd) dat = xarray.open_dataset(fn) - xarray.tests.assert_allclose(ref, dat) + xarray.testing.assert_allclose(ref, dat)