@@ -1227,10 +1227,6 @@ def test_set_categories(self):
1227
1227
exp_categories = Index (["a" , "b" , "c" , "d" ])
1228
1228
tm .assert_index_equal (cat .categories , exp_categories )
1229
1229
1230
- # all-nan categories GH 18051
1231
- cat_nan = Categorical ([np .nan ])
1232
- assert cat_nan .unique ()._codes .flags .writeable
1233
-
1234
1230
# internals...
1235
1231
c = Categorical ([1 , 2 , 3 , 4 , 1 ], categories = [1 , 2 , 3 , 4 ], ordered = True )
1236
1232
tm .assert_numpy_array_equal (c ._codes , np .array ([0 , 1 , 2 , 3 , 0 ],
@@ -1679,6 +1675,10 @@ def test_unique(self):
1679
1675
exp_cat = Categorical (["b" , np .nan , "a" ], categories = ["b" , "a" ])
1680
1676
tm .assert_categorical_equal (res , exp_cat )
1681
1677
1678
+ # GH 18051 unique()._codes should be writeable
1679
+ cat_nan = Categorical ([np .nan ])
1680
+ assert cat_nan .unique ()._codes .flags .writeable
1681
+
1682
1682
def test_unique_ordered (self ):
1683
1683
# keep categories order when ordered=True
1684
1684
cat = Categorical (['b' , 'a' , 'b' ], categories = ['a' , 'b' ], ordered = True )
0 commit comments