Skip to content

Commit 56e8aaf

Browse files
phoflfeefladder
authored andcommitted
Delete duplicates and unused code from reshape tests (pandas-dev#42802)
1 parent 97952e7 commit 56e8aaf

File tree

6 files changed

+18
-33
lines changed

6 files changed

+18
-33
lines changed

pandas/tests/reshape/concat/test_append.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import datetime as dt
2-
from datetime import datetime
32
from itertools import combinations
43

54
import dateutil

pandas/tests/reshape/concat/test_append_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def test_concatlike_datetimetz_to_object(self, tz_aware_fixture):
371371
)
372372

373373
res = dti1.append(dti3)
374-
# tm.assert_index_equal(res, exp)
374+
tm.assert_index_equal(res, exp)
375375

376376
dts1 = Series(dti1)
377377
dts3 = Series(dti3)

pandas/tests/reshape/concat/test_concat.py

-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ def test_concat_copy(self):
7979
assert b.values.base is not None
8080

8181
def test_concat_with_group_keys(self):
82-
df = DataFrame(np.random.randn(4, 3))
83-
df2 = DataFrame(np.random.randn(4, 4))
84-
8582
# axis=0
8683
df = DataFrame(np.random.randn(3, 4))
8784
df2 = DataFrame(np.random.randn(4, 4))

pandas/tests/reshape/concat/test_dataframe.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class TestDataFrameConcat:
1515
def test_concat_multiple_frames_dtypes(self):
1616

1717
# GH#2759
18-
A = DataFrame(data=np.ones((10, 2)), columns=["foo", "bar"], dtype=np.float64)
19-
B = DataFrame(data=np.ones((10, 2)), dtype=np.float32)
20-
results = concat((A, B), axis=1).dtypes
18+
df1 = DataFrame(data=np.ones((10, 2)), columns=["foo", "bar"], dtype=np.float64)
19+
df2 = DataFrame(data=np.ones((10, 2)), dtype=np.float32)
20+
results = concat((df1, df2), axis=1).dtypes
2121
expected = Series(
2222
[np.dtype("float64")] * 2 + [np.dtype("float32")] * 2,
2323
index=["foo", "bar", 0, 1],

pandas/tests/reshape/concat/test_index.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,18 @@ def test_concat_rename_index(self):
9696
tm.assert_frame_equal(result, exp)
9797
assert result.index.names == exp.index.names
9898

99-
@pytest.mark.parametrize("test_series", [True, False])
100-
def test_concat_copy_index(self, test_series, axis):
99+
def test_concat_copy_index_series(self, axis):
101100
# GH 29879
102-
if test_series:
103-
ser = Series([1, 2])
104-
comb = concat([ser, ser], axis=axis, copy=True)
105-
assert comb.index is not ser.index
106-
else:
107-
df = DataFrame([[1, 2], [3, 4]], columns=["a", "b"])
108-
comb = concat([df, df], axis=axis, copy=True)
109-
assert comb.index is not df.index
110-
assert comb.columns is not df.columns
101+
ser = Series([1, 2])
102+
comb = concat([ser, ser], axis=axis, copy=True)
103+
assert comb.index is not ser.index
104+
105+
def test_concat_copy_index_frame(self, axis):
106+
# GH 29879
107+
df = DataFrame([[1, 2], [3, 4]], columns=["a", "b"])
108+
comb = concat([df, df], axis=axis, copy=True)
109+
assert comb.index is not df.index
110+
assert comb.columns is not df.columns
111111

112112
def test_default_index(self):
113113
# is_series and ignore_index

pandas/tests/reshape/test_cut.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ def test_simple():
3232
tm.assert_numpy_array_equal(result, expected, check_dtype=False)
3333

3434

35-
def test_bins():
36-
data = np.array([0.2, 1.4, 2.5, 6.2, 9.7, 2.1])
35+
@pytest.mark.parametrize("func", [list, np.array])
36+
def test_bins(func):
37+
data = func([0.2, 1.4, 2.5, 6.2, 9.7, 2.1])
3738
result, bins = cut(data, 3, retbins=True)
3839

3940
intervals = IntervalIndex.from_breaks(bins.round(3))
@@ -68,18 +69,6 @@ def test_no_right():
6869
tm.assert_almost_equal(bins, np.array([0.2, 2.575, 4.95, 7.325, 9.7095]))
6970

7071

71-
def test_array_like():
72-
data = [0.2, 1.4, 2.5, 6.2, 9.7, 2.1]
73-
result, bins = cut(data, 3, retbins=True)
74-
75-
intervals = IntervalIndex.from_breaks(bins.round(3))
76-
intervals = intervals.take([0, 0, 0, 1, 2, 0])
77-
expected = Categorical(intervals, ordered=True)
78-
79-
tm.assert_categorical_equal(result, expected)
80-
tm.assert_almost_equal(bins, np.array([0.1905, 3.36666667, 6.53333333, 9.7]))
81-
82-
8372
def test_bins_from_interval_index():
8473
c = cut(range(5), 3)
8574
expected = c

0 commit comments

Comments
 (0)