def test_gross_range_check_masked(self): """See if user and sensor ranges are picked up.""" fail_span = (10, 50) suspect_span = (20, 40) vals = [ None, # None 10, # Sensor range. 15, # User range. 20, 25, 30, 35, 40, # Valid np.nan, # np.nan 51, # Sensor range. np.ma.masked # np.ma.masked ] result = np.ma.array([9, 3, 3, 1, 1, 1, 1, 1, 9, 4, 9]) with warnings.catch_warnings(): warnings.simplefilter("ignore") inputs = [ vals, np.array(vals, dtype=np.floating), dask_arr(np.array(vals, dtype=np.floating)) ] for i in inputs: npt.assert_array_equal( qartod.gross_range_test(vals, fail_span, suspect_span), result)
def test_gross_range_check(self): """See if user and sensor ranges are picked up.""" fail_span = (10, 50) suspect_span = (20, 40) vals = [ 5, 10, # Sensor range. 15, # User range. 20, 25, 30, 35, 40, # Valid 45, # User range. 51 # Sensor range. ] result = np.ma.array([4, 3, 3, 1, 1, 1, 1, 1, 3, 4]) with warnings.catch_warnings(): warnings.simplefilter("ignore") inputs = [ vals, np.array(vals, dtype=np.integer), np.array(vals, dtype=np.floating), dask_arr(np.array(vals, dtype=np.integer)), dask_arr(np.array(vals, dtype=np.floating)) ] for i in inputs: npt.assert_array_equal( qartod.gross_range_test(inp=i, fail_span=fail_span, suspect_span=suspect_span), result)
def test_gross_range_bad_input(self): with self.assertRaises(ValueError): qartod.gross_range_test(inp=np.array([5]), fail_span=10, suspect_span=(1, 1)) with self.assertRaises(ValueError): qartod.gross_range_test(inp=np.array([5]), fail_span=(1, 1), suspect_span=10) with self.assertRaises(ValueError): qartod.gross_range_test(inp=np.array([5]), fail_span=(1, 1), suspect_span=(2, 2))