-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Added FrozenList subtraction #15506
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
Closed
Closed
Added FrozenList subtraction #15506
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ada7cda
Added FrozenList subtraction
benthayer f6381a8
Removed whitespace
benthayer cd73faa
Updated whatsnew to reflect changes
benthayer 2fad2f7
Added __isub__ and groupby example to docs
benthayer fdcfbbb
Added versionadded tag in docs and renamed test_inplace to test_inpla…
benthayer 2e43849
Changed __sub__ to difference
benthayer cb95089
Depricated __add__ in favor of union
benthayer 2ab85cb
Fixed issue number
benthayer 6a2b48d
Added docstrings, depricated __iadd__, changed __add__ to use self.un…
benthayer fee7a7d
Merge branch 'master' into frozen-index
73564ab
Added FrozenList subtraction
benthayer 0fc7e19
Removed whitespace
benthayer 79dd958
Updated whatsnew to reflect changes
benthayer 0ea8d21
Added __isub__ and groupby example to docs
benthayer cd7de26
Added versionadded tag in docs and renamed test_inplace to test_inpla…
benthayer ccd75c7
Changed __sub__ to difference
benthayer 3d6cee5
Depricated __add__ in favor of union
benthayer 66b3b91
Fixed issue number
benthayer 6f6c140
Added docstrings, depricated __iadd__, changed __add__ to use self.un…
benthayer 8dbde1e
Rebased to upstream/master
benthayer 84ba405
Merge branch 'master' of github.com:pandas-dev/pandas into frozen-index
benthayer 428a1b3
Added __iadd__ test, fixed whatsnew
benthayer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,11 @@ def __add__(self, other): | |
|
||
__iadd__ = __add__ | ||
|
||
def __sub__(self, other): | ||
other = set(other) | ||
temp = [x for x in self if x not in other] | ||
return self.__class__(temp) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add isub as well (and a test) |
||
|
||
# Python 2 compat | ||
def __getslice__(self, i, j): | ||
return self.__class__(super(FrozenList, self).__getslice__(i, j)) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,16 @@ def test_add(self): | |
expected = FrozenList([1, 2, 3] + self.lst) | ||
self.check_result(result, expected) | ||
|
||
def test_sub(self): | ||
result = self.container - [2] | ||
expected = FrozenList([1, 3, 4, 5]) | ||
self.check_result(result, expected) | ||
|
||
def test_sub_dupe(self): | ||
result = FrozenList([1, 2, 3, 2]) - [2] | ||
expected = FrozenList([1, 3]) | ||
self.check_result(result, expected) | ||
|
||
def test_inplace(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you rename this to make consistent |
||
q = r = self.container | ||
q += [5] | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this is called difference
i think might be nice to add an example to th docs as well