Skip to content

TST: fix maybe_promote float dtype xfails #28776

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 1 commit into from
Oct 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ def maybe_promote(dtype, fill_value=np.nan):
if issubclass(dtype.type, np.bool_):
dtype = np.object_
elif issubclass(dtype.type, np.integer):
dtype = np.float64
dtype = np.dtype(np.float64)
if not isna(fill_value):
fill_value = dtype.type(fill_value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excuse my lack of familiarity but would it be possible for a non-numeric fill_value to hit this condition? If so I think would cause a ValueError

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, a few lines up we condition on fill_value being float scalar

elif is_bool(fill_value):
if not issubclass(dtype.type, np.bool_):
dtype = np.object_
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/dtypes/cast/test_promote.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ def test_maybe_promote_int_with_float(any_int_dtype, float_dtype, box):
fill_dtype = np.dtype(float_dtype)
boxed, box_dtype = box # read from parametrized fixture

if float_dtype == "float32" and not boxed:
pytest.xfail("falsely upcasts to float64")

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

Expand Down