-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Accept int value in head, thin and tail #3298
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ad7560e
Accept int value in head, thin and tail
griverat 5d76cd6
Merge remote-tracking branch 'origin/master' into defvals-head-thin-tail
griverat 6ca0b42
Fix typing
griverat d9cbcda
Remove thin def val and add suggestions
griverat 4fec603
Fix typing and change raise message
griverat 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 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 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 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 |
---|---|---|
|
@@ -1012,7 +1012,11 @@ def test_head(self): | |
self.dv.isel({dim: slice(5) for dim in self.dv.dims}), self.dv.head() | ||
) | ||
with raises_regex(TypeError, "must be a dict or a single int"): | ||
self.dv.head(3.1) | ||
self.dv.head([3]) | ||
with raises_regex(TypeError, "must be an int"): | ||
self.dv.head(x=3.1) | ||
with raises_regex(ValueError, "must be positive"): | ||
self.dv.head(-3) | ||
|
||
def test_tail(self): | ||
assert_equal(self.dv.isel(x=slice(-5, None)), self.dv.tail(x=5)) | ||
|
@@ -1025,22 +1029,26 @@ def test_tail(self): | |
self.dv.isel({dim: slice(-5, None) for dim in self.dv.dims}), self.dv.tail() | ||
) | ||
with raises_regex(TypeError, "must be a dict or a single int"): | ||
self.dv.tail(3.1) | ||
self.dv.tail([3]) | ||
with raises_regex(TypeError, "must be an int"): | ||
self.dv.tail(x=3.1) | ||
with raises_regex(ValueError, "must be positive"): | ||
self.dv.tail(-3) | ||
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. Very thorough tests! Thank you! |
||
|
||
def test_thin(self): | ||
assert_equal(self.dv.isel(x=slice(None, None, 5)), self.dv.thin(x=5)) | ||
assert_equal( | ||
self.dv.isel({dim: slice(None, None, 6) for dim in self.dv.dims}), | ||
self.dv.thin(6), | ||
) | ||
assert_equal( | ||
self.dv.isel({dim: slice(None, None, 5) for dim in self.dv.dims}), | ||
self.dv.thin(), | ||
) | ||
with raises_regex(TypeError, "must be a dict or a single int"): | ||
self.dv.thin([3]) | ||
with raises_regex(TypeError, "must be an int"): | ||
self.dv.thin(x=3.1) | ||
with raises_regex(ValueError, "must be positive"): | ||
self.dv.thin(-3) | ||
with raises_regex(ValueError, "cannot be zero"): | ||
self.dv.thin(time=0) | ||
with raises_regex(TypeError, "must be a dict or a single int"): | ||
self.dv.thin(3.1) | ||
|
||
def test_loc(self): | ||
self.ds["x"] = ("x", np.array(list("abcdefghij"))) | ||
|
This file contains 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
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.
It is help to include a little more context in error messages if possible. In this case, you could include offending the name and value.
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.
Hmmm, Something along these lines maybe?
and
The
k
andv
come from iterating overindexers.items()