Skip to content

Commit f4098c3

Browse files
jorisvandenbosscheTomAugspurger
authored andcommitted
TST: filter warnings for is_extension_type deprecation (#29549)
1 parent 07efdd4 commit f4098c3

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

pandas/core/dtypes/common.py

+1
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,7 @@ def is_extension_type(arr):
15081508
Check whether an array-like is of a pandas extension class instance.
15091509
15101510
.. deprecated:: 1.0.0
1511+
Use ``is_extension_array_dtype`` instead.
15111512
15121513
Extension classes include categoricals, pandas sparse objects (i.e.
15131514
classes represented within the pandas library and not ones external

pandas/tests/dtypes/test_common.py

+30
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ def test_is_bool_dtype():
549549
assert com.is_bool_dtype(pd.Index([True, False]))
550550

551551

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

575576

577+
def test_is_extension_type_deprecation():
578+
with tm.assert_produces_warning(FutureWarning):
579+
com.is_extension_type([1, 2, 3])
580+
581+
582+
@pytest.mark.parametrize(
583+
"check_scipy", [False, pytest.param(True, marks=td.skip_if_no_scipy)]
584+
)
585+
def test_is_extension_array_dtype(check_scipy):
586+
assert not com.is_extension_array_dtype([1, 2, 3])
587+
assert not com.is_extension_array_dtype(np.array([1, 2, 3]))
588+
assert not com.is_extension_array_dtype(pd.DatetimeIndex([1, 2, 3]))
589+
590+
cat = pd.Categorical([1, 2, 3])
591+
assert com.is_extension_array_dtype(cat)
592+
assert com.is_extension_array_dtype(pd.Series(cat))
593+
assert com.is_extension_array_dtype(pd.SparseArray([1, 2, 3]))
594+
assert com.is_extension_array_dtype(pd.DatetimeIndex(["2000"], tz="US/Eastern"))
595+
596+
dtype = DatetimeTZDtype("ns", tz="US/Eastern")
597+
s = pd.Series([], dtype=dtype)
598+
assert com.is_extension_array_dtype(s)
599+
600+
if check_scipy:
601+
import scipy.sparse
602+
603+
assert not com.is_extension_array_dtype(scipy.sparse.bsr_matrix([1, 2, 3]))
604+
605+
576606
def test_is_complex_dtype():
577607
assert not com.is_complex_dtype(int)
578608
assert not com.is_complex_dtype(str)

0 commit comments

Comments
 (0)