Skip to content
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

Consolidate numpy and dask vindex handling #3

Merged

Conversation

shoyer
Copy link

@shoyer shoyer commented Aug 6, 2017

No description provided.

Copy link
Owner

@fujiisoup fujiisoup left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I have some comments here

return mixed_positions, vindex_positions


class VectorizedIndex(object):
Copy link
Owner

Choose a reason for hiding this comment

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

As it is an array-wrapper, I think the name should be something like NumpyVectorizedIndexingAdapter, like NumpyIndexingAdapter or DaskIndexingAdapter.

Copy link
Author

Choose a reason for hiding this comment

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

Agreed, changed.

# result. This is significantly faster/more efficient for
# most array backends.
values = np.arange(*value.indices(self.sizes[dim]))
variables.insert(i, Variable((dim,), values))
Copy link
Owner

Choose a reason for hiding this comment

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

I am wondering if this line is correct.

v = Variable(['w', 'x', 'y', 'z'], [[[[1, 2, 3], [4, 5, 6]]]])
ind = Variable(['y'], [0])
v_new = v[ind, :, 1:2, 2]

raises
'IndexError: index 2 is out of bounds for axis 2 with size 2'

Copy link
Author

Choose a reason for hiding this comment

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

Good catch! Fixed (I think)

@fujiisoup fujiisoup merged commit 72587de into fujiisoup:indexing_broadcasting Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants