Skip to content

Commit

Permalink
Move test to test_unique and add whats new
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghasem Naddaf committed Nov 15, 2017
1 parent b35f16e commit 567d48f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.21.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Bug Fixes
- Bug in :class:`DatetimeIndex` subtracting datetimelike from DatetimeIndex could fail to overflow (:issue:`18020`)
- Bug in ``pd.Series.rolling.skew()`` and ``rolling.kurt()`` with all equal values has floating issue (:issue:`18044`)
- Bug in ``pd.DataFrameGroupBy.count()`` when counting over a datetimelike column (:issue:`13393`)
- Bug in ``pd.Categorical.unique()`` returning read-only array when all categories were ``NaN`` (:issue:`18051`)

Conversion
^^^^^^^^^^
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,10 +1227,6 @@ def test_set_categories(self):
exp_categories = Index(["a", "b", "c", "d"])
tm.assert_index_equal(cat.categories, exp_categories)

# all-nan categories GH 18051
cat_nan = Categorical([np.nan])
assert cat_nan.unique()._codes.flags.writeable

# internals...
c = Categorical([1, 2, 3, 4, 1], categories=[1, 2, 3, 4], ordered=True)
tm.assert_numpy_array_equal(c._codes, np.array([0, 1, 2, 3, 0],
Expand Down Expand Up @@ -1679,6 +1675,10 @@ def test_unique(self):
exp_cat = Categorical(["b", np.nan, "a"], categories=["b", "a"])
tm.assert_categorical_equal(res, exp_cat)

# GH 18051 unique()._codes should be writeable
cat_nan = Categorical([np.nan])
assert cat_nan.unique()._codes.flags.writeable

def test_unique_ordered(self):
# keep categories order when ordered=True
cat = Categorical(['b', 'a', 'b'], categories=['a', 'b'], ordered=True)
Expand Down

0 comments on commit 567d48f

Please sign in to comment.