Skip to content

Conversation

BuWeiSU
Copy link

@BuWeiSU BuWeiSU commented May 22, 2023

I found the code in appa.ipynb don't have function demean_axis in Appendices A, so I added it.
When I used numpy==1.23.0 to run demean_axis, an IndexError is raised.

[<ipython-input-1-037e683df74f>](https://localhost:8080/#) in demean_axis(arr, axis)
      6     indexer = [slice(None)] * arr.ndim
      7     indexer[axis] = np.newaxis
----> 8     return arr - means[indexer]

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

When using numpy==1.22.4 or lower, the code can run successfully but a future warning will be displayed.

FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result.

To fix this error, I added tuple in the last line of demean_axis. By using tuple as index, this error is fixed and the new version is compatible with older numpy versions.

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.

1 participant