8000 Reintroduced convert with a strong deprecation warning by hmaarrfk · Pull Request #4681 · scikit-image/scikit-image · GitHub
[go: up one dir, main page]

Skip to content

Reintroduced convert with a strong deprecation warning #4681

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

Merged
merged 3 commits into from
May 12, 2020

Conversation

hmaarrfk
Copy link
Member

Description

This PR reintroduces convert with a strong warning to not use it.

I know we are working toward 1.0, but this broke my code.

I guess most people use the public API, but I was not keep on making my own if/elif statement:

Closes #4680

@sciunto @emmanuelle

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.

@alexdesiqueira
Copy link
Member

Just out of curiosity, what code did break because of (the lack of) this, @hmaarrfk?

@hmaarrfk
Copy link
Member Author

i let the convert function do all the logic switching for me.

I guess most people do

if dytpe == float32:
    img_as_float32
elif dtype == float64:
    img_as_float64

Seems a little silly seeing as they all just call convert anyway. So i just call convert like asdtype

@sciunto
Copy link
Member
sciunto commented May 12, 2020

I think I'm -1 on this. You were not supposed to use this function, it was not in the API. The alternative, is to do what I originally did in my PR: put it in the API.

@hmaarrfk
Copy link
Member Author

FWIW,after this PR it is in the API albeit with a strong warning.

@jni
Copy link
Member
jni commented May 12, 2020

@hmaarrfk I really don't understand the logic here. If we are planning to destroy the function, and you acknowledge as much in the warning, your client code will need to adapt anyway. You might as well just use the private function, with a try/except for importing _convert. Then at least people reading your code will know that you are playing with fire. 😬

Having said this, I don't have very strong opposition to this. But I prefer going back to the old state of semi-private rather than making it fully public. We should aim to reduce the 1.0 disruption, not throw in the towel and decide that APIs don't matter anymore since we are planning to break them all soon.

@hmaarrfk
Copy link
Member Author

These concerns are all fair. And through searching on github, it seems that i am probably the only one using this function.

I understand that in 1.0, we can remove this function.

That said, today, this is a super useful function. I routinely have

arr = np.zeros(...., dtype='my_type')

and in my loading functions

arr = load_my_image(...., dtype='my_type')

where inside load_my_image, we use skimage.util.dtype.convert to really avoid the slew of if statements.

At this stage, I could go either way.

I don't think we should spend much more reviewer cognitive task, I won't take offense if somebody simply decides to close this PR.

@emmanuelle
Copy link
Member

I feel like the current state of the PR is an acceptable trade-off, ie

  • the function is still not public
  • convert is back but calls _convert and issues a big warning.
    So I'm approving and merging because we should not spend too much time on this.

@emmanuelle emmanuelle merged commit 4a68e75 into scikit-image:master May 12, 2020
@emmanuelle
Copy link
Member

@meeseeksdev backport to v0.17.x

@hmaarrfk
Copy link
Member Author

thx.

emmanuelle pushed a commit that referenced this pull request May 12, 2020
…ning (#4693)

Co-authored-by: Mark Harfouche <mark.harfouche@gmail.com>
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.

Reintroduce dtype.convert
5 participants
0