Skip to content

Commit 3d8be67

Browse files
committed
Move warning into _union method
1 parent 5d14833 commit 3d8be67

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

pandas/bin/activate

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/paul/anaconda/bin/activate

pandas/bin/conda

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/paul/anaconda/bin/conda

pandas/bin/deactivate

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/paul/anaconda/bin/deactivate

pandas/core/indexes/base.py

+6
Original file line numberDiff line numberDiff line change
@@ -2281,6 +2281,7 @@ def _union_incompatible_dtypes(self, other, sort):
22812281
-------
22822282
Index
22832283
"""
2284+
22842285
this = self.astype(object, copy=False)
22852286
# cast to Index for when `other` is list-like
22862287
other = Index(other).astype(object, copy=False)
@@ -2395,6 +2396,11 @@ def _union(self, other, sort):
23952396
Index
23962397
"""
23972398

2399+
if sort is None:
2400+
warnings.warn("sort='None' is deprecated, and will be "
2401+
"removed in a future version.",
2402+
FutureWarning, stacklevel=3)
2403+
23982404
if not len(other) or self.equals(other):
23992405
res = self._get_reconciled_name_object(other)
24002406
if sort:

pandas/tests/indexes/test_base.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ def test_chained_union(self, sort):
799799
j1 = Index([1, 2], name='j1')
800800
j2 = Index([], name='j2')
801801
j3 = Index([], name='j3')
802-
with tm.assert_produces_warning(warning):
802+
with tm.assert_produces_warning(warning, check_stacklevel=False):
803803
union = j1.union(j2.union(j3, sort=sort), sort=sort)
804804
expected = j1.union(j2, sort=sort).union(j3, sort=sort)
805805
tm.assert_index_equal(union, expected)
@@ -874,7 +874,7 @@ def test_union_from_iterables(self, klass, sort):
874874
case = klass(second.values)
875875

876876
warning = FutureWarning if sort is None else None
877-
with tm.assert_produces_warning(warning):
877+
with tm.assert_produces_warning(warning, check_stacklevel=False):
878878
result = first.union(case, sort=sort)
879879

880880
if sort is not False:
@@ -895,8 +895,7 @@ def test_union_identity(self, sort):
895895

896896
# This should no longer be the same object, since [] is not consistent,
897897
# both objects will be recast to dtype('O')
898-
union = first.union([], sort=sort)
899-
with tm.assert_produces_warning(warning):
898+
with tm.assert_produces_warning(warning, check_stacklevel=False):
900899
union = first.union([], sort=sort)
901900
assert (union is first) is (not sort)
902901

@@ -2259,7 +2258,7 @@ def test_union_different_type_base(self, klass):
22592258
first = index[3:]
22602259
second = index[:5]
22612260

2262-
with tm.assert_produces_warning(FutureWarning):
2261+
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
22632262
result = first.union(klass(second.values))
22642263

22652264
assert tm.equalContents(result, index)

0 commit comments

Comments
 (0)