def _run_test(self, tspan, period): cc = qartod.ClimatologyConfig() cc.add( vspan=(10, 20), # range of valid values tspan=tspan, # jan, feb and march period=period) test_inputs = [ # in feb, but outside range of valid values (np.datetime64('2011-02-02'), 9, None), # in feb, and within range of valid values (np.datetime64('2013-02-03'), 11, None), # Not run, outside of time range (np.datetime64('2011-04-01'), 21, None), # Not run, outside of time range (np.datetime64('2011-12-31'), 21, None), # leap day, with valid values (np.datetime64('2020-02-29'), 15, None), ] times, values, depths = zip(*test_inputs) inputs = [ values, np.asarray(values, dtype=np.floating), dask_arr(np.asarray(values, dtype=np.floating)) ] for i in inputs: results = qartod.climatology_test(config=cc, tinp=times, inp=i, zinp=depths) npt.assert_array_equal(results, np.ma.array([3, 1, 2, 2, 1]))
def _run_test(self, test_inputs, expected_result): times, values, depths = zip(*test_inputs) inputs = [ values, np.asarray(values, dtype=np.floating), dask_arr(np.asarray(values, dtype=np.floating)) ] 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_test(self): tests = [(np.datetime64('2011-01-02'), 11, None)] times, values, depths = zip(*tests) inputs = [ values, np.asarray(values, dtype=np.floating), dask_arr(np.asarray(values, dtype=np.floating)) ] 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([1]))
def test_climatology_test_depths(self): tests = [(np.datetime64('2012-01-02'), 51, 2), (np.datetime64('2012-01-02'), 71, 90), (np.datetime64('2012-01-02'), 42, None), (np.datetime64('2012-01-02'), 59, 11), (np.datetime64('2012-01-02'), 79, 101)] times, values, depths = zip(*tests) inputs = [ values, np.asarray(values, dtype=np.floating), dask_arr(np.asarray(values, dtype=np.floating)) ] 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([1, 1, 1, 3, 9]))
def _run_test(self, cc): # just run test and make sure we don't get any errors qartod.climatology_test(config=cc, tinp=self.tinp, inp=self.values, zinp=self.zinp)