Skip to content

Commit 107a299

Browse files
jbrockmendelPingviinituutti
authored andcommitted
DEPR: remove assert_panel_equal (pandas-dev#25238)
1 parent 50ee2ee commit 107a299

13 files changed

+27
-748
lines changed

pandas/tests/generic/test_generic.py

+4-28
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
import pandas as pd
1515
from pandas import DataFrame, MultiIndex, Panel, Series, date_range
1616
import pandas.util.testing as tm
17-
from pandas.util.testing import (
18-
assert_frame_equal, assert_panel_equal, assert_series_equal)
17+
from pandas.util.testing import assert_frame_equal, assert_series_equal
1918

2019
import pandas.io.formats.printing as printing
2120

@@ -701,16 +700,9 @@ def test_sample(sel):
701700
assert_frame_equal(sample1, df[['colString']])
702701

703702
# Test default axes
704-
with catch_warnings(record=True):
705-
simplefilter("ignore", FutureWarning)
706-
p = Panel(items=['a', 'b', 'c'], major_axis=[2, 4, 6],
707-
minor_axis=[1, 3, 5])
708-
assert_panel_equal(
709-
p.sample(n=3, random_state=42), p.sample(n=3, axis=1,
710-
random_state=42))
711-
assert_frame_equal(
712-
df.sample(n=3, random_state=42), df.sample(n=3, axis=0,
713-
random_state=42))
703+
assert_frame_equal(
704+
df.sample(n=3, random_state=42), df.sample(n=3, axis=0,
705+
random_state=42))
714706

715707
# Test that function aligns weights with frame
716708
df = DataFrame(
@@ -950,22 +942,6 @@ def test_pipe_tuple_error(self):
950942
with pytest.raises(ValueError):
951943
df.A.pipe((f, 'y'), x=1, y=0)
952944

953-
def test_pipe_panel(self):
954-
with catch_warnings(record=True):
955-
simplefilter("ignore", FutureWarning)
956-
wp = Panel({'r1': DataFrame({"A": [1, 2, 3]})})
957-
f = lambda x, y: x + y
958-
result = wp.pipe(f, 2)
959-
expected = wp + 2
960-
assert_panel_equal(result, expected)
961-
962-
result = wp.pipe((f, 'y'), x=1)
963-
expected = wp + 1
964-
assert_panel_equal(result, expected)
965-
966-
with pytest.raises(ValueError):
967-
wp.pipe((f, 'y'), x=1, y=1)
968-
969945
@pytest.mark.parametrize('box', [pd.Series, pd.DataFrame])
970946
def test_axis_classmethods(self, box):
971947
obj = box()

pandas/tests/generic/test_panel.py

-38
This file was deleted.

pandas/tests/indexing/common.py

-2
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ def _print(result, error=None):
233233
tm.assert_series_equal(rs, xp)
234234
elif xp.ndim == 2:
235235
tm.assert_frame_equal(rs, xp)
236-
elif xp.ndim == 3:
237-
tm.assert_panel_equal(rs, xp)
238236
result = 'ok'
239237
except AssertionError as e:
240238
detail = str(e)

pandas/tests/indexing/multiindex/test_panel.py

-46
Original file line numberDiff line numberDiff line change
@@ -55,49 +55,3 @@ def test_iloc_getitem_panel_multiindex(self):
5555

5656
result = p.loc[:, (1, 'y'), 'u']
5757
tm.assert_series_equal(result, expected)
58-
59-
def test_panel_setitem_with_multiindex(self):
60-
61-
# 10360
62-
# failing with a multi-index
63-
arr = np.array([[[1, 2, 3], [0, 0, 0]],
64-
[[0, 0, 0], [0, 0, 0]]],
65-
dtype=np.float64)
66-
67-
# reg index
68-
axes = dict(items=['A', 'B'], major_axis=[0, 1],
69-
minor_axis=['X', 'Y', 'Z'])
70-
p1 = Panel(0., **axes)
71-
p1.iloc[0, 0, :] = [1, 2, 3]
72-
expected = Panel(arr, **axes)
73-
tm.assert_panel_equal(p1, expected)
74-
75-
# multi-indexes
76-
axes['items'] = MultiIndex.from_tuples(
77-
[('A', 'a'), ('B', 'b')])
78-
p2 = Panel(0., **axes)
79-
p2.iloc[0, 0, :] = [1, 2, 3]
80-
expected = Panel(arr, **axes)
81-
tm.assert_panel_equal(p2, expected)
82-
83-
axes['major_axis'] = MultiIndex.from_tuples(
84-
[('A', 1), ('A', 2)])
85-
p3 = Panel(0., **axes)
86-
p3.iloc[0, 0, :] = [1, 2, 3]
87-
expected = Panel(arr, **axes)
88-
tm.assert_panel_equal(p3, expected)
89-
90-
axes['minor_axis'] = MultiIndex.from_product(
91-
[['X'], range(3)])
92-
p4 = Panel(0., **axes)
93-
p4.iloc[0, 0, :] = [1, 2, 3]
94-
expected = Panel(arr, **axes)
95-
tm.assert_panel_equal(p4, expected)
96-
97-
arr = np.array(
98-
[[[1, 0, 0], [2, 0, 0]], [[0, 0, 0], [0, 0, 0]]],
99-
dtype=np.float64)
100-
p5 = Panel(0., **axes)
101-
p5.iloc[0, :, 0] = [1, 2]
102-
expected = Panel(arr, **axes)
103-
tm.assert_panel_equal(p5, expected)

pandas/tests/indexing/test_panel.py

+1-89
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44
import pytest
55

6-
from pandas import DataFrame, Panel, date_range
6+
from pandas import Panel, date_range
77
from pandas.util import testing as tm
88

99

@@ -31,30 +31,6 @@ def test_iloc_getitem_panel(self):
3131
expected = p.loc['B', 'b', 'two']
3232
assert result == expected
3333

34-
# slice
35-
result = p.iloc[1:3]
36-
expected = p.loc[['B', 'C']]
37-
tm.assert_panel_equal(result, expected)
38-
39-
result = p.iloc[:, 0:2]
40-
expected = p.loc[:, ['a', 'b']]
41-
tm.assert_panel_equal(result, expected)
42-
43-
# list of integers
44-
result = p.iloc[[0, 2]]
45-
expected = p.loc[['A', 'C']]
46-
tm.assert_panel_equal(result, expected)
47-
48-
# neg indices
49-
result = p.iloc[[-1, 1], [-1, 1]]
50-
expected = p.loc[['D', 'B'], ['c', 'b']]
51-
tm.assert_panel_equal(result, expected)
52-
53-
# dups indices
54-
result = p.iloc[[-1, -1, 1], [-1, 1]]
55-
expected = p.loc[['D', 'D', 'B'], ['c', 'b']]
56-
tm.assert_panel_equal(result, expected)
57-
5834
# combined
5935
result = p.iloc[0, [True, True], [0, 1]]
6036
expected = p.loc['A', ['a', 'b'], ['one', 'two']]
@@ -110,18 +86,6 @@ def test_iloc_panel_issue(self):
11086
def test_panel_getitem(self):
11187

11288
with catch_warnings(record=True):
113-
# GH4016, date selection returns a frame when a partial string
114-
# selection
115-
ind = date_range(start="2000", freq="D", periods=1000)
116-
df = DataFrame(
117-
np.random.randn(
118-
len(ind), 5), index=ind, columns=list('ABCDE'))
119-
panel = Panel({'frame_' + c: df for c in list('ABC')})
120-
121-
test2 = panel.loc[:, "2002":"2002-12-31"]
122-
test1 = panel.loc[:, "2002"]
123-
tm.assert_panel_equal(test1, test2)
124-
12589
# with an object-like
12690
# GH 9140
12791
class TestObject(object):
@@ -138,55 +102,3 @@ def __str__(self):
138102
expected = p.iloc[0]
139103
result = p[obj]
140104
tm.assert_frame_equal(result, expected)
141-
142-
def test_panel_setitem(self):
143-
144-
with catch_warnings(record=True):
145-
# GH 7763
146-
# loc and setitem have setting differences
147-
np.random.seed(0)
148-
index = range(3)
149-
columns = list('abc')
150-
151-
panel = Panel({'A': DataFrame(np.random.randn(3, 3),
152-
index=index, columns=columns),
153-
'B': DataFrame(np.random.randn(3, 3),
154-
index=index, columns=columns),
155-
'C': DataFrame(np.random.randn(3, 3),
156-
index=index, columns=columns)})
157-
158-
replace = DataFrame(np.eye(3, 3), index=range(3), columns=columns)
159-
expected = Panel({'A': replace, 'B': replace, 'C': replace})
160-
161-
p = panel.copy()
162-
for idx in list('ABC'):
163-
p[idx] = replace
164-
tm.assert_panel_equal(p, expected)
165-
166-
p = panel.copy()
167-
for idx in list('ABC'):
168-
p.loc[idx, :, :] = replace
169-
tm.assert_panel_equal(p, expected)
170-
171-
def test_panel_assignment(self):
172-
173-
with catch_warnings(record=True):
174-
# GH3777
175-
wp = Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'],
176-
major_axis=date_range('1/1/2000', periods=5),
177-
minor_axis=['A', 'B', 'C', 'D'])
178-
wp2 = Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'],
179-
major_axis=date_range('1/1/2000', periods=5),
180-
minor_axis=['A', 'B', 'C', 'D'])
181-
182-
# TODO: unused?
183-
# expected = wp.loc[['Item1', 'Item2'], :, ['A', 'B']]
184-
185-
with pytest.raises(NotImplementedError):
186-
wp.loc[['Item1', 'Item2'], :, ['A', 'B']] = wp2.loc[
187-
['Item1', 'Item2'], :, ['A', 'B']]
188-
189-
# to_assign = wp2.loc[['Item1', 'Item2'], :, ['A', 'B']]
190-
# wp.loc[['Item1', 'Item2'], :, ['A', 'B']] = to_assign
191-
# result = wp.loc[['Item1', 'Item2'], :, ['A', 'B']]
192-
# tm.assert_panel_equal(result,expected)

