Skip to content

Commit 0a8ef62

Browse files
author
pilkibun
committed
TST: add tests for DecimalArray round and sum
1 parent 6c2ca29 commit 0a8ef62

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pandas/tests/extension/decimal/test_decimal.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import numpy as np
66
import pytest
77

8+
import pandas.util._test_decorators as td
9+
810
import pandas as pd
911
from pandas.tests.extension import base
1012
import pandas.util.testing as tm
@@ -380,6 +382,26 @@ def test_divmod_array(reverse, expected_div, expected_mod):
380382
tm.assert_extension_array_equal(mod, expected_mod)
381383

382384

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+
383405
def test_formatting_values_deprecated():
384406
class DecimalArray2(DecimalArray):
385407
def _formatting_values(self):

0 commit comments

Comments
 (0)