|
8 | 8 |
|
9 | 9 | from pandas.tests.extension import base
|
10 | 10 |
|
11 |
| -from .array import DecimalDtype, DecimalArray |
| 11 | +from .array import DecimalDtype, DecimalArray, to_decimal |
12 | 12 |
|
13 | 13 |
|
14 | 14 | def make_data():
|
@@ -244,6 +244,23 @@ def test_arith_series_with_array(self, data, all_arithmetic_operators):
|
244 | 244 | context.traps[decimal.DivisionByZero] = divbyzerotrap
|
245 | 245 | context.traps[decimal.InvalidOperation] = invalidoptrap
|
246 | 246 |
|
| 247 | + @pytest.mark.parametrize("reverse, expected_div, expected_mod", [ |
| 248 | + (False, [0, 1, 1, 2], [1, 0, 1, 0]), |
| 249 | + (True, [2, 1, 0, 0], [0, 0, 2, 2]), |
| 250 | + ]) |
| 251 | + def test_divmod_array(self, reverse, expected_div, expected_mod): |
| 252 | + # https://github.com/pandas-dev/pandas/issues/22930 |
| 253 | + arr = to_decimal([1, 2, 3, 4]) |
| 254 | + if reverse: |
| 255 | + div, mod = divmod(2, arr) |
| 256 | + else: |
| 257 | + div, mod = divmod(arr, 2) |
| 258 | + expected_div = to_decimal(expected_div) |
| 259 | + expected_mod = to_decimal(expected_mod) |
| 260 | + |
| 261 | + tm.assert_extension_array_equal(div, expected_div) |
| 262 | + tm.assert_extension_array_equal(mod, expected_mod) |
| 263 | + |
247 | 264 | def test_divmod(self, data):
|
248 | 265 | s = pd.Series(data, name='name')
|
249 | 266 | a, b = divmod(s, 2)
|
|
0 commit comments