Skip to content

Commit d6167ff

Browse files
undid the changed tests
1 parent 6c6a7c8 commit d6167ff

File tree

11 files changed

+26
-33
lines changed

11 files changed

+26
-33
lines changed

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5604,7 +5604,7 @@ def _validate_join_method(method: str):
56045604
def default_index(n):
56055605
from pandas.core.indexes.range import RangeIndex
56065606

5607-
return RangeIndex(0, n)
5607+
return RangeIndex(0, n, name=None)
56085608

56095609

56105610
def maybe_extract_name(name, obj, cls) -> Label:

pandas/tests/extension/base/missing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_isna(self, data_missing):
1919

2020
# GH 21189
2121
result = pd.Series(data_missing).drop([0, 1]).isna()
22-
expected = pd.Series([], dtype=bool, index=pd.RangeIndex(0))
22+
expected = pd.Series([], dtype=bool)
2323
self.assert_series_equal(result, expected)
2424

2525
def test_dropna_array(self, data_missing):

pandas/tests/extension/decimal/test_decimal.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def convert(x):
8686
else:
8787
right_na = right.isna()
8888

89-
tm.assert_series_equal(left_na, right_na, *args, **kwargs)
89+
tm.assert_series_equal(left_na, right_na)
9090
return tm.assert_series_equal(left[~left_na], right[~right_na], *args, **kwargs)
9191

9292
@classmethod

pandas/tests/extension/test_sparse.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def test_isna(self, data_missing):
187187

188188
# GH 21189
189189
result = pd.Series(data_missing).drop([0, 1]).isna()
190-
expected = pd.Series([], dtype=expected_dtype, index=pd.RangeIndex(0))
190+
expected = pd.Series([], dtype=expected_dtype)
191191
self.assert_series_equal(result, expected)
192192

193193
def test_fillna_limit_pad(self, data_missing):

pandas/tests/frame/test_constructors.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def test_empty_constructor(self, constructor):
8787
@pytest.mark.parametrize(
8888
"emptylike,expected_index,expected_columns",
8989
[
90-
([[]], RangeIndex(1), Index([])),
91-
([[], []], RangeIndex(2), Index([])),
92-
([(_ for _ in [])], RangeIndex(1), Index([])),
90+
([[]], RangeIndex(1), RangeIndex(0)),
91+
([[], []], RangeIndex(2), RangeIndex(0)),
92+
([(_ for _ in [])], RangeIndex(1), RangeIndex(0)),
9393
],
9494
)
9595
def test_emptylike_constructor(self, emptylike, expected_index, expected_columns):
@@ -342,7 +342,7 @@ def test_constructor_dict(self):
342342

343343
# with dict of empty list and Series
344344
frame = DataFrame({"A": [], "B": []}, columns=["A", "B"])
345-
tm.assert_index_equal(frame.index, Index([]))
345+
tm.assert_index_equal(frame.index, Index([], dtype=np.int64))
346346

347347
# GH 14381
348348
# Dict with None value

pandas/tests/groupby/test_filters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_filter_out_all_groups_in_df():
9797
df = pd.DataFrame({"a": [1, 1, 2], "b": [1, 2, 0]})
9898
res = df.groupby("a")
9999
res = res.filter(lambda x: x["b"].sum() > 5, dropna=True)
100-
expected = pd.DataFrame({"a": [], "b": []}, dtype="int64", index=pd.RangeIndex(0))
100+
expected = pd.DataFrame({"a": [], "b": []}, dtype="int64")
101101
tm.assert_frame_equal(expected, res)
102102

103103

