Skip to content

TST/CLN: Remove more Panel tests #25675

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

Merged
merged 2 commits into from
Mar 13, 2019
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
4 changes: 2 additions & 2 deletions pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class TestPDApi(Base):
]

# these are already deprecated; awaiting removal
deprecated_classes = ['TimeGrouper']
deprecated_classes = ['TimeGrouper', 'Panel']

# these should be deprecated in the future
deprecated_classes_in_future = ['Panel']
deprecated_classes_in_future = []

# external modules exposed in pandas namespace
modules = ['np', 'datetime']
Expand Down
10 changes: 1 addition & 9 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pandas.core.dtypes.common import is_bool, is_list_like, is_scalar

import pandas as pd
from pandas import DataFrame, Panel, Series, date_range
from pandas import DataFrame, Series, date_range
from pandas.core.computation import pytables
from pandas.core.computation.check import _NUMEXPR_VERSION
from pandas.core.computation.engines import NumExprClobberingError, _engines
Expand Down Expand Up @@ -1112,14 +1112,6 @@ def test_bool_ops_with_constants(self):
exp = eval(ex)
assert res == exp

@pytest.mark.filterwarnings("ignore::FutureWarning")
def test_panel_fails(self):
x = Panel(randn(3, 4, 5))
y = Series(randn(10))
with pytest.raises(NotImplementedError):
self.eval('x + y',
local_dict={'x': x, 'y': y})

def test_4d_ndarray_fails(self):
x = randn(3, 4, 5, 6)
y = Series(randn(10))
Expand Down
9 changes: 2 additions & 7 deletions pandas/tests/dtypes/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from fractions import Fraction
from numbers import Number
import re
from warnings import catch_warnings, simplefilter

import numpy as np
import pytest
Expand All @@ -30,8 +29,8 @@

import pandas as pd
from pandas import (
Categorical, DataFrame, DateOffset, DatetimeIndex, Index, Interval, Panel,
Period, Series, Timedelta, TimedeltaIndex, Timestamp, compat, isna)
Categorical, DataFrame, DateOffset, DatetimeIndex, Index, Interval, Period,
Series, Timedelta, TimedeltaIndex, Timestamp, compat, isna)
from pandas.util import testing as tm


Expand Down Expand Up @@ -1305,10 +1304,6 @@ def test_is_scalar_pandas_containers(self):
assert not is_scalar(Series([1]))
assert not is_scalar(DataFrame())
assert not is_scalar(DataFrame([[1]]))
with catch_warnings(record=True):
simplefilter("ignore", FutureWarning)
assert not is_scalar(Panel())
assert not is_scalar(Panel([[[1]]]))
assert not is_scalar(Index([]))
assert not is_scalar(Index([1]))

Expand Down
76 changes: 14 additions & 62 deletions pandas/tests/generic/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# pylint: disable-msg=E1101,W0612

from copy import copy, deepcopy
from warnings import catch_warnings, simplefilter

import numpy as np
import pytest
Expand All @@ -12,7 +11,7 @@
from pandas.core.dtypes.common import is_scalar

import pandas as pd
from pandas import DataFrame, MultiIndex, Panel, Series, date_range
from pandas import DataFrame, MultiIndex, Series, date_range
import pandas.util.testing as tm
from pandas.util.testing import assert_frame_equal, assert_series_equal

Expand Down Expand Up @@ -238,12 +237,6 @@ def test_metadata_propagation(self):
o2 = self._construct(shape=3)
o2.name = 'bar'

# TODO
# Once panel can do non-trivial combine operations
# (currently there is an a raise in the Panel arith_ops to prevent
# this, though it actually does work)
# can remove all of these try: except: blocks on the actual operations

# ----------
# preserving
# ----------
Expand All @@ -255,63 +248,37 @@ def test_metadata_propagation(self):

# ops with like
for op in ['__add__', '__sub__', '__truediv__', '__mul__']:
try:
result = getattr(o, op)(o)
self.check_metadata(o, result)
except (ValueError, AttributeError):
pass
result = getattr(o, op)(o)
self.check_metadata(o, result)

# simple boolean
for op in ['__eq__', '__le__', '__ge__']:
v1 = getattr(o, op)(o)
self.check_metadata(o, v1)

try:
self.check_metadata(o, v1 & v1)
except (ValueError):
pass

try:
self.check_metadata(o, v1 | v1)
except (ValueError):
pass
self.check_metadata(o, v1 & v1)
self.check_metadata(o, v1 | v1)

# combine_first
try:
result = o.combine_first(o2)
self.check_metadata(o, result)
except (AttributeError):
pass
result = o.combine_first(o2)
self.check_metadata(o, result)

# ---------------------------
# non-preserving (by default)
# ---------------------------

# add non-like
try:
result = o + o2
self.check_metadata(result)
except (ValueError, AttributeError):
pass
result = o + o2
self.check_metadata(result)

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

# this is a name matching op
v1 = getattr(o, op)(o)

v2 = getattr(o, op)(o2)
self.check_metadata(v2)

try:
self.check_metadata(v1 & v2)
except (ValueError):
pass

try:
self.check_metadata(v1 | v2)
except (ValueError):
pass
self.check_metadata(v1 & v2)
self.check_metadata(v1 | v2)

def test_head_tail(self):
# GH5370
Expand All @@ -325,12 +292,7 @@ def test_head_tail(self):
axis = o._get_axis_name(0)
setattr(o, axis, index(len(getattr(o, axis))))

