Skip to content

Commit

Permalink
Add QartodClimtologyMissingTest() to
Browse files Browse the repository at this point in the history
Test to capture test scenario provided here ioos#65
  • Loading branch information
iwensu0313 committed Apr 1, 2024
1 parent f2ec6b2 commit 518c9f7
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/test_qartod.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,62 @@ def test_climatology_test_all_unknown(self):
self._run_test(test_inputs, expected_result)



class QartodClimatologyMissingTest(unittest.TestCase):
def setUp(self):
self.cc = qartod.ClimatologyConfig()
# different time range, no depth
self.cc.add(
tspan=(np.datetime64('2021-07'), np.datetime64('2021-09')),
vspan=(3.4, 5)
)

def _run_test(self, test_inputs, expected_result):
times, values, depths = zip(*test_inputs)
inputs = [
values,
np.asarray(values, dtype=np.float64),
dask_arr(np.asarray(values, dtype=np.float64))
]

for i in inputs:
results = qartod.climatology_test(
config=self.cc,
tinp=times,
inp=i,
zinp=depths
)
npt.assert_array_equal(
results,
np.ma.array(expected_result)
)

def test_climatology_missing_values(self):
test_inputs = [
# Not missing value or depth, value out of bounds
(
np.datetime64('2021-07-16'),
0,
0
),
# Missing value and depth
(
np.datetime64('2021-07-16'),
np.nan,
np.nan
),
# Not missing value and depth, value within bounds
(
np.datetime64('2021-07-16'),
4.16743,
0.08931513
)
]
expected_result = [3, 9, 1]
self._run_test(test_inputs, expected_result)



class QartodClimatologyTest(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -859,6 +915,7 @@ def test_climatology_test_depths(self):
]
expected_result = [1, 1, 1, 3, 3, 3]
self._run_test(test_inputs, expected_result)



class QartodSpikeTest(unittest.TestCase):
Expand Down

0 comments on commit 518c9f7

Please sign in to comment.