Skip to content

Commit 69551aa

Browse files
simonjayhawkinsjreback
authored andcommitted
TST/CLN: Remove more Panel tests (#25675)
1 parent c57d162 commit 69551aa

File tree

8 files changed

+21
-148
lines changed

8 files changed

+21
-148
lines changed

pandas/tests/api/test_api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ class TestPDApi(Base):
5353
]
5454

5555
# these are already deprecated; awaiting removal
56-
deprecated_classes = ['TimeGrouper']
56+
deprecated_classes = ['TimeGrouper', 'Panel']
5757

5858
# these should be deprecated in the future
59-
deprecated_classes_in_future = ['Panel']
59+
deprecated_classes_in_future = []
6060

6161
# external modules exposed in pandas namespace
6262
modules = ['np', 'datetime']

pandas/tests/computation/test_eval.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from pandas.core.dtypes.common import is_bool, is_list_like, is_scalar
1515

1616
import pandas as pd
17-
from pandas import DataFrame, Panel, Series, date_range
17+
from pandas import DataFrame, Series, date_range
1818
from pandas.core.computation import pytables
1919
from pandas.core.computation.check import _NUMEXPR_VERSION
2020
from pandas.core.computation.engines import NumExprClobberingError, _engines
@@ -1112,14 +1112,6 @@ def test_bool_ops_with_constants(self):
11121112
exp = eval(ex)
11131113
assert res == exp
11141114

1115-
@pytest.mark.filterwarnings("ignore::FutureWarning")
1116-
def test_panel_fails(self):
1117-
x = Panel(randn(3, 4, 5))
1118-
y = Series(randn(10))
1119-
with pytest.raises(NotImplementedError):
1120-
self.eval('x + y',
1121-
local_dict={'x': x, 'y': y})
1122-
11231115
def test_4d_ndarray_fails(self):
11241116
x = randn(3, 4, 5, 6)
11251117
y = Series(randn(10))

pandas/tests/dtypes/test_inference.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from fractions import Fraction
1212
from numbers import Number
1313
import re
14-
from warnings import catch_warnings, simplefilter
1514

1615
import numpy as np
1716
import pytest
@@ -30,8 +29,8 @@
3029

3130
import pandas as pd
3231
from pandas import (
33-
Categorical, DataFrame, DateOffset, DatetimeIndex, Index, Interval, Panel,
34-
Period, Series, Timedelta, TimedeltaIndex, Timestamp, compat, isna)
32+
Categorical, DataFrame, DateOffset, DatetimeIndex, Index, Interval, Period,
33+
Series, Timedelta, TimedeltaIndex, Timestamp, compat, isna)
3534
from pandas.util import testing as tm
3635

3736

@@ -1305,10 +1304,6 @@ def test_is_scalar_pandas_containers(self):
13051304
assert not is_scalar(Series([1]))
13061305
assert not is_scalar(DataFrame())
13071306
assert not is_scalar(DataFrame([[1]]))
1308-
with catch_warnings(record=True):
1309-
simplefilter("ignore", FutureWarning)
1310-
assert not is_scalar(Panel())
1311-
assert not is_scalar(Panel([[[1]]]))
13121307
assert not is_scalar(Index([]))
13131308
assert not is_scalar(Index([1]))
13141309

pandas/tests/generic/test_generic.py

+14-62
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# pylint: disable-msg=E1101,W0612
33

44
from copy import copy, deepcopy
5-
from warnings import catch_warnings, simplefilter
65

76
import numpy as np
87
import pytest
@@ -12,7 +11,7 @@
1211
from pandas.core.dtypes.common import is_scalar
1312

1413
import pandas as pd
15-
from pandas import DataFrame, MultiIndex, Panel, Series, date_range
14+
from pandas import DataFrame, MultiIndex, Series, date_range
1615
import pandas.util.testing as tm
1716
from pandas.util.testing import assert_frame_equal, assert_series_equal
1817

@@ -238,12 +237,6 @@ def test_metadata_propagation(self):
238237
o2 = self._construct(shape=3)
239238
o2.name = 'bar'
240239

241-
# TODO
242-
# Once panel can do non-trivial combine operations
243-
# (currently there is an a raise in the Panel arith_ops to prevent
244-
# this, though it actually does work)
245-
# can remove all of these try: except: blocks on the actual operations
246-
247240
# ----------
248241
# preserving
249242
# ----------
@@ -255,63 +248,37 @@ def test_metadata_propagation(self):
255248

256249
# ops with like
257250
for op in ['__add__', '__sub__', '__truediv__', '__mul__']:
258-
try:
259-
result = getattr(o, op)(o)
260-
self.check_metadata(o, result)
261-
except (ValueError, AttributeError):
262-
pass
251+
result = getattr(o, op)(o)
252+
self.check_metadata(o, result)
263253