# Panel + dims
try:
o.head()
except (NotImplementedError):
pytest.skip('not implemented on {0}'.format(
o.__class__.__name__))
o.head()

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

# Ensure proper error if string given as weight for Series, panel, or
# Ensure proper error if string given as weight for Series or
# DataFrame with axis = 1.
s = Series(range(10))
with pytest.raises(ValueError):
s.sample(n=3, weights='weight_column')

with catch_warnings(record=True):
simplefilter("ignore", FutureWarning)
panel = Panel(items=[0, 1, 2], major_axis=[2, 3, 4],
minor_axis=[3, 4, 5])
with pytest.raises(ValueError):
panel.sample(n=1, weights='weight_column')

with pytest.raises(ValueError):
df.sample(n=1, weights='weight_column', axis=1)

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

[tm.assert_series_equal(empty_series, higher_dim.squeeze())
for higher_dim in [empty_series, empty_frame, empty_panel]]
for higher_dim in [empty_series, empty_frame]]

# axis argument
df = tm.makeTimeDataFrame(nper=1).iloc[:, :1]
Expand Down
64 changes: 0 additions & 64 deletions pandas/tests/generic/test_label_or_level_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pandas.core.dtypes.missing import array_equivalent

import pandas as pd
import pandas.util.testing as tm


# Fixtures
Expand Down Expand Up @@ -46,13 +45,6 @@ def df_duplabels(df):
return df


@pytest.fixture
def panel():
with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False):
return pd.Panel()


# Test is label/level reference
# =============================
def get_labels_levels(df_levels):
Expand Down Expand Up @@ -134,32 +126,6 @@ def test_is_level_reference_series_axis1_error(df):
s._is_level_reference('L1', axis=1)


# Panel
# -----
def test_is_level_reference_panel_error(panel):
msg = ("_is_level_reference is not implemented for {type}"
.format(type=type(panel)))

with pytest.raises(NotImplementedError, match=msg):
panel._is_level_reference('L1', axis=0)


def test_is_label_reference_panel_error(panel):
msg = ("_is_label_reference is not implemented for {type}"
.format(type=type(panel)))

with pytest.raises(NotImplementedError, match=msg):
panel._is_label_reference('L1', axis=0)


def test_is_label_or_level_reference_panel_error(panel):
msg = ("_is_label_or_level_reference is not implemented for {type}"
.format(type=type(panel)))

with pytest.raises(NotImplementedError, match=msg):
panel._is_label_or_level_reference('L1', axis=0)


# Test _check_label_or_level_ambiguity_df
# =======================================

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


# Panel
# -----
def test_check_label_or_level_ambiguity_panel_error(panel):
msg = ("_check_label_or_level_ambiguity is not implemented for {type}"
.format(type=type(panel)))

with pytest.raises(NotImplementedError, match=msg):
panel._check_label_or_level_ambiguity("L1", axis=0)


# Test _get_label_or_level_values
# ===============================
def assert_label_values(frame, labels, axis):
Expand Down Expand Up @@ -322,16 +278,6 @@ def test_get_label_or_level_values_series_axis1_error(df):
s._get_label_or_level_values('L1', axis=1)


# Panel
# -----
def test_get_label_or_level_values_panel_error(panel):
msg = ("_get_label_or_level_values is not implemented for {type}"
.format(type=type(panel)))

with pytest.raises(NotImplementedError, match=msg):
panel._get_label_or_level_values('L1', axis=0)


# Test _drop_labels_or_levels
# ===========================
def assert_labels_dropped(frame, labels, axis):
Expand Down Expand Up @@ -394,13 +340,3 @@ def test_drop_labels_or_levels_series(df):

with pytest.raises(ValueError, match="not valid labels or levels"):
s._drop_labels_or_levels('L4', axis=0)


# Panel
# -----
def test_drop_labels_or_levels_panel_error(panel):
msg = ("_drop_labels_or_levels is not implemented for {type}"
.format(type=type(panel)))

with pytest.raises(NotImplementedError, match=msg):
panel._drop_labels_or_levels('L1', axis=0)
1 change: 0 additions & 1 deletion pandas/tests/indexing/test_iloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ def test_iloc_getitem_neg_int_can_reach_first_index(self):

def test_iloc_getitem_dups(self):

# no dups in panel (bug?)
self.check_result('list int (dups)', 'iloc', [0, 1, 1, 3], 'ix',
{0: [0, 2, 2, 6], 1: [0, 3, 3, 9]},
objs=['series', 'frame'], typs=['ints', 'uints'])
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/reshape/merge/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
a_ = np.array


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

def setup_method(self, method):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import pandas as pd
from pandas import (
CategoricalIndex, DataFrame, DatetimeIndex, Index, Interval, IntervalIndex,
Panel, PeriodIndex, Series, Timedelta, TimedeltaIndex, Timestamp)
PeriodIndex, Series, Timedelta, TimedeltaIndex, Timestamp)
from pandas.core.accessor import PandasDelegate
from pandas.core.arrays import DatetimeArray, PandasArray, TimedeltaArray
from pandas.core.base import NoNewAttributesMixin, PandasObject
Expand Down Expand Up @@ -239,7 +239,7 @@ def check_ops_properties(self, props, filter=None, ignore_failures=False):
with pytest.raises(err):
getattr(o, op)

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