Skip to content

Commit f1254df

Browse files
committed
MAINT: Relocated backwards compat categorical pickle tests
1 parent f3321cb commit f1254df

File tree

5 files changed

+40
-40
lines changed

5 files changed

+40
-40
lines changed

pandas/io/tests/test_pickle.py

+38
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,44 @@ def python_unpickler(path):
231231
result = python_unpickler(path)
232232
self.compare_element(result, expected, typ)
233233

234+
def test_pickle_v0_14_1(self):
235+
236+
# we have the name warning
237+
# 10482
238+
with tm.assert_produces_warning(UserWarning):
239+
cat = pd.Categorical(values=['a', 'b', 'c'],
240+
categories=['a', 'b', 'c', 'd'],
241+
name='foobar', ordered=False)
242+
pickle_path = os.path.join(tm.get_data_path(),
243+
'categorical_0_14_1.pickle')
244+
# This code was executed once on v0.14.1 to generate the pickle:
245+
#
246+
# cat = Categorical(labels=np.arange(3), levels=['a', 'b', 'c', 'd'],
247+
# name='foobar')
248+
# with open(pickle_path, 'wb') as f: pickle.dump(cat, f)
249+
#
250+
tm.assert_categorical_equal(cat, pd.read_pickle(pickle_path))
251+
252+
def test_pickle_v0_15_2(self):
253+
# ordered -> _ordered
254+
# GH 9347
255+
256+
# we have the name warning
257+
# 10482
258+
with tm.assert_produces_warning(UserWarning):
259+
cat = pd.Categorical(values=['a', 'b', 'c'],
260+
categories=['a', 'b', 'c', 'd'],
261+
name='foobar', ordered=False)
262+
pickle_path = os.path.join(tm.get_data_path(),
263+
'categorical_0_15_2.pickle')
264+
# This code was executed once on v0.15.2 to generate the pickle:
265+
#
266+
# cat = Categorical(labels=np.arange(3), levels=['a', 'b', 'c', 'd'],
267+
# name='foobar')
268+
# with open(pickle_path, 'wb') as f: pickle.dump(cat, f)
269+
#
270+
tm.assert_categorical_equal(cat, pd.read_pickle(pickle_path))
271+
234272

235273
if __name__ == '__main__':
236274
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],

pandas/tests/test_categorical.py

-38
Original file line numberDiff line numberDiff line change
@@ -4419,44 +4419,6 @@ def test_dt_accessor_api_for_categorical(self):
44194419
invalid.dt
44204420
self.assertFalse(hasattr(invalid, 'str'))
44214421

4422-
def test_pickle_v0_14_1(self):
4423-
4424-
# we have the name warning
4425-
# 10482
4426-
with tm.assert_produces_warning(UserWarning):
4427-
cat = pd.Categorical(values=['a', 'b', 'c'],
4428-
categories=['a', 'b', 'c', 'd'],
4429-
name='foobar', ordered=False)
4430-
pickle_path = os.path.join(tm.get_data_path(),
4431-
'categorical_0_14_1.pickle')
4432-
# This code was executed once on v0.14.1 to generate the pickle:
4433-
#
4434-
# cat = Categorical(labels=np.arange(3), levels=['a', 'b', 'c', 'd'],
4435-
# name='foobar')
4436-
# with open(pickle_path, 'wb') as f: pickle.dump(cat, f)
4437-
#
4438-
self.assert_categorical_equal(cat, pd.read_pickle(pickle_path))
4439-
4440-
def test_pickle_v0_15_2(self):
4441-
# ordered -> _ordered
4442-
# GH 9347
4443-
4444-
# we have the name warning
4445-
# 10482
4446-
with tm.assert_produces_warning(UserWarning):
4447-
cat = pd.Categorical(values=['a', 'b', 'c'],
4448-
categories=['a', 'b', 'c', 'd'],
4449-
name='foobar', ordered=False)
4450-
pickle_path = os.path.join(tm.get_data_path(),
4451-
'categorical_0_15_2.pickle')
4452-
# This code was executed once on v0.15.2 to generate the pickle:
4453-
#
4454-
# cat = Categorical(labels=np.arange(3), levels=['a', 'b', 'c', 'd'],
4455-
# name='foobar')
4456-
# with open(pickle_path, 'wb') as f: pickle.dump(cat, f)
4457-
#
4458-
self.assert_categorical_equal(cat, pd.read_pickle(pickle_path))
4459-
44604422
def test_concat_categorical(self):
44614423
# See GH 10177
44624424
df1 = pd.DataFrame(

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ def pxd(name):
589589
'tests/data/legacy_msgpack/*/*.msgpack',
590590
'tests/data/*.csv*',
591591
'tests/data/*.dta',
592+
'tests/data/*.pickle',
592593
'tests/data/*.txt',
593594
'tests/data/*.xls',
594595
'tests/data/*.xlsx',
@@ -605,8 +606,7 @@ def pxd(name):
605606
'tests/data/html_encoding/*.html',
606607
'tests/json/data/*.json'],
607608
'pandas.tools': ['tests/data/*.csv'],
608-
'pandas.tests': ['data/*.pickle',
609-
'data/*.csv'],
609+
'pandas.tests': ['data/*.csv'],
610610
'pandas.tests.formats': ['data/*.csv'],
611611
'pandas.tests.indexes': ['data/*.pickle'],
612612
'pandas.tseries.tests': ['data/*.pickle',

0 commit comments

Comments
 (0)