From 87c97f593e915fcc93d29762c6886c9261db9eac Mon Sep 17 00:00:00 2001 From: galipremsagar Date: Tue, 17 Aug 2021 13:15:16 -0500 Subject: [PATCH] Add tests and address reviews --- python/cudf/cudf/tests/test_datetime.py | 9 +++++++++ python/cudf/cudf/tests/test_timedelta.py | 9 +++++++++ python/dask_cudf/dask_cudf/backends.py | 3 ++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/python/cudf/cudf/tests/test_datetime.py b/python/cudf/cudf/tests/test_datetime.py index 96d50c66f7e..9f19bf8b960 100644 --- a/python/cudf/cudf/tests/test_datetime.py +++ b/python/cudf/cudf/tests/test_datetime.py @@ -1541,3 +1541,12 @@ def test_is_quarter_end(data, dtype): got = gs.dt.is_quarter_end assert_eq(expect, got) + + +def test_error_values(): + s = cudf.Series([1, 2, 3], dtype="datetime64[ns]") + with pytest.raises( + NotImplementedError, + match="DateTime Arrays is not yet implemented in cudf", + ): + s.values diff --git a/python/cudf/cudf/tests/test_timedelta.py b/python/cudf/cudf/tests/test_timedelta.py index a65fdeeb0dd..75923a0b284 100644 --- a/python/cudf/cudf/tests/test_timedelta.py +++ b/python/cudf/cudf/tests/test_timedelta.py @@ -1386,3 +1386,12 @@ def test_timedelta_reductions(data, op, dtype): assert True else: assert_eq(expected.to_numpy(), actual) + + +def test_error_values(): + s = cudf.Series([1, 2, 3], dtype="timedelta64[ns]") + with pytest.raises( + NotImplementedError, + match="TimeDelta Arrays is not yet implemented in cudf", + ): + s.values diff --git a/python/dask_cudf/dask_cudf/backends.py b/python/dask_cudf/dask_cudf/backends.py index 419da1eaa11..c0204190957 100644 --- a/python/dask_cudf/dask_cudf/backends.py +++ b/python/dask_cudf/dask_cudf/backends.py @@ -263,6 +263,8 @@ def is_categorical_dtype_cudf(obj): @percentile_dispatch.register((cudf.Series, cp.ndarray, cudf.Index)) def percentile_cudf(a, q, interpolation="linear"): + # Cudf dispatch to the equivalent of `np.percentile`: + # https://numpy.org/doc/stable/reference/generated/numpy.percentile.html a = cudf.Series(a) # a is series. n = len(a) @@ -273,7 +275,6 @@ def percentile_cudf(a, q, interpolation="linear"): if cudf.utils.dtypes.is_categorical_dtype(a.dtype): result = cp.percentile(a.cat.codes, q, interpolation=interpolation) - import pandas as pd return ( pd.Categorical.from_codes(