|
5 | 5 | import numpy as np
|
6 | 6 | import pytest
|
7 | 7 |
|
| 8 | +import pandas.util._test_decorators as td |
| 9 | + |
8 | 10 | import pandas as pd
|
9 | 11 | from pandas.tests.extension import base
|
10 | 12 | import pandas.util.testing as tm
|
@@ -380,6 +382,26 @@ def test_divmod_array(reverse, expected_div, expected_mod):
|
380 | 382 | tm.assert_extension_array_equal(mod, expected_mod)
|
381 | 383 |
|
382 | 384 |
|
| 385 | +# numpy 1.17 has NEP-18 on by default |
| 386 | +# for numpy 1.16 set shell variable with |
| 387 | +# "export NUMPY_EXPERIMENTAL_ARRAY_FUNCTION=1" |
| 388 | +# before running pytest/python. |
| 389 | +# verify by checking value of `np.core.overrides.ENABLE_ARRAY_FUNCTION` |
| 390 | +@td.skip_if_no_NEP18 |
| 391 | +def test_series_round(): |
| 392 | + ser = pd.Series(to_decimal([1.1, 2.4, 3.1])).round() |
| 393 | + expected = pd.Series(to_decimal([1, 2, 3])) |
| 394 | + tm.assert_extension_array_equal(ser.array, expected.array) |
| 395 | + tm.assert_series_equal(ser, expected) |
| 396 | + |
| 397 | + |
| 398 | +@td.skip_if_no_NEP18 |
| 399 | +def test_series_round_then_sum(): |
| 400 | + result = pd.Series(to_decimal([1.1, 2.4, 3.1])).round().sum(skipna=False) |
| 401 | + expected = decimal.Decimal("6") |
| 402 | + assert result == expected |
| 403 | + |
| 404 | + |
383 | 405 | def test_formatting_values_deprecated():
|
384 | 406 | class DecimalArray2(DecimalArray):
|
385 | 407 | def _formatting_values(self):
|
|
0 commit comments