|
6 | 6 |
|
7 | 7 | import cudf
|
8 | 8 | from cudf.tests.utils import INTEGER_TYPES, NUMERIC_TYPES, assert_eq, gen_rand
|
| 9 | +from cudf.core.dtypes import Decimal64Dtype |
9 | 10 |
|
10 | 11 | params_sizes = [0, 1, 2, 5]
|
11 | 12 |
|
@@ -61,6 +62,21 @@ def test_cumsum_masked():
|
61 | 62 | assert_eq(got, expected)
|
62 | 63 |
|
63 | 64 |
|
| 65 | +@pytest.mark.parametrize( |
| 66 | + "dtype", |
| 67 | + [Decimal64Dtype(8, 4), Decimal64Dtype(10, 5), Decimal64Dtype(12, 7)], |
| 68 | +) |
| 69 | +def test_cumsum_decimal(dtype): |
| 70 | + data = ["243.32", "48.245", "-7234.298", np.nan, "-467.2"] |
| 71 | + gser = cudf.Series(data).astype(dtype) |
| 72 | + pser = pd.Series(data, dtype="float64") |
| 73 | + |
| 74 | + got = gser.cumsum() |
| 75 | + expected = cudf.Series.from_pandas(pser.cumsum()).astype(dtype) |
| 76 | + |
| 77 | + assert_eq(got, expected) |
| 78 | + |
| 79 | + |
64 | 80 | @pytest.mark.parametrize("dtype,nelem", list(_gen_params()))
|
65 | 81 | def test_cummin(dtype, nelem):
|
66 | 82 | if dtype == np.int8:
|
@@ -103,6 +119,21 @@ def test_cummin_masked():
|
103 | 119 | assert_eq(gs.cummin(), expected)
|
104 | 120 |
|
105 | 121 |
|
| 122 | +@pytest.mark.parametrize( |
| 123 | + "dtype", |
| 124 | + [Decimal64Dtype(8, 4), Decimal64Dtype(11, 6), Decimal64Dtype(14, 7)], |
| 125 | +) |
| 126 | +def test_cummin_decimal(dtype): |
| 127 | + data = ["8394.294", np.nan, "-9940.444", np.nan, "-23.928"] |
| 128 | + gser = cudf.Series(data).astype(dtype) |
| 129 | + pser = pd.Series(data, dtype="float64") |
| 130 | + |
| 131 | + got = gser.cummin() |
| 132 | + expected = cudf.Series.from_pandas(pser.cummin()).astype(dtype) |
| 133 | + |
| 134 | + assert_eq(got, expected) |
| 135 | + |
| 136 | + |
106 | 137 | @pytest.mark.parametrize("dtype,nelem", list(_gen_params()))
|
107 | 138 | def test_cummax(dtype, nelem):
|
108 | 139 | if dtype == np.int8:
|
@@ -145,6 +176,21 @@ def test_cummax_masked():
|
145 | 176 | assert_eq(gs.cummax(), expected)
|
146 | 177 |
|
147 | 178 |
|
| 179 | +@pytest.mark.parametrize( |
| 180 | + "dtype", |
| 181 | + [Decimal64Dtype(8, 4), Decimal64Dtype(11, 6), Decimal64Dtype(14, 7)], |
| 182 | +) |
| 183 | +def test_cummax_decimal(dtype): |
| 184 | + data = [np.nan, "54.203", "8.222", "644.32", "-562.272"] |
| 185 | + gser = cudf.Series(data).astype(dtype) |
| 186 | + pser = pd.Series(data, dtype="float64") |
| 187 | + |
| 188 | + got = gser.cummax() |
| 189 | + expected = cudf.Series.from_pandas(pser.cummax()).astype(dtype) |
| 190 | + |
| 191 | + assert_eq(got, expected) |
| 192 | + |
| 193 | + |
148 | 194 | @pytest.mark.parametrize("dtype,nelem", list(_gen_params()))
|
149 | 195 | def test_cumprod(dtype, nelem):
|
150 | 196 | if dtype == np.int8:
|
|
0 commit comments