@@ -0,0 +1,22 @@ |
|
|
|
1 |
+import pytest |
|
2 |
+ |
|
3 |
+from pandas.tests.extension.decimal.array import to_decimal |
|
4 |
+import pandas.util.testing as tm |
|
5 |
+ |
|
6 |
+ |
|
7 |
+@pytest.mark.parametrize("reverse, expected_div, expected_mod", [ |
|
8 |
+ (False, [0, 1, 1, 2], [1, 0, 1, 0]), |
|
9 |
+ (True, [2, 1, 0, 0], [0, 0, 2, 2]), |
|
10 |
+]) |
|
11 |
+def test_divmod(reverse, expected_div, expected_mod): |
|
12 |
+# https://github.com/pandas-dev/pandas/issues/22930 |
|
13 |
+arr = to_decimal([1, 2, 3, 4]) |
|
14 |
+if reverse: |
|
15 |
+div, mod = divmod(2, arr) |
|
16 |
+else: |
|
17 |
+div, mod = divmod(arr, 2) |
|
18 |
+expected_div = to_decimal(expected_div) |
|
19 |
+expected_mod = to_decimal(expected_mod) |
|
20 |
+ |
|
21 |
+tm.assert_extension_array_equal(div, expected_div) |
|
22 |
+tm.assert_extension_array_equal(mod, expected_mod) |