Skip to content

Commit b96f320

Browse files
jbrockmendeljreback
authored andcommitted
TST: Remove maybe_promote tests for iNaT as an NA value (#28775)
1 parent 31994ca commit b96f320

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

pandas/tests/dtypes/cast/test_promote.py

+6-34
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import numpy as np
88
import pytest
99

10-
from pandas._libs.tslibs import NaT, iNaT
10+
from pandas._libs.tslibs import NaT
1111
from pandas.compat import is_platform_windows
1212

1313
from pandas.core.dtypes.cast import maybe_promote
@@ -19,7 +19,6 @@
1919
is_integer_dtype,
2020
is_object_dtype,
2121
is_scalar,
22-
is_string_dtype,
2322
is_timedelta64_dtype,
2423
)
2524
from pandas.core.dtypes.dtypes import DatetimeTZDtype
@@ -156,7 +155,7 @@ def _assert_match(result_fill_value, expected_fill_value):
156155
match_value = result_fill_value == expected_fill_value
157156

158157
# Note: type check above ensures that we have the _same_ NA value
159-
# for missing values, None == None and iNaT == iNaT (which is checked
158+
# for missing values, None == None (which is checked
160159
# through match_value above), but np.nan != np.nan and pd.NaT != pd.NaT
161160
match_missing = isna(result_fill_value) and isna(expected_fill_value)
162161

@@ -536,22 +535,15 @@ def test_maybe_promote_datetimetz_with_datetimetz(
536535
)
537536

538537

539-
@pytest.mark.parametrize("fill_value", [None, np.nan, NaT, iNaT])
538+
@pytest.mark.parametrize("fill_value", [None, np.nan, NaT])
540539
# override parametrization due to to many xfails; see GH 23982 / 25425
541540
@pytest.mark.parametrize("box", [(False, None)])
542541
def test_maybe_promote_datetimetz_with_na(tz_aware_fixture, fill_value, box):
543542

544543
dtype = DatetimeTZDtype(tz=tz_aware_fixture)
545544
boxed, box_dtype = box # read from parametrized fixture
546545

547-
# takes the opinion that DatetimeTZ should have single na-marker
548-
# using iNaT would lead to errors elsewhere -> NaT
549-
if not boxed and fill_value == iNaT:
550-
# TODO: are we sure iNaT _should_ be cast to NaT?
551-
pytest.xfail("wrong missing value marker")
552-
553546
expected_dtype = dtype
554-
# DatetimeTZDtype does not use iNaT as missing value marker
555547
exp_val_for_scalar = NaT
556548
exp_val_for_array = NaT
557549

@@ -820,7 +812,7 @@ def test_maybe_promote_any_with_object(any_numpy_dtype_reduced, object_dtype, bo
820812
)
821813

822814

823-
@pytest.mark.parametrize("fill_value", [None, np.nan, NaT, iNaT])
815+
@pytest.mark.parametrize("fill_value", [None, np.nan, NaT])
824816
# override parametrization due to to many xfails; see GH 23982 / 25425
825817
@pytest.mark.parametrize("box", [(False, None)])
826818
def test_maybe_promote_any_numpy_dtype_with_na(
@@ -836,37 +828,17 @@ def test_maybe_promote_any_numpy_dtype_with_na(
836828
and fill_value is not NaT
837829
):
838830
pytest.xfail("does not upcast to object")
839-
elif dtype == "uint64" and not boxed and fill_value == iNaT:
840-
pytest.xfail("does not upcast correctly")
841-
# below: opinionated that iNaT should be interpreted as missing value
842-
elif (
843-
not boxed
844-
and (is_float_dtype(dtype) or is_complex_dtype(dtype))
845-
and fill_value == iNaT
846-
):
847-
pytest.xfail("does not cast to missing value marker correctly")
848-
elif (is_string_dtype(dtype) or dtype == bool) and not boxed and fill_value == iNaT:
849-
pytest.xfail("does not cast to missing value marker correctly")
850-
851-
if is_integer_dtype(dtype) and dtype == "uint64" and fill_value == iNaT:
852-
# uint64 + negative int casts to object; iNaT is considered as missing
853-
expected_dtype = np.dtype(object)
854-
exp_val_for_scalar = np.nan
855-
elif is_integer_dtype(dtype) and fill_value == iNaT:
856-
# other integer + iNaT casts to int64
857-
expected_dtype = np.int64
858-
exp_val_for_scalar = iNaT
859831
elif is_integer_dtype(dtype) and fill_value is not NaT:
860832
# integer + other missing value (np.nan / None) casts to float
861833
expected_dtype = np.float64
862834
exp_val_for_scalar = np.nan
863-
elif is_object_dtype(dtype) and (fill_value == iNaT or fill_value is NaT):
835+
elif is_object_dtype(dtype) and fill_value is NaT:
864836
# inserting into object does not cast the value
865837
# but *does* cast None to np.nan
866838
expected_dtype = np.dtype(object)
867839
exp_val_for_scalar = fill_value
868840
elif is_datetime_or_timedelta_dtype(dtype):
869-
# datetime / timedelta cast all missing values to iNaT
841+
# datetime / timedelta cast all missing values to dtyped-NaT
870842
expected_dtype = dtype
871843
exp_val_for_scalar = dtype.type("NaT", "ns")
872844
elif fill_value is NaT:

0 commit comments

Comments
 (0)