Skip to content

Commit

Permalink
MAINT: Relocated backwards compat categorical pickle tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyoung committed Jul 14, 2016
1 parent f3321cb commit f1254df
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 40 deletions.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions pandas/io/tests/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,44 @@ def python_unpickler(path):
result = python_unpickler(path)
self.compare_element(result, expected, typ)

def test_pickle_v0_14_1(self):

# we have the name warning
# 10482
with tm.assert_produces_warning(UserWarning):
cat = pd.Categorical(values=['a', 'b', 'c'],
categories=['a', 'b', 'c', 'd'],
name='foobar', ordered=False)
pickle_path = os.path.join(tm.get_data_path(),
'categorical_0_14_1.pickle')
# This code was executed once on v0.14.1 to generate the pickle:
#
# cat = Categorical(labels=np.arange(3), levels=['a', 'b', 'c', 'd'],
# name='foobar')
# with open(pickle_path, 'wb') as f: pickle.dump(cat, f)
#
tm.assert_categorical_equal(cat, pd.read_pickle(pickle_path))

def test_pickle_v0_15_2(self):
# ordered -> _ordered
# GH 9347

# we have the name warning
# 10482
with tm.assert_produces_warning(UserWarning):
cat = pd.Categorical(values=['a', 'b', 'c'],
categories=['a', 'b', 'c', 'd'],
name='foobar', ordered=False)
pickle_path = os.path.join(tm.get_data_path(),
'categorical_0_15_2.pickle')
# This code was executed once on v0.15.2 to generate the pickle:
#
# cat = Categorical(labels=np.arange(3), levels=['a', 'b', 'c', 'd'],
# name='foobar')
# with open(pickle_path, 'wb') as f: pickle.dump(cat, f)
#
tm.assert_categorical_equal(cat, pd.read_pickle(pickle_path))


if __name__ == '__main__':
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
Expand Down
38 changes: 0 additions & 38 deletions pandas/tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -4419,44 +4419,6 @@ def test_dt_accessor_api_for_categorical(self):
invalid.dt
self.assertFalse(hasattr(invalid, 'str'))

def test_pickle_v0_14_1(self):

# we have the name warning
# 10482
with tm.assert_produces_warning(UserWarning):
cat = pd.Categorical(values=['a', 'b', 'c'],
categories=['a', 'b', 'c', 'd'],
name='foobar', ordered=False)
pickle_path = os.path.join(tm.get_data_path(),
'categorical_0_14_1.pickle')
# This code was executed once on v0.14.1 to generate the pickle:
#
# cat = Categorical(labels=np.arange(3), levels=['a', 'b', 'c', 'd'],
# name='foobar')
# with open(pickle_path, 'wb') as f: pickle.dump(cat, f)
#
self.assert_categorical_equal(cat, pd.read_pickle(pickle_path))

def test_pickle_v0_15_2(self):
# ordered -> _ordered
# GH 9347

# we have the name warning
# 10482
with tm.assert_produces_warning(UserWarning):
cat = pd.Categorical(values=['a', 'b', 'c'],
categories=['a', 'b', 'c', 'd'],
name='foobar', ordered=False)
pickle_path = os.path.join(tm.get_data_path(),
'categorical_0_15_2.pickle')
# This code was executed once on v0.15.2 to generate the pickle:
#
# cat = Categorical(labels=np.arange(3), levels=['a', 'b', 'c', 'd'],
# name='foobar')
# with open(pickle_path, 'wb') as f: pickle.dump(cat, f)
#
self.assert_categorical_equal(cat, pd.read_pickle(pickle_path))

def test_concat_categorical(self):
# See GH 10177
df1 = pd.DataFrame(
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ def pxd(name):
'tests/data/legacy_msgpack/*/*.msgpack',
'tests/data/*.csv*',
'tests/data/*.dta',
'tests/data/*.pickle',
'tests/data/*.txt',
'tests/data/*.xls',
'tests/data/*.xlsx',
Expand All @@ -605,8 +606,7 @@ def pxd(name):
'tests/data/html_encoding/*.html',
'tests/json/data/*.json'],
'pandas.tools': ['tests/data/*.csv'],
'pandas.tests': ['data/*.pickle',
'data/*.csv'],
'pandas.tests': ['data/*.csv'],
'pandas.tests.formats': ['data/*.csv'],
'pandas.tests.indexes': ['data/*.pickle'],
'pandas.tseries.tests': ['data/*.pickle',
Expand Down

0 comments on commit f1254df

Please sign in to comment.