Skip to content

Commit

Permalink
CLN: removed setter method of categorical's ordered attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyoung committed Jul 16, 2016
1 parent d7c028d commit 58938e7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.19.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ Removal of prior version deprecations/changes

- ``DataFrame.to_csv()`` has dropped the ``engine`` parameter, as was deprecated in 0.17.1 (:issue:`11274`, :issue:`13419`)
- ``DataFrame.to_dict()`` has dropped the ``outtype`` parameter in favor of ``orient`` (:issue:`13627`, :issue:`8486`)
- ``pd.Categorical`` has dropped setting of the ``ordered`` attribute directly in favor of the ``set_ordered`` method (:issue:`13671`)
- ``pd.Categorical`` has dropped the ``levels`` attribute in favour of ``categories`` (:issue:`8376`)


Expand Down
8 changes: 1 addition & 7 deletions pandas/core/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,12 +571,6 @@ def _get_categories(self):

_ordered = None

def _set_ordered(self, value):
""" Sets the ordered attribute to the boolean value """
warn("Setting 'ordered' directly is deprecated, use 'set_ordered'",
FutureWarning, stacklevel=2)
self.set_ordered(value, inplace=True)

def set_ordered(self, value, inplace=False):
"""
Sets the ordered attribute to the boolean value
Expand Down Expand Up @@ -624,7 +618,7 @@ def _get_ordered(self):
""" Gets the ordered attribute """
return self._ordered

ordered = property(fget=_get_ordered, fset=_set_ordered)
ordered = property(fget=_get_ordered)

def set_categories(self, new_categories, ordered=None, rename=False,
inplace=False):
Expand Down
11 changes: 5 additions & 6 deletions pandas/tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,13 +808,12 @@ def test_set_ordered(self):
cat2.set_ordered(False, inplace=True)
self.assertFalse(cat2.ordered)

# deperecated in v0.16.0
with tm.assert_produces_warning(FutureWarning):
cat.ordered = False
self.assertFalse(cat.ordered)
with tm.assert_produces_warning(FutureWarning):
# removed in 0.19.0
msg = "can\'t set attribute"
with tm.assertRaisesRegexp(AttributeError, msg):
cat.ordered = True
self.assertTrue(cat.ordered)
with tm.assertRaisesRegexp(AttributeError, msg):
cat.ordered = False

def test_set_categories(self):
cat = Categorical(["a", "b", "c", "a"], ordered=True)
Expand Down

0 comments on commit 58938e7

Please sign in to comment.