-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
API/DEPR: Remove +/- as setops for Index (GH8227) #14127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1739,28 +1739,16 @@ def argsort(self, *args, **kwargs): | |
| return result.argsort(*args, **kwargs) | ||
|
|
||
| def __add__(self, other): | ||
| if is_list_like(other): | ||
| warnings.warn("using '+' to provide set union with Indexes is " | ||
| "deprecated, use '|' or .union()", FutureWarning, | ||
| stacklevel=2) | ||
| if isinstance(other, Index): | ||
| return self.union(other) | ||
| return Index(np.array(self) + other) | ||
|
|
||
| def __radd__(self, other): | ||
| if is_list_like(other): | ||
| warnings.warn("using '+' to provide set union with Indexes is " | ||
| "deprecated, use '|' or .union()", FutureWarning, | ||
| stacklevel=2) | ||
| return Index(other + np.array(self)) | ||
|
|
||
|
||
| __iadd__ = __add__ | ||
|
|
||
| def __sub__(self, other): | ||
| warnings.warn("using '-' to provide set differences with Indexes is " | ||
| "deprecated, use .difference()", FutureWarning, | ||
| stacklevel=2) | ||
| return self.difference(other) | ||
| raise TypeError("cannot perform __sub__ with this index type: " | ||
| "{typ}".format(typ=type(self))) | ||
|
|
||
| def __and__(self, other): | ||
| return self.intersection(other) | ||
|
|
@@ -1990,7 +1978,8 @@ def symmetric_difference(self, other, result_name=None): | |
| ----- | ||
| ``symmetric_difference`` contains elements that appear in either | ||
| ``idx1`` or ``idx2`` but not both. Equivalent to the Index created by | ||
| ``(idx1 - idx2) + (idx2 - idx1)`` with duplicates dropped. | ||
| ``idx1.difference(idx2) | idx2.difference(idx1)`` with duplicates | ||
| dropped. | ||
|
|
||
| Examples | ||
| -------- | ||
|
|
@@ -3333,8 +3322,8 @@ def _evaluate_compare(self, other): | |
| cls.__ge__ = _make_compare(operator.ge) | ||
|
|
||
| @classmethod | ||
| def _add_numericlike_set_methods_disabled(cls): | ||
| """ add in the numeric set-like methods to disable """ | ||
| def _add_numeric_methods_add_sub_disabled(cls): | ||
| """ add in the numeric add/sub methods to disable """ | ||
|
|
||
| def _make_invalid_op(name): | ||
| def invalid_op(self, other=None): | ||
|
|
@@ -3349,7 +3338,7 @@ def invalid_op(self, other=None): | |
|
|
||
| @classmethod | ||
| def _add_numeric_methods_disabled(cls): | ||
| """ add in numeric methods to disable """ | ||
| """ add in numeric methods to disable other than add/sub """ | ||
|
|
||
| def _make_invalid_op(name): | ||
| def invalid_op(self, other=None): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this clear that this ONLY applies to
Indexitself and not-subclasses (maybe show that numeric/datetimelike ops are unchanged)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, will try to clarify