numpy: Handle multidimentional indexing in 1.15#3238
numpy: Handle multidimentional indexing in 1.15#3238soupault merged 4 commits intoscikit-image:masterfrom
Conversation
|
Hello @hmaarrfk! Thanks for updating the PR.
Comment last updated on July 22, 2018 at 03:24 Hours UTC |
|
Maybe a better way to handle scipy's use of the matrix subclass for sparse matricies is to use https://github.com/pydata/sparse internally. |
soupault
left a comment
There was a problem hiding this comment.
Thanks for the PR! I think many of the changes could be simplified to lower the visual complexity of the code. Also, the warnings conditional on package versions should be considered for further refactoring.
skimage/restoration/_cycle_spin.py
Outdated
| futures = [dask.delayed(_run_one_shift)(s) for s in all_shifts] | ||
| mean = sum(futures) / len(futures) | ||
| mean = mean.compute(get=dask.threaded.get, num_workers=num_workers) | ||
| mean = mean.compute(scheduler='threading', num_workers=num_workers) |
There was a problem hiding this comment.
Ok. That was easy to remove using rebasing :D
skimage/segmentation/boundaries.py
Outdated
| label_img_expanded = np.zeros([(2 * s - 1) for s in label_img.shape], | ||
| label_img.dtype) | ||
| pixels = [slice(None, None, 2)] * ndim | ||
| pixels = tuple([slice(None, None, 2)] * ndim) |
There was a problem hiding this comment.
This is just pixels = (slice(None, None, 2), ) * ndim
skimage/util/_regular_grid.py
Outdated
| space_size = float(np.prod(ar_shape)) | ||
| if space_size <= n_points: | ||
| return [slice(None)] * ndim | ||
| return tuple([slice(None)] * ndim) |
skimage/util/_regular_grid.py
Outdated
| slices = [slice(start, None, step) for | ||
| start, step in zip(starts, stepsizes)] | ||
| slices = [slices[i] for i in unsort_dim_idxs] | ||
| slices = tuple([slices[i] for i in unsort_dim_idxs]) |
There was a problem hiding this comment.
Why not tuple(slices[i] for i in unsort_dim_idxs)?
There was a problem hiding this comment.
You know, I thought you needed the square brackets to make it a list comprehension. I guess you don't :D
There was a problem hiding this comment.
@hmaarrfk I have a PEP for you :) - https://www.python.org/dev/peps/pep-0289/
There was a problem hiding this comment.
nice one! Yeah, I still don't know generator expressions.
skimage/util/arraycrop.py
Outdated
| ar = np.array(ar, copy=False) | ||
| crops = _validate_lengths(ar, crop_width) | ||
| slices = [slice(a, ar.shape[i] - b) for i, (a, b) in enumerate(crops)] | ||
| slices = tuple([slice(a, ar.shape[i] - b) |
skimage/util/shape.py
Outdated
| arr_in = np.ascontiguousarray(arr_in) | ||
|
|
||
| slices = [slice(None, None, st) for st in step] | ||
| slices = tuple([slice(None, None, st) for st in step]) |
skimage/_shared/_warnings.py
Outdated
| Finally, you can use `|\A\Z` in a pattern to signify it as optional. | ||
|
|
||
| """ | ||
| if isinstance(matching, str): |
skimage/filters/lpi_filter.py
Outdated
| """ | ||
| start = (np.array(x.shape) - np.array(oshape)) // 2 + 1 | ||
| out = x[[slice(s, s + n) for s, n in zip(start, oshape)]] | ||
| out = x[tuple([slice(s, s + n) for s, n in zip(start, oshape)])] |
| from skimage._shared._warnings import expected_warnings | ||
|
|
||
|
|
||
| if Version(np.__version__) >= '1.15' and Version(scipy.__version__) <= '1.1.0': |
There was a problem hiding this comment.
Are there any plans on removing this check in future? If yes, please, add a note to TODO file
|
|
||
| # SNR is improved less with 1 wavelet level than with the default. | ||
| denoised_1 = restoration.denoise_wavelet(noisy, | ||
| with expected_warnings([None]): |
There was a problem hiding this comment.
What is the benefit of using None?
There was a problem hiding this comment.
The benefit of using none is that under certain build conditions, where we don't expect warnings, None can be passed in.
|
@soupault plans for deprecacting the logic behind the conditional warnings: Well, the plan for removing it is so long term that I didn't know if it makes sense. I'll add some words about it. I assume that scipy (and pywavelets) will eventually fix these warnings on their side too. at which point, some version of scipy, higher than 1.1.6, will eventually not have these warnings by default. But until then, this is just a very explicit way ensuring warning are |
Codecov Report
@@ Coverage Diff @@
## master #3238 +/- ##
=======================================
Coverage 81.98% 81.98%
=======================================
Files 339 339
Lines 27313 27313
=======================================
Hits 22392 22392
Misses 4921 4921
Continue to review full report at Codecov.
|
|
Finally, I was testing out avoiding the use of Even without instructions, somebody 10 years from now would be able to go through the code, find that a certain combinations of packages can't exist in their supported versions, and rip out the logic if they want to. That said, I don't know when pywavelets and scipy will address their warnings, maybe it is for us to send in the PR, and the tests might fail once or twice until they get around to fixing their codebase. We would require version bumps on the logic at that point. The matrix subclass warning should definitely be broadened, as that would require a major change on scipy's end. |
|
I just updated the scipy dependency to not depend on the minor version number for the sparse matrix warning. |
soupault
left a comment
There was a problem hiding this comment.
Couple of remarks are still pending, but they aren't blocking :). Otherwise, lgtm.
7b65ff0 to
91a641d
Compare
|
Before anyone merges, I suggested in #3235 (comment) that changing the return type of |
For all except `_regular_grid.py`.
|
@jni I finally got around to removing the keyword argument and added your suggested |
…a tuple add notes in changelog
jni
left a comment
There was a problem hiding this comment.
@hmaarrfk I've tweaked it a little but otherwise LVGTM. ;) Can someone more familiar with Sphinx check my formatting? CC @stefanv
(For some reason I can't build the docs on my machine; make html inside the doc directory gives me the following error:
~/projects/scikit-image/doc (numpy_1_15)
$ make
python tools/build_modref_templates.py
/home/jni/projects/scikit-image/skimage/novice/__init__.py:103: UserWarning: The `skimage.novice` module was deprecated in version 0.14. It will be removed in 0.16.
warnings.warn("The `skimage.novice` module was deprecated in version 0.14. "
WARNING: Empty - skimage.scripts
outdir:
27 files written
Build API docs...done.
Copying release notes
python -b html -d build/doctrees -j 1 source build/html
python: can't open file 'html': [Errno 2] No such file or directory
Makefile:53: recipe for target 'html' failed
make: *** [html] Error 2
)
|
@jni I tried: I got pretty far in the building process, but still no cigar. Something about a db mismatch. |
|
@jni Looks good to me: |
|
Thanks a lot @hmaarrfk ! |
|
@meeseeksdev backport to v0.14.x |
|
There seem to be a conflict, please backport manually |
Handle multidimentional indexing in numpy 1.15
Handle multidimentional indexing in numpy 1.15
Handle multidimentional indexing in numpy 1.15
|
Apparently, I have 0 knowledge on the manual backporting of merge commits... Could someone try to handle this, please? |
@jni Try to update |
That's the kind of issue you can raise on MrMeeseeks repo. The "there seem to be a conflict" comments should now have instruction on which git commands to issue to backport a merge commit |
|
@Carreau Very nice addition, thanks! |
|
I just learned where MrMeeseeks is from.... |
Time for some Netflix binge-watching. =D |

Goes in an catches the warnings from dependencies that don't follow numpy 1.15PR pytest: Numpy 1 15 warnings #3242.Locks the expected warnings to a specific version.pytest: Numpy 1 15 warnings #3242A few other small fixes wherepytest: Numpy 1 15 warnings #3242expected_warningswas passed as string as opposed to a list.regular_gridreturn a tuple? #3235 is handled as a single commit so that it can be rebased if we don't like it.Future me notes: use
to pull it out and edit it to whatever the final solution is chosen to be.
Checklist
[It's fine to submit PRs which are a work in progress! But before they are merged, all PRs should provide:]
./doc/examples(new features only)./benchmarks, if your changes aren't covered by anexisting benchmark
[For detailed information on these and other aspects see scikit-image contribution guidelines]
References
[If this is a bug-fix or enhancement, it closes issue # ]
[If this is a new feature, it implements the following paper: ]
For reviewers
(Don't remove the checklist below.)
later.
__init__.py.doc/release/release_dev.rst.@meeseeksdev backport to v0.14.x