Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tztsai committed Jan 16, 2024
1 parent d522f32 commit 33d5114
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 630 deletions.
58 changes: 0 additions & 58 deletions tests/unit/splash/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from importlib import resources

import numpy as np
import pytest
import xarray

Expand All @@ -20,63 +19,6 @@ def splash_core_constants():
return CoreConst(k_To=288.15, water_density_method="chen")


@pytest.fixture()
def daily_flux_benchmarks() -> tuple[np.ndarray, np.ndarray]:
"""Test daily values.
Loads an input file and SPLASH outputs for 100 random locations with a wide range of
possible input values. Not intended for testing time series iteration, just the
daily predictions of all core variables.
"""

dpath = resources.files("pyrealm_build_data.splash")

inputs = np.genfromtxt(
str(dpath / "inputs.csv"),
dtype=None,
delimiter=",",
names=True,
encoding="UTF-8",
)

expected = np.genfromtxt(
str(dpath / "benchmark_daily_fluxes.csv"),
dtype=None,
delimiter=",",
names=True,
encoding="UTF-8",
)

# rename a couple of fields to match new implementation
assert expected.dtype.names is not None
exp_fields = list(expected.dtype.names)
exp_fields[exp_fields.index("my_nu")] = "nu"
exp_fields[exp_fields.index("my_lambda")] = "lambda_"
expected.dtype.names = tuple(exp_fields)

return inputs, expected


@pytest.fixture()
def one_d_benchmark() -> tuple[xarray.Dataset, xarray.Dataset]:
"""Test one dimensional time series.
Loads the input data and resulting soil moisture outputs from the single location
San Francisco dataset provided with the original implementation. These were
originally calculated using the __main__ code in SPLASH main.py, but the data has
bee converted to netCDF and run using an alternative interface in order to retain
more validation data.
"""

dpath = resources.files("pyrealm_build_data.splash")

inputs = xarray.load_dataset(dpath / "splash_test_example.nc")

expected = xarray.load_dataset(dpath / "splash_test_example_out.nc")

return inputs, expected


@pytest.fixture()
def grid_benchmarks() -> tuple[xarray.Dataset, xarray.Dataset]:
"""Test 3D time series.
Expand Down
184 changes: 0 additions & 184 deletions tests/unit/splash/test_evap.py

This file was deleted.

Loading

0 comments on commit 33d5114

Please sign in to comment.