Add __setitem__ slicing#387
Merged
Merged
Conversation
to match NumPy.
like NumPy does.
…etitem-slicing Conflicts: distarray/dist/tests/test_distarray.py
Contributor
There was a problem hiding this comment.
I presume the value_slices[arr.comm_rank] is necessary because we can't scatter the slices to the targets?
Contributor
There was a problem hiding this comment.
What about doing a for loop of self.apply() calls, each iteration sending the slice to its target?
Contributor
Author
There was a problem hiding this comment.
Wouldn't that force us to wait on n serialized roundtrips though?
Contributor
Author
There was a problem hiding this comment.
And apropos scattering: yes.
Contributor
|
Some strange behavior: >>> c = Context()
>>> dist = Distribution.from_shape(c, (10, 20))
>>> da = c.ones(dist)
>>> db = da[:5, :10]
>>> db * 2
[2:apply]:
---------------------------------------------------------------------------
Traceback (most recent call last)<string> in <module>()
[...]
AttributeError: 'DummyMod' object has no attribute '__distarray__b4369fc35ada6cd50'
[3:apply]:
(same error)This looks like the operation is being called on targets where the sliced array doesn't exist. Also: >>> arr = db.tondarray()
>>> db[...] = arr * 2
>>> db.tondarray()
array([[ 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
[ 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
[ 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
[ 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.],
[ 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.]])That looks good, but: >>> db[...] = db * 2
[2:apply]:
[...]
AttributeError: 'DummyMod' object has no attribute '__distarray__b4369fc35ada6cd50'
[3:apply]:
(same error) |
Seems to pass for me though...
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Building on #384 and #385, this PR allows slice syntax in a
DistArray's__setitem__.The same restrictions apply:
BlockMaps andNoDistMaps only and slice-steps of size 1 only.