Add __getitem__ slicing#384
Conversation
and NoDistMap.
Slicing is kind of working!
…add-slicing Conflicts: distarray/dist/distarray.py
Slices shouldn't be bounds checked.
in DistArray.from_localarrays.
and reuse it on the client side. Also factor out a _process_return_value function.
This method allows making a new client-side Distribution object from a Distribution and slice.
|
This is great -- will review soon. I recommend we merge the reduction stuff first, and get the 0-dimensional and n-dimensional with shape entry of 0 working before merging this. I think slicing the other distribution types is possible with certain constraints in place -- we should discuss. Those should come in future PRs, of course. Other features for future PRs:
|
|
Also for a future PR:
|
There was a problem hiding this comment.
To allow us to implement this on other map subclasses in the future, can we put a slice() method on the map subclasses, and have Distribution.slice() call its map slices in a polymorphic way?
Conflicts: distarray/dist/maps.py distarray/dist/tests/test_maps.py distarray/local/localarray.py distarray/metadata_utils.py
Polymorphism!
|
The merges from master make this hard to review. Could you rebase in the future? |
|
@cowlicks: I'm not really sold on history rewriting, but I could be convinced. What about the merge commits make this hard to review? |
|
What is wrong with rewriting history locally? No one has a copy of your local branch, so you could rebase before you push. So you wouldn't need to add a merge at the end of the PR. I agree that we should not rewrite the history of any branch on DistArray's public repo. I think personal dev forks are usually okay to rewrite, unless another dev has expressed interest in working off one of your forks. Generally I review a PR by looking at the list of commit messages. Then trying to understand how they are accomplishing the goal of the PR. From there, I read each commit consecutively. And make sure it does what the commit message says. And that it does nothing weird or buggy. However this does not work if you carefully craft all your commit then throw a merge in at the end. Since the merge changes a bunch of stuff potentially related to your PR. A bunch of my comments are probably obsolete, and everything after the commit it should probably be re-reviewed. I realize there is the other reviewing strategy of click on "files changed" and read everything. This is generally what I have to do when I realize a bunch of commits overlap. However this basically leaves you reviewing a giant diff with no commit messages. Which is frustrating because you have no idea what the changes are intended to do except for what is in the PR message. |
Conflicts: distarray/dist/maps.py distarray/dist/tests/test_distarray.py distarray/dist/tests/test_maps.py distarray/local/localarray.py distarray/local/maps.py
|
@bgrant -- what about creating a Also, same question for the local side -- what about adding a |
There was a problem hiding this comment.
It seems like this error case should be dealt with immediately after the santitize_indices() call -- reason for handling it here?
Conflicts: distarray/dist/distarray.py distarray/dist/maps.py distarray/dist/tests/test_maps.py
How's this, @kwmsmith?
into _index and _slice.
|
Okay @kwmsmith : comments addressed. |
Add support for slicing (including incomplete indexing) through a
DistArray's__getitem__. Currently onlyBlockMaps andNoDistMaps are supported, and only slices with step-sizes of 1 are supported.Slices return
DistArrayviews as one would expect.This required a small bit of refactoring
NoDistMaps fromBlockMaps for conveniencesanitize_indicesand expanded its functionality and usage.Slicing currently throws errors when a resulting slice would have a dimension of size 0, but maybe Kurt's upcoming changes will resolve this.