Skip to content
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

TST (string dtype): avoid explicit object dtype Index in fixture data #60217

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
2 changes: 2 additions & 0 deletions pandas/_testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ def shares_memory(left, right) -> bool:
if isinstance(left, MultiIndex):
return shares_memory(left._codes, right)
if isinstance(left, (Index, Series)):
if isinstance(right, (Index, Series)):
return shares_memory(left._values, right._values)
return shares_memory(left._values, right)

if isinstance(left, NDArrayBackedExtensionArray):
Expand Down
10 changes: 5 additions & 5 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ def multiindex_year_month_day_dataframe_random_data():
"""
tdf = DataFrame(
np.random.default_rng(2).standard_normal((100, 4)),
columns=Index(list("ABCD"), dtype=object),
columns=Index(list("ABCD")),
index=date_range("2000-01-01", periods=100, freq="B"),
)
ymd = tdf.groupby([lambda x: x.year, lambda x: x.month, lambda x: x.day]).sum()
Expand Down Expand Up @@ -787,7 +787,7 @@ def string_series() -> Series:
"""
return Series(
np.arange(30, dtype=np.float64) * 1.1,
index=Index([f"i_{i}" for i in range(30)], dtype=object),
index=Index([f"i_{i}" for i in range(30)]),
name="series",
)

Expand All @@ -798,7 +798,7 @@ def object_series() -> Series:
Fixture for Series of dtype object with Index of unique strings
"""
data = [f"foo_{i}" for i in range(30)]
index = Index([f"bar_{i}" for i in range(30)], dtype=object)
index = Index([f"bar_{i}" for i in range(30)])
return Series(data, index=index, name="objects", dtype=object)


Expand Down Expand Up @@ -890,8 +890,8 @@ def int_frame() -> DataFrame:
"""
return DataFrame(
np.ones((30, 4), dtype=np.int64),
index=Index([f"foo_{i}" for i in range(30)], dtype=object),
columns=Index(list("ABCD"), dtype=object),
index=Index([f"foo_{i}" for i in range(30)]),
columns=Index(list("ABCD")),
)


Expand Down
1 change: 0 additions & 1 deletion pandas/tests/frame/test_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,6 @@ def test_sum_bools(self):
# ----------------------------------------------------------------------
# Index of max / min

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
@pytest.mark.parametrize("axis", [0, 1])
def test_idxmin(self, float_frame, int_frame, skipna, axis):
frame = float_frame
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/series/indexing/test_setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ def test_setitem_with_expansion_type_promotion(self):
expected = Series([Timestamp("2016-01-01"), 3.0, "foo"], index=["a", "b", "c"])
tm.assert_series_equal(ser, expected)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
def test_setitem_not_contained(self, string_series):
# set item that's not contained
ser = string_series.copy()
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/methods/test_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
def test_reindex(datetime_series, string_series):
identity = string_series.reindex(string_series.index)

assert np.may_share_memory(string_series.index, identity.index)
assert tm.shares_memory(string_series.index, identity.index)

assert identity.index.is_(string_series.index)
assert identity.index.identical(string_series.index)
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/series/methods/test_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

import pandas as pd
from pandas import Series
import pandas._testing as tm
Expand All @@ -26,7 +24,6 @@ def read_csv(self, path, **kwargs):

return out

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
def test_from_csv(self, datetime_series, string_series, temp_file):
# freq doesn't round-trip
datetime_series.index = datetime_series.index._with_freq(None)
Expand Down