-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
numpy deprecation: Should regular_grid return a tuple? #3235
Copy link
Copy link
Closed
Labels
🔧 type: MaintenanceRefactoring and maintenance of internalsRefactoring and maintenance of internals
Milestone
Description
scikit-image/skimage/util/_regular_grid.py
Lines 21 to 25 in f21c52b
| Returns | |
| ------- | |
| slices : list of slice objects | |
| A slice along each dimension of `ar_shape`, such that the intersection | |
| of all the slices give the coordinates of regularly spaced points. |
Numpy decided to deprecacte multi-indexing with anything other than a tuple.
regular grid currently returns a list. It might be useful to keep up with numpy's API, and as such, we should return a tuple.
For example, just below in _regular_grid.py
scikit-image/skimage/util/_regular_grid.py
Lines 101 to 104 in f21c52b
| grid = regular_grid(ar_shape, n_points) | |
| seed_img = np.zeros(ar_shape, dtype=dtype) | |
| seed_img[grid] = 1 + np.reshape(np.arange(seed_img[grid].size), | |
| seed_img[grid].shape) |
uses the output directly to index a numpy array.
Unfortunately, lists are not tuples, and this would cause a breaking change in the (internal) API.
How should we proceed with this?
Ideas I have:
- Check the numpy version, if greater than
1.15then we can return a tuple. - Return a list until numpy decides to change their implementation
- Return a tuple instead of a list.
I kinda like 3, but doesn't seem prudent.
Edit: it seems that this is actually an external facing API.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
🔧 type: MaintenanceRefactoring and maintenance of internalsRefactoring and maintenance of internals