Skip to content

Commit

Permalink
COMPAT: Suppress .take() warning for numpy < 1.12 (pandas-dev#17764)
Browse files Browse the repository at this point in the history
Follow-up to pandas-devgh-17352.
  • Loading branch information
gfyoung authored and Krzysztof Chomski committed Oct 16, 2017
1 parent 3d9a59b commit ef52915
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pandas/tests/sparse/test_series.py
Expand Up @@ -9,7 +9,8 @@
import numpy as np
import pandas as pd

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

tm.assert_series_equal(np.take(sp, indices, axis=0).to_dense(),
np.take(sp.to_dense(), indices, axis=0))
# gh-17352: older versions of numpy don't properly
# pass in arguments to downstream .take() implementations.
warning = FutureWarning if _np_version_under1p12 else None

with tm.assert_produces_warning(warning, check_stacklevel=False):
tm.assert_series_equal(np.take(sp, indices, axis=0).to_dense(),
np.take(sp.to_dense(), indices, axis=0))

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

0 comments on commit ef52915

Please sign in to comment.