Skip to content

ndimage: support all interpolation boundary modes - #4400

Merged
mergify[bot] merged 7 commits into
cupy:masterfrom
grlee77:ndimage_boundary_modes
Dec 21, 2020
Merged

mergify[bot] merged 7 commits into
cupy:masterfrom
grlee77:ndimage_boundary_modes

Conversation

@grlee77

@grlee77 grlee77 commented Dec 3, 2020

Copy link
Copy Markdown
Member

Overview

This PR adds support for additional boundary modes in all interpolation functions. It is based on the most recent bug fixes and enhancements in this area for SciPy 1.6.0 (~12 issues in SciPy were closed: see meta-issue scipy/scipy#12773).

The changes in this PR correspond to those from scipy/scipy#12767 and scipy/scipy#12776 and include:

  • enables the previously disabled 'reflect' and 'wrap' modes ('reflect' behavior was fixed in SciPy 1.6. 'wrap' remains as before, but a new 'grid-wrap' mode is probably what most users will want)
  • new modes: 'grid-wrap' and 'grid-constant' (also 'grid-mirror' as a synonym for 'reflect')

The easiest way to understand the various modes is probably via the new figures introduced to SciPy's ndimage tutorial. The main doc site doesn't show these yet, but here is documentation artifact link from one of the CI runs:
https://22174-1460385-gh.circle-artifacts.com/0/html-scipyorg/tutorial/ndimage.html#interpolation-boundary-handling

There is also a text-based explanation in the SciPy mode docstrings for each individual function. I have not reproduced that here, but can if desired. CuPy users should also be to reach those via our cross-linking to SciPy in the seealso sections of our docstrings.
https://22174-1460385-gh.circle-artifacts.com/0/html-scipyorg/generated/scipy.ndimage.affine_transform.html#scipy-ndimage-affine-transform

image from the tutorial reproduced here (Ignore order > 1 for now. Orders 2-5 will be added in a follow-up PR):
plot_boundary_modes

Additional Details

Many of the new tests require SciPy >=1.6.0 which should have a release candidate any day now. I have tested locally vs. SciPy master.

The kernel generation code would be somewhat simplified if we dropped support for the legacy 'wrap' mode and only support the newer 'grid-wrap' mode which is probably what most users would want (see figure above).

@grlee77 grlee77 changed the title Support all boundary modes in cupyx.scipy.ndimage.interpolation ndimage: support all interpolation boundary modes Dec 4, 2020
@kmaehashi kmaehashi added cat:enhancement Improvements to existing features prio:medium labels Dec 4, 2020
The changes here are consistent with a large number of fixes introduced for SciPy 1.6
Specifically this PR includes order=1 and order=0 fixes from
SciPy's gh-12767 and gh-12776
STYLE: f-strings in _spline_prefilter_core.py

pep 8 fixes
All ndimage test cases now verified to pass when using SciPy 1.6.0 pre-release code
@grlee77
grlee77 force-pushed the ndimage_boundary_modes branch from 83da19e to eb3e8e2 Compare December 10, 2020 03:12
@takagi

takagi commented Dec 10, 2020

Copy link
Copy Markdown
Contributor

pfnCI, test this please.

@takagi

takagi commented Dec 10, 2020

Copy link
Copy Markdown
Contributor

Thanks for the PR! I think of merging this with cupy.experimental mark as the upstream SciPy 1.6 is not released yet.

https://github.com/cupy/cupy/wiki/Development-policies#numpyscipy-compatibility

BTW, do you have information about when SciPy 1.6 is released?

@chainer-ci

Copy link
Copy Markdown
Member

Jenkins CI test (for commit 23cdb6b, target branch master) succeeded!

@grlee77

grlee77 commented Dec 10, 2020 •

Copy link
Copy Markdown
Member Author

BTW, do you have information about when SciPy 1.6 is released?

A release candidate should be out any day now. I would guess early Jan for the final release, but don't have a specific date. The original plan was to release in December, but things have gone a bit slower than anticipated, partly due to having to move a lot of CI off of Travis after their billing policy changes.

@takagi

takagi commented Dec 14, 2020

Copy link
Copy Markdown
Contributor

Okay, thanks for the information! CuPy v9 is planned to release on next April, so SciPy 1.6 is likely released before that.

@takagi

takagi commented Dec 14, 2020

Copy link
Copy Markdown
Contributor

Would you mark the functions with cupy._util.experimental when the new modes are passed until SciPy 1.6 is released? I suppose in _check_parameter and spline_filter1d would be fine as each function goes them through.

@takagi takagi added this to the v9.0.0b1 milestone Dec 14, 2020
@takagi

takagi commented Dec 14, 2020

Copy link
Copy Markdown
Contributor

LGTM except for that!

@takagi takagi added the st:awaiting-author Awaiting response from author label Dec 17, 2020
@takagi

takagi commented Dec 21, 2020

Copy link
Copy Markdown
Contributor

Thanks! Let me fix the arguments of the marks a bit to make them properly output messages.

@takagi

takagi commented Dec 21, 2020

Copy link
Copy Markdown
Contributor

pfnCI, test this please.

@takagi takagi added st:test-and-merge (deprecated) Ready to merge after test pass. and removed st:awaiting-author Awaiting response from author labels Dec 21, 2020
@takagi

takagi commented Dec 21, 2020

Copy link
Copy Markdown
Contributor

Waiting for CI pass.

@chainer-ci

Copy link
Copy Markdown
Member

Jenkins CI test (for commit 94df47b, target branch master) succeeded!

@mergify
mergify Bot merged commit 66ad5b3 into cupy:master Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat:enhancement Improvements to existing features prio:medium st:test-and-merge (deprecated) Ready to merge after test pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants