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

Fix numpy slicing #271

Closed
ahartikainen opened this issue Sep 21, 2018 · 3 comments
Closed

Fix numpy slicing #271

ahartikainen opened this issue Sep 21, 2018 · 3 comments
Assignees

Comments

@ahartikainen
Copy link
Contributor

Change all ndarray slicings to tuple slicing. We need to hunt down all the cases. At least stats has some of them.

From

idx = np.array(...)
ary_sliced = ary[idx]

To

idx = np.array(...)
ary_sliced = ary[tuple(idx)]
@canyon289 canyon289 self-assigned this Sep 22, 2018
@canyon289
Copy link
Member

Is this only in regards to Ellipsis slicing? If so I can only find one example
https://github.com/arviz-devs/arviz/blob/master/arviz/stats/stats.py#L670

or is this in regards to any ndarray slicing at all?
Like here
https://github.com/arviz-devs/arviz/blob/master/arviz/stats/stats.py#L305

or here
https://github.com/arviz-devs/arviz/blob/master/arviz/stats/stats.py#L447

@canyon289
Copy link
Member

Copying @ahartikainen's helpful answer here

Multidimensional indexing with anything but a tuple is deprecated. This means that the index list in ind = [slice(None), 0]; arr[ind] should be changed to a tuple, e.g., ind = [slice(None), 0]; arr[tuple(ind)] or arr[(slice(None), 0)]. That change is necessary to avoid ambiguity in expressions such as arr[[[0, 1], [0, 1]]], currently interpreted as arr[array([0, 1]), array([0, 1])], that will be interpreted as arr[array([[0, 1], [0, 1]])] in the future.

https://docs.scipy.org/doc/numpy/release.html

@canyon289
Copy link
Member

Closed by #278

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

No branches or pull requests

2 participants