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

Improve multi-Otsu error message and maintenance of threshold.py #6375

Merged
merged 8 commits into from May 24, 2022

Conversation

rfezzani
Copy link
Member

@rfezzani rfezzani commented May 6, 2022

Description

Fixes #6324 and implements some code maintenance:

  • ravel -> reshape(-1),
  • copy=False in astype
  • use single precision when possible (float -> float32)
  • call np.flatnonzero(arr) instead of np.where(arr >0)[0]

Checklist

  • Docstrings for all functions
  • Gallery example in ./doc/examples (new features only)
  • Benchmark in ./benchmarks, if your changes aren't covered by an
    existing benchmark
  • Unit tests
  • Clean style in the spirit of PEP8
  • Descriptive commit messages (see below)

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.
  • There is a bot to help automate backporting a PR to an older branch. For
    example, to backport to v0.19.x after merging, add the following in a PR
    comment: @meeseeksdev backport to v0.19.x
  • To run benchmarks on a PR, add the run-benchmark label. To rerun, the label
    can be removed and then added again. The benchmark output can be checked in
    the "Actions" tab.

@rfezzani rfezzani added 🔧 type: Maintenance Refactoring and maintenance of internals 🩹 type: Bug fix Fixes unexpected or incorrect behavior labels May 6, 2022
Copy link
Member

@alexdesiqueira alexdesiqueira left a comment

Choose a reason for hiding this comment

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

Thank you @rfezzani! Just left a note on the number of bins (returning nbins), but please feel free to ignore it.

skimage/filters/thresholding.py Outdated Show resolved Hide resolved
Co-authored-by: Alexandre de Siqueira <alex.desiqueira@igdore.org>
@pep8speaks
Copy link

pep8speaks commented May 8, 2022

Hello @rfezzani! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-05-08 21:05:51 UTC

@alexdesiqueira alexdesiqueira changed the title Improve multi_otsu error messgae and maintance of threshold.py Improve multi-Otsu error message and maintenance of threshold.py May 9, 2022
@lagru lagru merged commit 306231a into scikit-image:main May 24, 2022
@lagru
Copy link
Member

lagru commented May 24, 2022

Thank you @rfezzani and @alexdesiqueira!

@rfezzani
Copy link
Member Author

🎉 Thank you @lagru and @alexdesiqueira for your reviews 😉

alexdesiqueira pushed a commit to alexdesiqueira/scikit-image that referenced this pull request May 24, 2022
…kit-image#6375)

* Avoid a copy when converting histogram to float32

* Replace ravel calls by reshape(-1)

* Avoid copy if not necessary when calling astype

* Avoid temporary arrays creation

* Improve threshold_multiotsu error message

* Use single precision instead of double precision

* Update skimage/filters/thresholding.py

Co-authored-by: Alexandre de Siqueira <alex.desiqueira@igdore.org>

* Fix pep8

Co-authored-by: Riadh <r.fezzani@vitadx.com>
Co-authored-by: Alexandre de Siqueira <alex.desiqueira@igdore.org>
@jarrodmillman jarrodmillman added this to the 0.20 milestone Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🩹 type: Bug fix Fixes unexpected or incorrect behavior 🔧 type: Maintenance Refactoring and maintenance of internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

threshold_multiotsu fails for array with 0
5 participants