pandas/tests/groupby/test_grouping.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,10 @@ def test_list_grouper_with_nat(self):
611611
@pytest.mark.parametrize(
612612
"func,expected",
613613
[
614-
("transform", pd.Series(name=2, dtype=np.float64)),
614+
(
615+
"transform",
616+
pd.Series(name=2, dtype=np.float64, index=pd.RangeIndex(0, 0, 1)),
617+
),
615618
(
616619
"agg",
617620
pd.Series(name=2, dtype=np.float64, index=pd.Float64Index([], name=1)),
@@ -635,13 +638,9 @@ def test_evaluate_with_empty_groups(self, func, expected):
635638
def test_groupby_empty(self):
636639
# https://github.com/pandas-dev/pandas/issues/27190
637640
s = pd.Series([], name="name", dtype="float64")
638-
639-
expected = s.copy()
640-
expected.index = pd.RangeIndex(0)
641-
642641
gr = s.groupby([])
643642
result = gr.mean()
644-
tm.assert_series_equal(result, expected)
643+
tm.assert_series_equal(result, s)
645644

646645
# check group properties
647646
assert len(gr.grouper.groupings) == 1

pandas/tests/io/json/test_pandas.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,13 @@ def test_roundtrip_empty(self, orient, convert_axes, numpy, empty_frame):
213213
)
214214
expected = empty_frame.copy()
215215

216-
# TODO: conditions below are probably bugs
216+
# TODO: both conditions below are probably bugs
217217
if convert_axes:
218+
expected.index = expected.index.astype(float)
218219
expected.columns = expected.columns.astype(float)
219-
220220
if numpy and orient == "values":
221221
expected = expected.reindex([0], axis=1).reset_index(drop=True)
222222

223-
if convert_axes:
224-
expected.index = expected.index.astype(float)
225-
226223
tm.assert_frame_equal(result, expected)
227224

228225
@pytest.mark.parametrize("convert_axes", [True, False])
@@ -635,7 +632,8 @@ def test_series_roundtrip_empty(self, orient, numpy, empty_series):
635632
expected = empty_series
636633
if orient in ("values", "records"):
637634
expected = expected.reset_index(drop=True)
638-
expected.index = expected.index.astype(float)
635+
else:
636+
expected.index = expected.index.astype(float)
639637

640638
tm.assert_series_equal(result, expected)
641639

pandas/tests/reshape/test_concat.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2203,8 +2203,7 @@ def test_concat_empty_series_timelike(self, tz, values):
22032203
{
22042204
0: pd.Series([pd.NaT] * len(values), dtype="M8[ns]").dt.tz_localize(tz),
22052205
1: values,
2206-
},
2207-
index=pd.Index(list(range(len(values))), dtype="object"),
2206+
}
22082207
)
22092208
result = concat([first, second], axis=1)
22102209
tm.assert_frame_equal(result, expected)

pandas/tests/series/methods/test_interpolate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def test_interpolate_corners(self, kwargs):
169169
s = Series([np.nan, np.nan])
170170
tm.assert_series_equal(s.interpolate(**kwargs), s)
171171

172-
s = Series([], dtype=object, index=pd.RangeIndex(0)).interpolate()
172+
s = Series([], dtype=object).interpolate()
173173
tm.assert_series_equal(s.interpolate(**kwargs), s)
174174

175175
def test_interpolate_index_values(self):

pandas/tests/series/test_constructors.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -127,40 +127,37 @@ def test_constructor_empty(self, input_class):
127127
with tm.assert_produces_warning(DeprecationWarning, check_stacklevel=False):
128128
empty = Series()
129129
empty2 = Series(input_class())
130-
tm.assert_series_equal(empty, empty2)
131-
assert type(empty.index) is Index
130+
131+
# these are Index() and RangeIndex() which don't compare type equal
132+
# but are just .equals
133+
tm.assert_series_equal(empty, empty2, check_index_type=False)
132134

133135
# With explicit dtype:
134136
empty = Series(dtype="float64")
135137
empty2 = Series(input_class(), dtype="float64")
136-
tm.assert_series_equal(empty, empty2)
137-
assert type(empty.index) is Index
138+
tm.assert_series_equal(empty, empty2, check_index_type=False)
138139

139140
# GH 18515 : with dtype=category:
140141
empty = Series(dtype="category")
141142
empty2 = Series(input_class(), dtype="category")
142-
tm.assert_series_equal(empty, empty2)
143-
assert type(empty.index) is Index
143+
tm.assert_series_equal(empty, empty2, check_index_type=False)
144144

145145
if input_class is not list:
146146
# With index:
147147
with tm.assert_produces_warning(DeprecationWarning, check_stacklevel=False):
148148
empty = Series(index=range(10))
149149
empty2 = Series(input_class(), index=range(10))
150150
tm.assert_series_equal(empty, empty2)
151-
assert type(empty.index) is pd.RangeIndex
152151

153152
# With index and dtype float64:
154153
empty = Series(np.nan, index=range(10))
155154
empty2 = Series(input_class(), index=range(10), dtype="float64")
156155
tm.assert_series_equal(empty, empty2)
157-
assert type(empty.index) is pd.RangeIndex
158156

159157
# GH 19853 : with empty string, index and dtype str
160158
empty = Series("", dtype=str, index=range(3))
161159
empty2 = Series("", index=range(3))
162160
tm.assert_series_equal(empty, empty2)
163-
assert type(empty.index) is pd.RangeIndex
164161

165162
@pytest.mark.parametrize("input_arg", [np.nan, float("nan")])
166163
def test_constructor_nan(self, input_arg):

0 commit comments

Comments
 (0)