Skip to content

Removed Panel Kludge from Pickle/Msgpack tests #27082

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 14 commits into from
Jun 27, 2019
Merged
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
44 changes: 11 additions & 33 deletions pandas/tests/io/generate_legacy_storage_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
self-contained to write legacy storage (pickle/msgpack) files

To use this script. Create an environment where you want
generate pickles, say its for 0.18.1, with your pandas clone
generate pickles, say its for 0.20.3, with your pandas clone
in ~/pandas

. activate pandas_0.18.1
. activate pandas_0.20.3
cd ~/

$ python pandas/pandas/tests/io/generate_legacy_storage_files.py \
pandas/pandas/tests/io/data/legacy_pickle/0.18.1/ pickle

This script generates a storage file for the current arch, system,
and python version
pandas version: 0.18.1
pandas version: 0.20.3
output dir : pandas/pandas/tests/io/data/legacy_pickle/0.18.1/
storage format: pickle
created pickle file: 0.18.1_x86_64_darwin_3.5.2.pickle
created pickle file: 0.20.3_x86_64_darwin_3.5.2.pickle

The idea here is you are using the *current* version of the
generate_legacy_storage_files with an *older* version of pandas to
Expand Down Expand Up @@ -118,9 +118,8 @@ def create_data():
uint=Index(np.arange(10, dtype=np.uint64)),
timedelta=timedelta_range('00:00:00', freq='30T', periods=10))

if _loose_version >= LooseVersion('0.18'):
from pandas import RangeIndex
index['range'] = RangeIndex(10)
from pandas import RangeIndex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can move this import to the top i think

index['range'] = RangeIndex(10)

if _loose_version >= LooseVersion('0.21'):
from pandas import interval_range
Expand Down Expand Up @@ -191,14 +190,9 @@ def create_data():
nat=NaT,
tz=Timestamp('2011-01-01', tz='US/Eastern'))

if _loose_version < LooseVersion('0.19.2'):
timestamp['freq'] = Timestamp('2011-01-01', offset='D')
timestamp['both'] = Timestamp('2011-01-01', tz='Asia/Tokyo',
offset='M')
else:
timestamp['freq'] = Timestamp('2011-01-01', freq='D')
timestamp['both'] = Timestamp('2011-01-01', tz='Asia/Tokyo',
freq='M')
timestamp['freq'] = Timestamp('2011-01-01', freq='D')
timestamp['both'] = Timestamp('2011-01-01', tz='Asia/Tokyo',
freq='M')

off = {'DateOffset': DateOffset(years=1),
'DateOffset_h_ns': DateOffset(hour=6, nanoseconds=5824),
Expand Down Expand Up @@ -239,14 +233,6 @@ def create_data():
def create_pickle_data():
data = create_data()

# Pre-0.14.1 versions generated non-unpicklable mixed-type frames and
# panels if their columns/items were non-unique.
if _loose_version < LooseVersion('0.14.1'):
del data['frame']['mixed_dup']
del data['panel']['mixed_dup']
if _loose_version < LooseVersion('0.17.0'):
del data['series']['period']
del data['scalars']['period']
return data


Expand All @@ -256,14 +242,6 @@ def _u(x):

def create_msgpack_data():
data = create_data()
if _loose_version < LooseVersion('0.17.0'):
del data['frame']['mixed_dup']
del data['panel']['mixed_dup']
del data['frame']['dup']
del data['panel']['dup']
if _loose_version < LooseVersion('0.18.0'):
del data['series']['dt_tz']
del data['frame']['dt_mixed_tzs']
# Not supported
del data['sp_series']
del data['sp_frame']
Expand All @@ -272,7 +250,8 @@ def create_msgpack_data():
del data['frame']['cat_onecol']
del data['frame']['cat_and_float']
del data['scalars']['period']
if _loose_version < LooseVersion('0.23.0'):
if _loose_version >= LooseVersion('0.21') and (
_loose_version < LooseVersion('0.23.0')):
del data['index']['interval']
del data['offsets']
return _u(data)
Expand All @@ -285,7 +264,6 @@ def platform_name():

def write_legacy_pickles(output_dir):

# make sure we are < 0.13 compat (in py3)
version = pandas.__version__

print("This script generates a storage file for the current arch, system, "
Expand Down
12 changes: 0 additions & 12 deletions pandas/tests/io/test_packers.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def check_arbitrary(a, b):
assert(a == b)


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

def setup_method(self, method):
Expand All @@ -99,7 +98,6 @@ def encode_decode(self, x, compress=None, **kwargs):
return read_msgpack(p, **kwargs)


@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
class TestAPI(TestPackers):

def test_string_io(self):
Expand Down Expand Up @@ -463,7 +461,6 @@ def test_basic(self):
assert_categorical_equal(i, i_rec)


@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
class TestNDFrame(TestPackers):

def setup_method(self, method):
Expand Down Expand Up @@ -842,7 +839,6 @@ def legacy_packer(request, datapath):
return datapath(request.param)


@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
@pytest.mark.filterwarnings("ignore:Sparse:FutureWarning")
class TestMsgpack:
"""
Expand All @@ -858,15 +854,11 @@ class TestMsgpack:
minimum_structure = {'series': ['float', 'int', 'mixed',
'ts', 'mi', 'dup'],
'frame': ['float', 'int', 'mixed', 'mi'],
'panel': ['float'],
'index': ['int', 'date', 'period'],
'mi': ['reg2']}

def check_min_structure(self, data, version):
for typ, v in self.minimum_structure.items():
if typ == "panel":
# FIXME: kludge; get this key out of the legacy file
continue

assert typ in data, '"{0}" not found in unpacked data'.format(typ)
for kind in v:
Expand All @@ -880,10 +872,6 @@ def compare(self, current_data, all_data, vf, version):
else:
data = read_msgpack(vf)

if "panel" in data:
# FIXME: kludge; get the key out of the stored file
del data["panel"]

self.check_min_structure(data, version)
for typ, dv in data.items():
assert typ in all_data, ('unpacked data contains '
Expand Down
4 changes: 0 additions & 4 deletions pandas/tests/io/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ def compare(data, vf, version):

m = globals()
for typ, dv in data.items():
if typ == "panel":
# FIXME: kludge; get this key out of the legacy file
continue

for dt, result in dv.items():
try:
expected = data[typ][dt]
Expand Down