pandas/tests/indexing/test_partial.py

+1-31
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
import pytest
1111

1212
import pandas as pd
13-
from pandas import DataFrame, Index, Panel, Series, date_range
13+
from pandas import DataFrame, Index, Series, date_range
1414
from pandas.util import testing as tm
1515

1616

1717
class TestPartialSetting(object):
1818

19-
@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
2019
@pytest.mark.filterwarnings("ignore:\\n.ix:DeprecationWarning")
2120
def test_partial_setting(self):
2221

@@ -116,35 +115,6 @@ def test_partial_setting(self):
116115
df.ix[:, 'C'] = df.ix[:, 'A']
117116
tm.assert_frame_equal(df, expected)
118117

119-
with catch_warnings(record=True):
120-
# ## panel ##
121-
p_orig = Panel(np.arange(16).reshape(2, 4, 2),
122-
items=['Item1', 'Item2'],
123-
major_axis=pd.date_range('2001/1/12', periods=4),
124-
minor_axis=['A', 'B'], dtype='float64')
125-
126-
# panel setting via item
127-
p_orig = Panel(np.arange(16).reshape(2, 4, 2),
128-
items=['Item1', 'Item2'],
129-
major_axis=pd.date_range('2001/1/12', periods=4),
130-
minor_axis=['A', 'B'], dtype='float64')
131-
expected = p_orig.copy()
132-
expected['Item3'] = expected['Item1']
133-
p = p_orig.copy()
134-
p.loc['Item3'] = p['Item1']
135-
tm.assert_panel_equal(p, expected)
136-
137-
# panel with aligned series
138-
expected = p_orig.copy()
139-
expected = expected.transpose(2, 1, 0)
140-
expected['C'] = DataFrame({'Item1': [30, 30, 30, 30],
141-
'Item2': [32, 32, 32, 32]},
142-
index=p_orig.major_axis)
143-
expected = expected.transpose(2, 1, 0)
144-
p = p_orig.copy()
145-
p.loc[:, :, 'C'] = Series([30, 32], index=p_orig.items)
146-
tm.assert_panel_equal(p, expected)
147-
148118
# GH 8473
149119
dates = date_range('1/1/2000', periods=8)
150120
df_orig = DataFrame(np.random.randn(8, 4), index=dates,

pandas/tests/io/generate_legacy_storage_files.py

+1-15
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,14 @@
4141
import os
4242
import platform as pl
4343
import sys
44-
from warnings import catch_warnings, filterwarnings
4544

4645
import numpy as np
4746

4847
from pandas.compat import u
4948

5049
import pandas
5150
from pandas import (
52-
Categorical, DataFrame, Index, MultiIndex, NaT, Panel, Period, Series,
51+
Categorical, DataFrame, Index, MultiIndex, NaT, Period, Series,
5352
SparseDataFrame, SparseSeries, Timestamp, bdate_range, date_range,
5453
period_range, timedelta_range, to_msgpack)
5554

@@ -187,18 +186,6 @@ def create_data():
187186
u'C': Timestamp('20130603', tz='UTC')}, index=range(5))
188187
)
189188

190-
with catch_warnings(record=True):
191-
filterwarnings("ignore", "\\nPanel", FutureWarning)
192-
mixed_dup_panel = Panel({u'ItemA': frame[u'float'],
193-
u'ItemB': frame[u'int']})
194-
mixed_dup_panel.items = [u'ItemA', u'ItemA']
195-
panel = dict(float=Panel({u'ItemA': frame[u'float'],
196-
u'ItemB': frame[u'float'] + 1}),
197-
dup=Panel(
198-
np.arange(30).reshape(3, 5, 2).astype(np.float64),
199-
items=[u'A', u'B', u'A']),
200-
mixed_dup=mixed_dup_panel)
201-
202189
cat = dict(int8=Categorical(list('abcdefg')),
203190
int16=Categorical(np.arange(1000)),
204191
int32=Categorical(np.arange(10000)))
@@ -241,7 +228,6 @@ def create_data():
241228

242229
return dict(series=series,
243230
frame=frame,
244-
panel=panel,
245231
index=index,
246232
scalars=scalars,
247233
mi=mi,

0 commit comments

Comments
 (0)