Skip to content
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

DEPR: remove assert_panel_equal #25238

Merged
merged 3 commits into from
Feb 11, 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
32 changes: 4 additions & 28 deletions pandas/tests/generic/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import pandas as pd
from pandas import DataFrame, MultiIndex, Panel, Series, date_range
import pandas.util.testing as tm
from pandas.util.testing import (
assert_frame_equal, assert_panel_equal, assert_series_equal)
from pandas.util.testing import assert_frame_equal, assert_series_equal

import pandas.io.formats.printing as printing

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

# Test default axes
with catch_warnings(record=True):
simplefilter("ignore", FutureWarning)
p = Panel(items=['a', 'b', 'c'], major_axis=[2, 4, 6],
minor_axis=[1, 3, 5])
assert_panel_equal(
p.sample(n=3, random_state=42), p.sample(n=3, axis=1,
random_state=42))
assert_frame_equal(
df.sample(n=3, random_state=42), df.sample(n=3, axis=0,
random_state=42))
assert_frame_equal(
df.sample(n=3, random_state=42), df.sample(n=3, axis=0,
random_state=42))

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

def test_pipe_panel(self):
with catch_warnings(record=True):
simplefilter("ignore", FutureWarning)
wp = Panel({'r1': DataFrame({"A": [1, 2, 3]})})
f = lambda x, y: x + y
result = wp.pipe(f, 2)
expected = wp + 2
assert_panel_equal(result, expected)

result = wp.pipe((f, 'y'), x=1)
expected = wp + 1
assert_panel_equal(result, expected)

with pytest.raises(ValueError):
wp.pipe((f, 'y'), x=1, y=1)

@pytest.mark.parametrize('box', [pd.Series, pd.DataFrame])
def test_axis_classmethods(self, box):
obj = box()
Expand Down
38 changes: 0 additions & 38 deletions pandas/tests/generic/test_panel.py

This file was deleted.

2 changes: 0 additions & 2 deletions pandas/tests/indexing/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ def _print(result, error=None):
tm.assert_series_equal(rs, xp)
elif xp.ndim == 2:
tm.assert_frame_equal(rs, xp)
elif xp.ndim == 3:
tm.assert_panel_equal(rs, xp)
result = 'ok'
except AssertionError as e:
detail = str(e)
Expand Down
46 changes: 0 additions & 46 deletions pandas/tests/indexing/multiindex/test_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,49 +55,3 @@ def test_iloc_getitem_panel_multiindex(self):

result = p.loc[:, (1, 'y'), 'u']
tm.assert_series_equal(result, expected)

def test_panel_setitem_with_multiindex(self):

# 10360
# failing with a multi-index
arr = np.array([[[1, 2, 3], [0, 0, 0]],
[[0, 0, 0], [0, 0, 0]]],
dtype=np.float64)

# reg index
axes = dict(items=['A', 'B'], major_axis=[0, 1],
minor_axis=['X', 'Y', 'Z'])
p1 = Panel(0., **axes)
p1.iloc[0, 0, :] = [1, 2, 3]
expected = Panel(arr, **axes)
tm.assert_panel_equal(p1, expected)

# multi-indexes
axes['items'] = MultiIndex.from_tuples(
[('A', 'a'), ('B', 'b')])
p2 = Panel(0., **axes)
p2.iloc[0, 0, :] = [1, 2, 3]
expected = Panel(arr, **axes)
tm.assert_panel_equal(p2, expected)

axes['major_axis'] = MultiIndex.from_tuples(
[('A', 1), ('A', 2)])
p3 = Panel(0., **axes)
p3.iloc[0, 0, :] = [1, 2, 3]
expected = Panel(arr, **axes)
tm.assert_panel_equal(p3, expected)

axes['minor_axis'] = MultiIndex.from_product(
[['X'], range(3)])
p4 = Panel(0., **axes)
p4.iloc[0, 0, :] = [1, 2, 3]
expected = Panel(arr, **axes)
tm.assert_panel_equal(p4, expected)

arr = np.array(
[[[1, 0, 0], [2, 0, 0]], [[0, 0, 0], [0, 0, 0]]],
dtype=np.float64)
p5 = Panel(0., **axes)
p5.iloc[0, :, 0] = [1, 2]
expected = Panel(arr, **axes)
tm.assert_panel_equal(p5, expected)
90 changes: 1 addition & 89 deletions pandas/tests/indexing/test_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import pytest

from pandas import DataFrame, Panel, date_range
from pandas import Panel, date_range
from pandas.util import testing as tm


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

# slice
result = p.iloc[1:3]
expected = p.loc[['B', 'C']]
tm.assert_panel_equal(result, expected)

result = p.iloc[:, 0:2]
expected = p.loc[:, ['a', 'b']]
tm.assert_panel_equal(result, expected)

# list of integers
result = p.iloc[[0, 2]]
expected = p.loc[['A', 'C']]
tm.assert_panel_equal(result, expected)

# neg indices
result = p.iloc[[-1, 1], [-1, 1]]
expected = p.loc[['D', 'B'], ['c', 'b']]
tm.assert_panel_equal(result, expected)

# dups indices
result = p.iloc[[-1, -1, 1], [-1, 1]]
expected = p.loc[['D', 'D', 'B'], ['c', 'b']]
tm.assert_panel_equal(result, expected)

# combined
result = p.iloc[0, [True, True], [0, 1]]
expected = p.loc['A', ['a', 'b'], ['one', 'two']]
Expand Down Expand Up @@ -110,18 +86,6 @@ def test_iloc_panel_issue(self):
def test_panel_getitem(self):

with catch_warnings(record=True):
# GH4016, date selection returns a frame when a partial string
# selection
ind = date_range(start="2000", freq="D", periods=1000)
df = DataFrame(
np.random.randn(
len(ind), 5), index=ind, columns=list('ABCDE'))
panel = Panel({'frame_' + c: df for c in list('ABC')})

test2 = panel.loc[:, "2002":"2002-12-31"]
test1 = panel.loc[:, "2002"]
tm.assert_panel_equal(test1, test2)

# with an object-like
# GH 9140
class TestObject(object):
Expand All @@ -138,55 +102,3 @@ def __str__(self):
expected = p.iloc[0]
result = p[obj]
tm.assert_frame_equal(result, expected)

def test_panel_setitem(self):

with catch_warnings(record=True):
# GH 7763
# loc and setitem have setting differences
np.random.seed(0)
index = range(3)
columns = list('abc')

panel = Panel({'A': DataFrame(np.random.randn(3, 3),
index=index, columns=columns),
'B': DataFrame(np.random.randn(3, 3),
index=index, columns=columns),
'C': DataFrame(np.random.randn(3, 3),
index=index, columns=columns)})

replace = DataFrame(np.eye(3, 3), index=range(3), columns=columns)
expected = Panel({'A': replace, 'B': replace, 'C': replace})

p = panel.copy()
for idx in list('ABC'):
p[idx] = replace
tm.assert_panel_equal(p, expected)

p = panel.copy()
for idx in list('ABC'):
p.loc[idx, :, :] = replace
tm.assert_panel_equal(p, expected)

def test_panel_assignment(self):

with catch_warnings(record=True):
# GH3777
wp = Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'],
major_axis=date_range('1/1/2000', periods=5),
minor_axis=['A', 'B', 'C', 'D'])
wp2 = Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'],
major_axis=date_range('1/1/2000', periods=5),
minor_axis=['A', 'B', 'C', 'D'])

# TODO: unused?
# expected = wp.loc[['Item1', 'Item2'], :, ['A', 'B']]

with pytest.raises(NotImplementedError):
wp.loc[['Item1', 'Item2'], :, ['A', 'B']] = wp2.loc[
['Item1', 'Item2'], :, ['A', 'B']]

# to_assign = wp2.loc[['Item1', 'Item2'], :, ['A', 'B']]
# wp.loc[['Item1', 'Item2'], :, ['A', 'B']] = to_assign
# result = wp.loc[['Item1', 'Item2'], :, ['A', 'B']]
# tm.assert_panel_equal(result,expected)
32 changes: 1 addition & 31 deletions pandas/tests/indexing/test_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
import pytest

import pandas as pd
from pandas import DataFrame, Index, Panel, Series, date_range
from pandas import DataFrame, Index, Series, date_range
from pandas.util import testing as tm


class TestPartialSetting(object):

@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
@pytest.mark.filterwarnings("ignore:\\n.ix:DeprecationWarning")
def test_partial_setting(self):

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

with catch_warnings(record=True):
# ## panel ##
p_orig = Panel(np.arange(16).reshape(2, 4, 2),
items=['Item1', 'Item2'],
major_axis=pd.date_range('2001/1/12', periods=4),
minor_axis=['A', 'B'], dtype='float64')

# panel setting via item
p_orig = Panel(np.arange(16).reshape(2, 4, 2),
items=['Item1', 'Item2'],
major_axis=pd.date_range('2001/1/12', periods=4),
minor_axis=['A', 'B'], dtype='float64')
expected = p_orig.copy()
expected['Item3'] = expected['Item1']
p = p_orig.copy()
p.loc['Item3'] = p['Item1']
tm.assert_panel_equal(p, expected)

# panel with aligned series
expected = p_orig.copy()
expected = expected.transpose(2, 1, 0)
expected['C'] = DataFrame({'Item1': [30, 30, 30, 30],
'Item2': [32, 32, 32, 32]},
index=p_orig.major_axis)
expected = expected.transpose(2, 1, 0)
p = p_orig.copy()
p.loc[:, :, 'C'] = Series([30, 32], index=p_orig.items)
tm.assert_panel_equal(p, expected)

# GH 8473
dates = date_range('1/1/2000', periods=8)
df_orig = DataFrame(np.random.randn(8, 4), index=dates,
Expand Down
16 changes: 1 addition & 15 deletions pandas/tests/io/generate_legacy_storage_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@
import os
import platform as pl
import sys
from warnings import catch_warnings, filterwarnings

import numpy as np

from pandas.compat import u

import pandas
from pandas import (
Categorical, DataFrame, Index, MultiIndex, NaT, Panel, Period, Series,
Categorical, DataFrame, Index, MultiIndex, NaT, Period, Series,
SparseDataFrame, SparseSeries, Timestamp, bdate_range, date_range,
period_range, timedelta_range, to_msgpack)

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

with catch_warnings(record=True):
filterwarnings("ignore", "\\nPanel", FutureWarning)
mixed_dup_panel = Panel({u'ItemA': frame[u'float'],
u'ItemB': frame[u'int']})
mixed_dup_panel.items = [u'ItemA', u'ItemA']
panel = dict(float=Panel({u'ItemA': frame[u'float'],
u'ItemB': frame[u'float'] + 1}),
dup=Panel(
np.arange(30).reshape(3, 5, 2).astype(np.float64),
items=[u'A', u'B', u'A']),
mixed_dup=mixed_dup_panel)

cat = dict(int8=Categorical(list('abcdefg')),
int16=Categorical(np.arange(1000)),
int32=Categorical(np.arange(10000)))
Expand Down Expand Up @@ -241,7 +228,6 @@ def create_data():

return dict(series=series,
frame=frame,
panel=panel,
index=index,
scalars=scalars,
mi=mi,
Expand Down
Loading