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 CI failures related to conversion of np.floating to dtype #4731

Merged
merged 3 commits into from
May 21, 2020

Conversation

rfezzani
Copy link
Member

Description

This PR prevent the conversion using np.floating as it is deprecated in numpy 1.19.

It fixes CI failures in #4730

Checklist

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    doc/release/release_dev.rst.

@sciunto
Copy link
Member

sciunto commented May 20, 2020

looks like it does not fully fix the CI :)

@lagru lagru added the 🔧 type: Maintenance Refactoring and maintenance of internals label May 20, 2020
@@ -244,6 +244,8 @@ def _convert(image, dtype, force_copy=False, uniform=False):
if force_copy:
image = image.copy()
return image
else:
dtype = np.float64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean dtypeobj_out? I think dtype is never used from this point onwards...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, it should be dtype_out ;)

@rfezzani rfezzani changed the title Prevent type convertion to np.floating [WIP] Prevent type convertion to np.floating May 20, 2020
@rfezzani rfezzani changed the title [WIP] Prevent type convertion to np.floating [DO NOT MERGE] Prevent type convertion to np.floating May 20, 2020
@rfezzani rfezzani changed the title [DO NOT MERGE] Prevent type convertion to np.floating Fix CI failures related to dtype convertion to np.floating May 20, 2020
@rfezzani
Copy link
Member Author

Ci failures are fixed by #4735

Copy link
Member

@jni jni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the correct fix. Instead, I think we should change img_as_float's call to _convert(img, np.floating) to _convert(img, np.float). Or np.float64, I'm not sure. np.float64 is the current behaviour, but np.float (ie 32-bit on 32-bit-default platforms, 64-bit on 64-bit-default platforms) is the intended behaviour, I believe.

@jni jni changed the title Fix CI failures related to dtype convertion to np.floating Fix CI failures related to conversion of np.floating to dtype May 21, 2020
@jni
Copy link
Member

jni commented May 21, 2020

To clarify my position: this PR currently takes NumPy's deprecated behaviour and hardcodes it into skimage. Instead, we should follow NumPy's guidance here. Users doing _convert(arr, np.floating) should get the warning (although for some reason I couldn't trigger it locally), users using img_as_float should get the fixed (future) behaviour.

Copy link
Member

@jni jni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore me! 😂 The np.issubdtype change becomes nearly impossible with my half-baked proposal. 😂

@jni
Copy link
Member

jni commented May 21, 2020

fwiw, I do think we should consider making img_as_float default to np.float rather than np.float64. But that can be resolved another day, this matches current behaviour.

@jni jni merged commit fd24648 into scikit-image:master May 21, 2020
jni pushed a commit that referenced this pull request May 21, 2020
numpy 1.19 deprecates (See NEP 34) automatic dtype for ragged input. This causes CI failures (please see #4731).
jni pushed a commit to jni/scikit-image that referenced this pull request May 22, 2020
numpy 1.19 deprecates (See NEP 34) automatic dtype for ragged input. This causes CI failures (please see scikit-image#4731).
jni pushed a commit to jni/scikit-image that referenced this pull request May 22, 2020
…-image#4731)

* Prevent type conversion to np.floating

* Fix conversion to np.floating
emmanuelle pushed a commit that referenced this pull request May 24, 2020
* Fix array ragged input numpy deprecation (#4735)

numpy 1.19 deprecates (See NEP 34) automatic dtype for ragged input. This causes CI failures (please see #4731).

* Fix CI failures related to conversion of np.floating to dtype (#4731)

* Prevent type conversion to np.floating

* Fix conversion to np.floating

Co-authored-by: Riadh Fezzani <rfezzani@gmail.com>
@dstansby
Copy link

Does anyone know which release number this is targeted for?

@sciunto
Copy link
Member

sciunto commented Jul 14, 2020

@scikit-image/core Do we plan to release a minor version to include this fix?

@jni
Copy link
Member

jni commented Jul 14, 2020

Looks like it was backported to the 0.17.x branch, so I think we could release 0.17.3 with this. @emmanuelle could you handle that? I'd be available today and/or Thursday to help if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 type: Maintenance Refactoring and maintenance of internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants