Skip to content

Add __setitem__ slicing#387

Merged
kwmsmith merged 23 commits into
masterfrom
feature/setitem-slicing
Jun 16, 2014
Merged

Add __setitem__ slicing#387
kwmsmith merged 23 commits into
masterfrom
feature/setitem-slicing

Conversation

@bgrant
Copy link
Copy Markdown
Contributor

@bgrant bgrant commented May 27, 2014

Building on #384 and #385, this PR allows slice syntax in a DistArray's __setitem__.

The same restrictions apply: BlockMaps and NoDistMaps only and slice-steps of size 1 only.

@bgrant bgrant added this to the 0.4 milestone May 27, 2014
@bgrant bgrant changed the title __setitem__ slicing Add __setitem__ slicing May 27, 2014
…etitem-slicing

Conflicts:
	distarray/dist/tests/test_distarray.py
Comment thread distarray/dist/distarray.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume the value_slices[arr.comm_rank] is necessary because we can't scatter the slices to the targets?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about doing a for loop of self.apply() calls, each iteration sending the slice to its target?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that force us to wait on n serialized roundtrips though?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And apropos scattering: yes.

@kwmsmith
Copy link
Copy Markdown
Contributor

kwmsmith commented Jun 9, 2014

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)

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.49%) when pulling 2d75aa4 on feature/setitem-slicing into de18b91 on master.

kwmsmith added a commit that referenced this pull request Jun 16, 2014
@kwmsmith kwmsmith merged commit 4405136 into master Jun 16, 2014
@kwmsmith kwmsmith deleted the feature/setitem-slicing branch June 16, 2014 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants