Skip to content

Commit c4ef354

Browse files
gfyoungNo-Stream
authored andcommitted
COMPAT: Suppress .take() warning for numpy < 1.12 (pandas-dev#17764)
Follow-up to pandas-devgh-17352.
1 parent 2e15a53 commit c4ef354

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pandas/tests/sparse/test_series.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
import numpy as np
1010
import pandas as pd
1111

12-
from pandas import Series, DataFrame, bdate_range, isna, compat
12+
from pandas import (Series, DataFrame, bdate_range,
13+
isna, compat, _np_version_under1p12)
1314
from pandas.tseries.offsets import BDay
1415
import pandas.util.testing as tm
1516
from pandas.compat import range
@@ -527,8 +528,13 @@ def test_numpy_take(self):
527528
sp = SparseSeries([1.0, 2.0, 3.0])
528529
indices = [1, 2]
529530

530-
tm.assert_series_equal(np.take(sp, indices, axis=0).to_dense(),
531-
np.take(sp.to_dense(), indices, axis=0))
531+
# gh-17352: older versions of numpy don't properly
532+
# pass in arguments to downstream .take() implementations.
533+
warning = FutureWarning if _np_version_under1p12 else None
534+
535+
with tm.assert_produces_warning(warning, check_stacklevel=False):
536+
tm.assert_series_equal(np.take(sp, indices, axis=0).to_dense(),
537+
np.take(sp.to_dense(), indices, axis=0))
532538

533539
msg = "the 'out' parameter is not supported"
534540
tm.assert_raises_regex(ValueError, msg, np.take,

0 commit comments

Comments
 (0)