Skip to content

Commit

Permalink
TST: filter warnings for is_extension_type deprecation (#29549)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche authored and TomAugspurger committed Nov 11, 2019
1 parent 07efdd4 commit f4098c3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,7 @@ def is_extension_type(arr):
Check whether an array-like is of a pandas extension class instance.
.. deprecated:: 1.0.0
Use ``is_extension_array_dtype`` instead.
Extension classes include categoricals, pandas sparse objects (i.e.
classes represented within the pandas library and not ones external
Expand Down
30 changes: 30 additions & 0 deletions pandas/tests/dtypes/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ def test_is_bool_dtype():
assert com.is_bool_dtype(pd.Index([True, False]))


@pytest.mark.filterwarnings("ignore:'is_extension_type' is deprecated:FutureWarning")
@pytest.mark.parametrize(
"check_scipy", [False, pytest.param(True, marks=td.skip_if_no_scipy)]
)
Expand All @@ -573,6 +574,35 @@ def test_is_extension_type(check_scipy):
assert not com.is_extension_type(scipy.sparse.bsr_matrix([1, 2, 3]))


def test_is_extension_type_deprecation():
with tm.assert_produces_warning(FutureWarning):
com.is_extension_type([1, 2, 3])


@pytest.mark.parametrize(
"check_scipy", [False, pytest.param(True, marks=td.skip_if_no_scipy)]
)
def test_is_extension_array_dtype(check_scipy):
assert not com.is_extension_array_dtype([1, 2, 3])
assert not com.is_extension_array_dtype(np.array([1, 2, 3]))
assert not com.is_extension_array_dtype(pd.DatetimeIndex([1, 2, 3]))

cat = pd.Categorical([1, 2, 3])
assert com.is_extension_array_dtype(cat)
assert com.is_extension_array_dtype(pd.Series(cat))
assert com.is_extension_array_dtype(pd.SparseArray([1, 2, 3]))
assert com.is_extension_array_dtype(pd.DatetimeIndex(["2000"], tz="US/Eastern"))

dtype = DatetimeTZDtype("ns", tz="US/Eastern")
s = pd.Series([], dtype=dtype)
assert com.is_extension_array_dtype(s)

if check_scipy:
import scipy.sparse

assert not com.is_extension_array_dtype(scipy.sparse.bsr_matrix([1, 2, 3]))


def test_is_complex_dtype():
assert not com.is_complex_dtype(int)
assert not com.is_complex_dtype(str)
Expand Down

0 comments on commit f4098c3

Please sign in to comment.