def test_deprecation(self, tas_series): with pytest.warns(FutureWarning): out = utils.convert_units_to(0, units.K) assert out == 273.15 out = utils.convert_units_to(10, units.mm / units.day, context='hydro') assert out == 10 with pytest.warns(FutureWarning): tas = tas_series(np.arange(365), start='1/1/2001') out = ind.tx_days_above(tas, 30) out1 = ind.tx_days_above(tas, '30 degC') out2 = ind.tx_days_above(tas, '303.15 K') np.testing.assert_array_equal(out, out1) np.testing.assert_array_equal(out, out2)
def test_simple(self, tasmax_series): a = np.zeros(365) a[:6] += [27, 28, 29, 30, 31, 32] # 2 above 30 mx = tasmax_series(a + K2C) out = xci.tx_days_above(mx, thresh="30 C") np.testing.assert_array_equal(out[:1], [2]) np.testing.assert_array_equal(out[1:], [0])
def test_deprecation(self, tas_series): with pytest.warns(FutureWarning): out = convert_units_to(0, units.K) assert out == 273.15 with pytest.warns(FutureWarning): out = convert_units_to(10, units.mm / units.day, context="hydro") assert out == 10 with pytest.warns(FutureWarning): tas = tas_series(np.arange(365), start="1/1/2001") out = indices.tx_days_above(tas, 30) out1 = indices.tx_days_above(tas, "30 degC") out2 = indices.tx_days_above(tas, "303.15 K") np.testing.assert_array_equal(out, out1) np.testing.assert_array_equal(out, out2) assert out1.name == tas.name