Skip to content

Commit

Permalink
remove Categorical name warnings from tests, xref #10482
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback committed Aug 23, 2015
1 parent c399b9e commit 873d007
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions pandas/tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,8 @@ def test_deprecated_levels(self):
self.assertFalse(LooseVersion(pd.__version__) >= '0.18')

def test_removed_names_produces_warning(self):

# 10482
with tm.assert_produces_warning(UserWarning):
Categorical([0,1], name="a")

Expand Down Expand Up @@ -3580,9 +3582,13 @@ def test_cat_accessor_api(self):
self.assertFalse(hasattr(invalid, 'cat'))

def test_pickle_v0_14_1(self):
cat = pd.Categorical(values=['a', 'b', 'c'],
categories=['a', 'b', 'c', 'd'],
name='foobar', ordered=False)

# 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:
Expand All @@ -3597,9 +3603,12 @@ def test_pickle_v0_15_2(self):
# ordered -> _ordered
# GH 9347

cat = pd.Categorical(values=['a', 'b', 'c'],
categories=['a', 'b', 'c', 'd'],
name='foobar', ordered=False)
# 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:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -3570,7 +3570,7 @@ def test_groupby_categorical_index(self):

levels = ['foo', 'bar', 'baz', 'qux']
codes = np.random.randint(0, 4, size=20)
cats = Categorical.from_codes(codes, levels, name='myfactor', ordered=True)
cats = Categorical.from_codes(codes, levels, ordered=True)
df = DataFrame(np.repeat(np.arange(20),4).reshape(-1,4), columns=list('abcd'))
df['cats'] = cats

Expand Down

0 comments on commit 873d007

Please sign in to comment.