Skip to content

Commit 873d007

Browse files
committed
remove Categorical name warnings from tests, xref #10482
1 parent c399b9e commit 873d007

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

pandas/tests/test_categorical.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,8 @@ def test_deprecated_levels(self):
12071207
self.assertFalse(LooseVersion(pd.__version__) >= '0.18')
12081208

12091209
def test_removed_names_produces_warning(self):
1210+
1211+
# 10482
12101212
with tm.assert_produces_warning(UserWarning):
12111213
Categorical([0,1], name="a")
12121214

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

35823584
def test_pickle_v0_14_1(self):
3583-
cat = pd.Categorical(values=['a', 'b', 'c'],
3584-
categories=['a', 'b', 'c', 'd'],
3585-
name='foobar', ordered=False)
3585+
3586+
# we have the name warning
3587+
# 10482
3588+
with tm.assert_produces_warning(UserWarning):
3589+
cat = pd.Categorical(values=['a', 'b', 'c'],
3590+
categories=['a', 'b', 'c', 'd'],
3591+
name='foobar', ordered=False)
35863592
pickle_path = os.path.join(tm.get_data_path(),
35873593
'categorical_0_14_1.pickle')
35883594
# This code was executed once on v0.14.1 to generate the pickle:
@@ -3597,9 +3603,12 @@ def test_pickle_v0_15_2(self):
35973603
# ordered -> _ordered
35983604
# GH 9347
35993605

3600-
cat = pd.Categorical(values=['a', 'b', 'c'],
3601-
categories=['a', 'b', 'c', 'd'],
3602-
name='foobar', ordered=False)
3606+
# we have the name warning
3607+
# 10482
3608+
with tm.assert_produces_warning(UserWarning):
3609+
cat = pd.Categorical(values=['a', 'b', 'c'],
3610+
categories=['a', 'b', 'c', 'd'],
3611+
name='foobar', ordered=False)
36033612
pickle_path = os.path.join(tm.get_data_path(),
36043613
'categorical_0_15_2.pickle')
36053614
# This code was executed once on v0.15.2 to generate the pickle:

pandas/tests/test_groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3570,7 +3570,7 @@ def test_groupby_categorical_index(self):
35703570

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

0 commit comments

Comments
 (0)