-
Notifications
You must be signed in to change notification settings - Fork 129
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
Fix indexing behavior in NumpyTupleDataset #200
Conversation
Codecov Report
@@ Coverage Diff @@
## master #200 +/- ##
==========================================
+ Coverage 77.08% 77.79% +0.71%
==========================================
Files 89 91 +2
Lines 3875 4067 +192
==========================================
+ Hits 2987 3164 +177
- Misses 888 903 +15 |
@@ -35,7 +35,8 @@ def __init__(self, *datasets): | |||
|
|||
def __getitem__(self, index): | |||
batches = [dataset[index] for dataset in self._datasets] | |||
if isinstance(index, slice): | |||
if isinstance(index, slice) or isinstance(index, list) or\ |
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.
you may write
if isinstance(index, (slice, list, numpy.ndarray)):
@@ -47,6 +55,38 @@ def test_get_item_slice_index(self, data, index): | |||
for a, e in six.moves.zip(tuple_a, tuple_e): | |||
numpy.testing.assert_array_equal(a, e) | |||
|
|||
@pytest.mark.parametrize('index', [numpy.asarray([2, 0])]) |
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.
Can you add array with length 1?
for a, e in six.moves.zip(tuple_a, tuple_e): | ||
numpy.testing.assert_array_equal(a, e) | ||
|
||
@pytest.mark.parametrize('index', [[2, 0]]) |
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.
Can you add list with length 1?
Fix. |
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.
LGTM
This PR contains non compatibility change.