-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
profile_line's reduce_func parameter should be np.nanmean by default #5361
Comments
Hum, I will not call this a bug since NaN are IMHO exceptions, it must not rule the general case. |
Changed it from bug. |
|
Yeah, I agree with @grlee77 and @rfezzani: nanmean is slower and correct nan handling is very context-dependent, so we have in general preferred to leave this to users. Having said this, I can see how one might want to measure things near the edge of images and not include measurements from outside the image, in which case Perhaps a middle approach would be to include this example in the docstring? |
All makes sense, thanks for all the comments!
Brilliant, I shall do just that. |
Thank you @PinkShnack, any PR is welcome of course 😉. I close this issue, but feel free to reopen it if you wish. |
A late reply from me.... Does scikit image test the docstring examples by default with your current github actions/CI integration? If this has been corrected in the mean-time, then ignore the above. |
I would have thought so, but perhaps this got lost somewhere along the line with the move the GHA. Let me look into it.
Indeed, the results in the example appear to still correspond to |
@PinkShnack, thanks for raising the issue here about the broken examples. I opened #5502 about fixing this and running the doctests on CI. |
Description
When we implemented the
reduce_func
parameter forskimage.measure.profile_line
I didn't realise thatnp.mean
doesn't handlenan
very well.Scenario example 1:
By setting
mode="constant"
andcval=np.nan
,profile_line
will returnnan
when calculated bynp.mean
.This could be fixed by your deprecation of
mode="constant"
. Why is this being deprecated by the way?Scenario example 1:
I guess this could also be a problem when an array/image just has some
nans
in it.Proposal
Therefore, I propose changing the default
reduce_func=np.mean
parameter ofskimage.measure.profile_line
toreduce_func=np.nanmean
. I can create a PR if you all feel this is worthwhile.The text was updated successfully, but these errors were encountered: