Skip to content

Commit e2752a8

Browse files
committed
additional review edits
1 parent 1dceb04 commit e2752a8

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

doc/source/whatsnew/v0.23.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ Other API Changes
507507
- Set operations (union, difference...) on :class:`IntervalIndex` with incompatible index types will now raise a ``TypeError`` rather than a ``ValueError`` (:issue:`19329`)
508508
- :class:`DateOffset` objects render more simply, e.g. "<DateOffset: days=1>" instead of "<DateOffset: kwds={'days': 1}>" (:issue:`19403`)
509509
- :func:`pandas.merge` provides a more informative error message when trying to merge on timezone-aware and timezone-naive columns (:issue:`15800`)
510-
- The default value of the ``ordered`` parameter for :class:`~pandas.api.types.CategoricalDtype` has changed from ``False`` to ``None``. Behavior should remain consistent for downstream objects, such as :class:`Categorical` (:issue:`18790`)
510+
- The default value of the ``ordered`` parameter for :class:`~pandas.api.types.CategoricalDtype` has changed from ``False`` to ``None`` to allow updating of ``categories`` without impacting ``ordered``. Behavior should remain consistent for downstream objects, such as :class:`Categorical` (:issue:`18790`)
511511

512512
.. _whatsnew_0230.deprecations:
513513

pandas/tests/dtypes/test_dtypes.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,22 @@ def test_same_categories_different_order(self):
642642
@pytest.mark.parametrize('ordered1', [True, False, None])
643643
@pytest.mark.parametrize('ordered2', [True, False, None])
644644
def test_categorical_equality(self, ordered1, ordered2):
645-
# same categories
645+
# same categories, same order
646+
# any combination of None/False are equal
647+
# True/True is the only combination with True that are equal
646648
c1 = CategoricalDtype(list('abc'), ordered1)
647649
c2 = CategoricalDtype(list('abc'), ordered2)
648650
result = c1 == c2
649-
expected = (ordered1 is ordered2) or not any([ordered1, ordered2])
651+
expected = bool(ordered1) is bool(ordered2)
652+
assert result is expected
653+
654+
# same categories, different order
655+
# any combination of None/False are equal (order doesn't matter)
656+
# any combination with True are not equal (different order of cats)
657+
c1 = CategoricalDtype(list('abc'), ordered1)
658+
c2 = CategoricalDtype(list('cab'), ordered2)
659+
result = c1 == c2
660+
expected = (bool(ordered1) is False) and (bool(ordered2) is False)
650661
assert result is expected
651662

652663
# different categories

0 commit comments

Comments
 (0)