8000 TST: port maybe_promote tests from #23982 by jbrockmendel · Pull Request #28764 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

TST: port maybe_promote tests from #23982 #28764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 3, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
TST: port more tests from 23892
  • Loading branch information
jbrockmendel committed Oct 3, 2019
commit 2c6114046bf308150bfd9794f3871d89496b557d
42 changes: 39 additions & 3 deletions pandas/tests/dtypes/cast/test_promote.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,45 @@ def test_maybe_promote_any_with_bytes():
pass


def test_maybe_promote_datetime64_with_any():
# placeholder due to too many xfails; see GH 23982 / 25425
pass
def test_maybe_promote_datetime64_with_any(
datetime64_dtype, any_numpy_dtype_reduced, box
):
dtype = np.dtype(datetime64_dtype)
fill_dtype = np.dtype(any_numpy_dtype_reduced)
boxed, box_dtype = box # read from parametrized fixture

if is_datetime64_dtype(fill_dtype):
if box_dtype == object:
pytest.xfail("falsely upcasts to object")
else:
if boxed and box_dtype is None:
pytest.xfail("does not upcast to object")
if not boxed:
pytest.xfail("does not upcast to object or raises")

# create array of given dtype; casts "1" to correct dtype
fill_value = np.array([1], dtype=fill_dtype)[0]

# filling datetime with anything but datetime casts to object
if is_datetime64_dtype(fill_dtype):
expected_dtype = dtype
# for datetime dtypes, scalar values get cast to to_datetime64
exp_val_for_scalar = pd.Timestamp(fill_value).to_datetime64()
exp_val_for_array = np.datetime64("NaT", "ns")
else:
expected_dtype = np.dtype(object)
exp_val_for_scalar = fill_value
exp_val_for_array = np.nan

_check_promote(
dtype,
fill_value,
boxed,
box_dtype,
expected_dtype,
exp_val_for_scalar,
exp_val_for_array,
)


# override parametrization of box to add special case for dt_dtype
Expand Down
0