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

Avoid matplotlib import overhead during 'import skimage' #6032

Merged
merged 1 commit into from
Nov 14, 2021

Conversation

grlee77
Copy link
Contributor

@grlee77 grlee77 commented Nov 12, 2021

Description

This PR removes the overhead of importing matplotlib when doing import skimage (see figure in #5995 (comment)). I think the issue was unintentionally introduced by #5990. The solution used here is to move has_mpl out of skimage/_shared/__init__.py so it does not get imported before it is needed.

The following shows that with this PR there is no matplotlib import anymore:
tuna_no_mpl_import

  • 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.

move has_mpl out of _shared.__init__ because setting its value requires
importing matplotlib
@grlee77 grlee77 added 🔧 type: Maintenance Refactoring and maintenance of internals 📈 type: Performance labels Nov 12, 2021
@grlee77 grlee77 added this to the 0.19 milestone Nov 12, 2021
@jni jni merged commit eb4e3a3 into scikit-image:main Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📈 type: Performance 🔧 type: Maintenance Refactoring and maintenance of internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants