Skip to content

Commit 4eadc73

Browse files
committed
Move warning into _union method
1 parent baef416 commit 4eadc73

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

Diff for: pandas/bin/activate

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

Diff for: pandas/bin/conda

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

Diff for: pandas/bin/deactivate

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

Diff for: pandas/core/indexes/base.py

+6
Original file line numberDiff line numberDiff line change
@@ -2301,6 +2301,7 @@ def _union_incompatible_dtypes(self, other, sort):
23012301
-------
23022302
Index
23032303
"""
2304+
23042305
this = self.astype(object, copy=False)
23052306
# cast to Index for when `other` is list-like
23062307
other = Index(other).astype(object, copy=False)
@@ -2415,6 +2416,11 @@ def _union(self, other, sort):
24152416
Index
24162417
"""
24172418

2419+
if sort is None:
2420+
warnings.warn("sort='None' is deprecated, and will be "
2421+
"removed in a future version.",
2422+
FutureWarning, stacklevel=3)
2423+
24182424
if not len(other) or self.equals(other):
24192425
res = self._get_reconciled_name_object(other)
24202426
if sort:

Diff for: 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

@@ -2263,7 +2262,7 @@ def test_union_different_type_base(self, klass):
22632262
first = index[3:]
22642263
second = index[:5]
22652264

2266-
with tm.assert_produces_warning(FutureWarning):
2265+
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
22672266
result = first.union(klass(second.values))
22682267

22692268
assert tm.equalContents(result, index)

0 commit comments

Comments
 (0)