def test_cython_group_mean_wrong_min_count(): actual = np.zeros(shape=(1, 1), dtype="float64") counts = np.zeros(1, dtype="int64") data = np.zeros(1, dtype="float64")[:, None] labels = np.zeros(1, dtype=np.intp) with pytest.raises(AssertionError, match="min_count"): group_mean(actual, counts, data, labels, is_datetimelike=True, min_count=0)
def test_cython_group_mean_not_datetimelike_but_has_NaT_values(): actual = np.zeros(shape=(1, 1), dtype="float64") counts = np.array([0], dtype="int64") data = (np.array( [np.timedelta64("NaT"), np.timedelta64("NaT")], dtype="m8[ns]", )[:, None].view("int64").astype("float64")) labels = np.zeros(len(data), dtype=np.intp) group_mean(actual, counts, data, labels, is_datetimelike=False) tm.assert_numpy_array_equal( actual[:, 0], np.array(np.divide(np.add(data[0], data[1]), 2), dtype="float64"))
def test_cython_group_mean_datetimelike(): actual = np.zeros(shape=(1, 1), dtype="float64") counts = np.array([0], dtype="int64") data = (np.array( [ np.timedelta64(2, "ns"), np.timedelta64(4, "ns"), np.timedelta64("NaT") ], dtype="m8[ns]", )[:, None].view("int64").astype("float64")) labels = np.zeros(len(data), dtype=np.intp) group_mean(actual, counts, data, labels, is_datetimelike=True) tm.assert_numpy_array_equal(actual[:, 0], np.array([3], dtype="float64"))