264254
# simple boolean
265255
for op in ['__eq__', '__le__', '__ge__']:
266256
v1 = getattr(o, op)(o)
267257
self.check_metadata(o, v1)
268-
269-
try:
270-
self.check_metadata(o, v1 & v1)
271-
except (ValueError):
272-
pass
273-
274-
try:
275-
self.check_metadata(o, v1 | v1)
276-
except (ValueError):
277-
pass
258+
self.check_metadata(o, v1 & v1)
259+
self.check_metadata(o, v1 | v1)
278260

279261
# combine_first
280-
try:
281-
result = o.combine_first(o2)
282-
self.check_metadata(o, result)
283-
except (AttributeError):
284-
pass
262+
result = o.combine_first(o2)
263+
self.check_metadata(o, result)
285264

286265
# ---------------------------
287266
# non-preserving (by default)
288267
# ---------------------------
289268

290269
# add non-like
291-
try:
292-
result = o + o2
293-
self.check_metadata(result)
294-
except (ValueError, AttributeError):
295-
pass
270+
result = o + o2
271+
self.check_metadata(result)
296272

297273
# simple boolean
298274
for op in ['__eq__', '__le__', '__ge__']:
299275

300276
# this is a name matching op
301277
v1 = getattr(o, op)(o)
302-
303278
v2 = getattr(o, op)(o2)
304279
self.check_metadata(v2)
305-
306-
try:
307-
self.check_metadata(v1 & v2)
308-
except (ValueError):
309-
pass
310-
311-
try:
312-
self.check_metadata(v1 | v2)
313-
except (ValueError):
314-
pass
280+
self.check_metadata(v1 & v2)
281+
self.check_metadata(v1 | v2)
315282

316283
def test_head_tail(self):
317284
# GH5370
@@ -325,12 +292,7 @@ def test_head_tail(self):
325292
axis = o._get_axis_name(0)
326293
setattr(o, axis, index(len(getattr(o, axis))))
327294

328-
# Panel + dims
329-
try:
330-
o.head()
331-
except (NotImplementedError):
332-
pytest.skip('not implemented on {0}'.format(
333-
o.__class__.__name__))
295+
o.head()
334296

335297
self._compare(o.head(), o.iloc[:5])
336298
self._compare(o.tail(), o.iloc[-5:])
@@ -639,19 +601,12 @@ def test_sample(sel):
639601
sample1 = df.sample(n=1, weights='easyweights')
640602
assert_frame_equal(sample1, df.iloc[5:6])
641603

642-
# Ensure proper error if string given as weight for Series, panel, or
604+
# Ensure proper error if string given as weight for Series or
643605
# DataFrame with axis = 1.
644606
s = Series(range(10))
645607
with pytest.raises(ValueError):
646608
s.sample(n=3, weights='weight_column')
647609

648-
with catch_warnings(record=True):
649-
simplefilter("ignore", FutureWarning)
650-
panel = Panel(items=[0, 1, 2], major_axis=[2, 3, 4],
651-
minor_axis=[3, 4, 5])
652-
with pytest.raises(ValueError):
653-
panel.sample(n=1, weights='weight_column')
654-
655610
with pytest.raises(ValueError):
656611
df.sample(n=1, weights='weight_column', axis=1)
657612

@@ -754,12 +709,9 @@ def test_squeeze(self):
754709
# don't fail with 0 length dimensions GH11229 & GH8999
755710
empty_series = Series([], name='five')
756711
empty_frame = DataFrame([empty_series])
757-
with catch_warnings(record=True):
758-
simplefilter("ignore", FutureWarning)
759-
empty_panel = Panel({'six': empty_frame})
760712

761713
[tm.assert_series_equal(empty_series, higher_dim.squeeze())
762-
for higher_dim in [empty_series, empty_frame, empty_panel]]
714+
for higher_dim in [empty_series, empty_frame]]
763715

764716
# axis argument
765717
df = tm.makeTimeDataFrame(nper=1).iloc[:, :1]

pandas/tests/generic/test_label_or_level_utils.py

-64
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from pandas.core.dtypes.missing import array_equivalent
44

55
import pandas as pd
6-
import pandas.util.testing as tm
76

87

98
# Fixtures
@@ -46,13 +45,6 @@ def df_duplabels(df):
4645
return df
4746

4847

49-
@pytest.fixture
50-
def panel():
51-
with tm.assert_produces_warning(FutureWarning,
52-
check_stacklevel=False):
53-
return pd.Panel()
54-
55-
5648
# Test is label/level reference
5749
# =============================
5850
def get_labels_levels(df_levels):
@@ -134,32 +126,6 @@ def test_is_level_reference_series_axis1_error(df):
134126
s._is_level_reference('L1', axis=1)
135127

136128

137-
# Panel
138-
# -----
139-
def test_is_level_reference_panel_error(panel):
140-
msg = ("_is_level_reference is not implemented for {type}"
141-
.format(type=type(panel)))
142-
143-
with pytest.raises(NotImplementedError, match=msg):
144-
panel._is_level_reference('L1', axis=0)
145-
146-
147-
def test_is_label_reference_panel_error(panel):
148-
msg = ("_is_label_reference is not implemented for {type}"
149-
.format(type=type(panel)))
150-
151-
with pytest.raises(NotImplementedError, match=msg):
152-
panel._is_label_reference('L1', axis=0)
153-
154-
155-
def test_is_label_or_level_reference_panel_error(panel):
156-
msg = ("_is_label_or_level_reference is not implemented for {type}"
157-
.format(type=type(panel)))
158-
159-
with pytest.raises(NotImplementedError, match=msg):
160-
panel._is_label_or_level_reference('L1', axis=0)
161-
162-
163129
# Test _check_label_or_level_ambiguity_df
164130
# =======================================
165131

@@ -215,16 +181,6 @@ def test_check_label_or_level_ambiguity_series_axis1_error(df):
215181
s._check_label_or_level_ambiguity('L1', axis=1)
216182

217183

218-
# Panel
219-
# -----
220-
def test_check_label_or_level_ambiguity_panel_error(panel):
221-
msg = ("_check_label_or_level_ambiguity is not implemented for {type}"
222-
.format(type=type(panel)))
223-
224-
with pytest.raises(NotImplementedError, match=msg):
225-
panel._check_label_or_level_ambiguity("L1", axis=0)
226-
227-
228184
# Test _get_label_or_level_values
229185
# ===============================
230186
def assert_label_values(frame, labels, axis):
@@ -322,16 +278,6 @@ def test_get_label_or_level_values_series_axis1_error(df):
322278
s._get_label_or_level_values('L1', axis=1)
323279

324280

325-
# Panel
326-
# -----
327-
def test_get_label_or_level_values_panel_error(panel):
328-
msg = ("_get_label_or_level_values is not implemented for {type}"
329-
.format(type=type(panel)))
330-
331-
with pytest.raises(NotImplementedError, match=msg):
332-
panel._get_label_or_level_values('L1', axis=0)
333-
334-
335281
# Test _drop_labels_or_levels
336282
# ===========================
337283
def assert_labels_dropped(frame, labels, axis):
@@ -394,13 +340,3 @@ def test_drop_labels_or_levels_series(df):
394340

395341
with pytest.raises(ValueError, match="not valid labels or levels"):
396342
s._drop_labels_or_levels('L4', axis=0)
397-
398-
399-
# Panel
400-
# -----
401-
def test_drop_labels_or_levels_panel_error(panel):
402-
msg = ("_drop_labels_or_levels is not implemented for {type}"
403-
.format(type=type(panel)))
404-
405-
with pytest.raises(NotImplementedError, match=msg):
406-
panel._drop_labels_or_levels('L1', axis=0)

pandas/tests/indexing/test_iloc.py

-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ def test_iloc_getitem_neg_int_can_reach_first_index(self):
217217

218218
def test_iloc_getitem_dups(self):
219219

220-
# no dups in panel (bug?)
221220
self.check_result('list int (dups)', 'iloc', [0, 1, 1, 3], 'ix',
222221
{0: [0, 2, 2, 6], 1: [0, 3, 3, 9]},
223222
objs=['series', 'frame'], typs=['ints', 'uints'])

pandas/tests/reshape/merge/test_join.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
a_ = np.array
1818

1919

20-
@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
2120
class TestJoin(object):
2221

2322
def setup_method(self, method):

pandas/tests/test_base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import pandas as pd
2222
from pandas import (
2323
CategoricalIndex, DataFrame, DatetimeIndex, Index, Interval, IntervalIndex,
24-
Panel, PeriodIndex, Series, Timedelta, TimedeltaIndex, Timestamp)
24+
PeriodIndex, Series, Timedelta, TimedeltaIndex, Timestamp)
2525
from pandas.core.accessor import PandasDelegate
2626
from pandas.core.arrays import DatetimeArray, PandasArray, TimedeltaArray
2727
from pandas.core.base import NoNewAttributesMixin, PandasObject
@@ -239,7 +239,7 @@ def check_ops_properties(self, props, filter=None, ignore_failures=False):
239239
with pytest.raises(err):
240240
getattr(o, op)
241241

242-
@pytest.mark.parametrize('klass', [Series, DataFrame, Panel])
242+
@pytest.mark.parametrize('klass', [Series, DataFrame])
243243
def test_binary_ops_docs(self, klass):
244244
op_map = {'add': '+',
245245
'sub': '-',

0 commit comments

Comments
 (0)