Skip to content

Commit 428a1b3

Browse files
committed
Added __iadd__ test, fixed whatsnew
1 parent 84ba405 commit 428a1b3

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

doc/source/whatsnew/v0.20.0.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,8 @@ Deprecations
536536
- ``Series.sortlevel`` and ``DataFrame.sortlevel`` have been deprecated in favor of ``Series.sort_index`` and ``DataFrame.sort_index`` (:issue:`15099`)
537537
- importing ``concat`` from ``pandas.tools.merge`` has been deprecated in favor of imports from the ``pandas`` namespace. This should only affect explict imports (:issue:`15358`)
538538
- ``Series/DataFrame/Panel.consolidate()`` been deprecated as a public method. (:issue:`15483`)
539-
- ``FrozenList.__add__`` has been depricated in favor of ``FrozenList.union`` (:issue: `15475`)
539+
- ``FrozenList.__add__`` has been depricated. (:issue: `15475`)
540+
- ``FrozenList.__iadd__`` has been depricated. (:issue: `15475`)
540541

541542
.. _whatsnew_0200.prior_deprecations:
542543

pandas/indexes/frozen.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def __add__(self, other):
3232

3333
def __iadd__(self, other):
3434
warnings.warn("__iadd__ is deprecated, use union(...)", FutureWarning)
35-
return self.union(other)
35+
if isinstance(other, tuple):
36+
other = list(other)
37+
return super(FrozenList, self).__iadd__(other)
3638

3739
# Python 2 compat
3840
def __getslice__(self, i, j):

pandas/tests/indexes/test_frozen.py

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ def setUp(self):
1717
def test_add(self):
1818
self.assert_produces_warning(FutureWarning)
1919

20+
def test_iadd(self):
21+
q = q1 = [1, 2, 3, 4, 5]
22+
q = FrozenList(q)
23+
q += [1, 2, 3]
24+
expected = FrozenList(q1 + [1, 2, 3])
25+
self.check_result(q, expected)
26+
2027
def test_union(self):
2128
result = self.container.union((1, 2, 3))
2229
expected = FrozenList(self.lst + [1, 2, 3])

0 commit comments

Comments
 (0)