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

Remove matplotlib as a core dependency. #3129

Conversation

hmaarrfk
Copy link
Member

@hmaarrfk hmaarrfk commented May 31, 2018

Issue #2710

Move matplotlib to optional dependency.
Skip tests that can't run without matplotlib

Few questions:

  • geometry.polygon_clip requires matplotlib path, transforms. :
    - Look into updating the celiagg conda recipe so it isn't pinned to numpy 1.12. Ultimately, we decided against this since it seemed like we were just removing matplotliib and replacing it with a different dependency.
    - See this PR Update to version 1.0.3 conda-forge/celiagg-feedstock#4 on celiagg's feedstock
    - A python implemented of the required algorithm was written to replace the matplotlib exposed algorithm.

Note: This was rebased onto: #3432

Checklist

[It's fine to submit PRs which are a work in progress! But before they are merged, all PRs should provide:]

[For detailed information on these and other aspects see scikit-image contribution guidelines]

References

[If this is a bug-fix or enhancement, it closes issue # ]
[If this is a new feature, it implements the following paper: ]

For reviewers

(Don't remove the checklist below.)

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

@pep8speaks
Copy link

pep8speaks commented May 31, 2018

Hello @hmaarrfk! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on February 28, 2019 at 04:14 Hours UTC

@hmaarrfk hmaarrfk changed the title Lazy import a few matplotlib dependencies. Remove matplotlib as a core dependency. May 31, 2018
@soupault soupault added the 🔧 type: Maintenance Refactoring and maintenance of internals label May 31, 2018
@soupault soupault added this to the 0.15 milestone May 31, 2018
@codecov-io

This comment has been minimized.

@hmaarrfk hmaarrfk force-pushed the feature_remove_matplotlib_dependency branch from 1b4c9e0 to cec0783 Compare May 31, 2018 22:55
hmaarrfk added a commit to hmaarrfk/scikit-image that referenced this pull request Jun 3, 2018
Undo some of the merge errors that were introduced in a previous rebase.
@hmaarrfk hmaarrfk force-pushed the feature_remove_matplotlib_dependency branch from 95ca24c to 4043434 Compare June 6, 2018 17:51
hmaarrfk added a commit to hmaarrfk/scikit-image that referenced this pull request Jun 7, 2018
Undo some of the merge errors that were introduced in a previous rebase.
@hmaarrfk hmaarrfk mentioned this pull request Jun 9, 2018
15 tasks
@hmaarrfk hmaarrfk force-pushed the feature_remove_matplotlib_dependency branch 3 times, most recently from c08a930 to 5ff38ab Compare June 28, 2018 05:09
@hmaarrfk
Copy link
Member Author

Future me notes: Seems like mac os builds might be failing because of a bug in libpng
ImageMagick/ImageMagick#747 (comment)

@hmaarrfk hmaarrfk changed the title Remove matplotlib as a core dependency. WIP: Remove matplotlib as a core dependency. Jun 28, 2018
@soupault soupault self-assigned this Jul 29, 2018
@hmaarrfk hmaarrfk force-pushed the feature_remove_matplotlib_dependency branch from 14e7bf4 to 89d892a Compare August 6, 2018 03:14
@hmaarrfk hmaarrfk force-pushed the feature_remove_matplotlib_dependency branch 8 times, most recently from ec0795a to 3e2247c Compare September 30, 2018 05:09
@hmaarrfk hmaarrfk force-pushed the feature_remove_matplotlib_dependency branch 3 times, most recently from 41a6798 to ab6913a Compare September 30, 2018 14:03
@hmaarrfk hmaarrfk force-pushed the feature_remove_matplotlib_dependency branch from 5270a78 to b40aef6 Compare February 28, 2019 04:14
@soupault soupault modified the milestones: 0.15, 0.16 Apr 20, 2019
@@ -6,6 +6,7 @@ sphinx-gallery
sphinx-copybutton
pytest-runner
scikit-learn
matplotlib>=2.0.0,!=3.0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

what about future >3.0.0 it still won't be compatible, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

it should work, it is just 3.0.0 that is skipped. When 3.0.0 it had a bug, that was fixed in 3.0.1

Copy link
Contributor

Choose a reason for hiding this comment

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

well, now I see that there is no support for py2, (matplotlib 3.x droped it also)

Copy link
Member Author

Choose a reason for hiding this comment

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

for now, we still support installing matplotlib 2.3 + scikit-image 0.15

@alexdesiqueira
Copy link
Member

Hey @hmaarrfk,
how are we on this one? :)

@hmaarrfk
Copy link
Member Author

This needs a few core devs to want to take this on at one time. I can update if you want to review.

@@ -53,3 +61,81 @@ def polygon_area(pr, pc):
pr = np.asarray(pr)
pc = np.asarray(pc)
return 0.5 * np.abs(np.sum((pc[:-1] * pr[1:]) - (pc[1:] * pr[:-1])))


def _clip_sutherland_hodgman(rp, cp, rclip, cclip):
Copy link
Member

Choose a reason for hiding this comment

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

Where does this implementation come from? These clipping algorithms are notoriously tricky to get right.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wrote it adapting the code you referred to I believe.

https://github.com/stefanv/supreme/blob/master/supreme/ext/polygon.c#L121

Base automatically changed from master to main February 18, 2021 18:23
@grlee77 grlee77 added the 🤖 type: Infrastructure CI, packaging, tools and automation label Apr 5, 2021
@rfezzani
Copy link
Member

Sad that this PR is not merged 😕. @hmaarrfk do you have bandwidth to work again on it?

@hmaarrfk
Copy link
Member Author

I'm not too sure it made sense to remove the core dependency without a concerted desire from the core devs.

To do so, requires effort to move cleanup PRs like this one forward.

And follow them up with other maintenance PRs.

I tink people can take the implementation of the function I wrote here verbatim. I think it works.

I think there remained one function that needed to be rewritten to truely get rid of matplotlib.

It remains to answer, why?

The scientific Python stack has gotten ALOT easier to install now. So I think that depending on matplotlib is only about saving disk space, and likely loading time in niche applications.

I think both of those can be accomplished by lazy loading, which I think there was an interesting PR by stefanv.

I do think it is good to reduce dependencies to make things faster to download. I've gotten bitten by 256k modems (or throttled to those speeds) and any python installation process was rather miserable. But I'm not sure it is a common enough usecase for me to devote time on.

@rfezzani
Copy link
Member

Reducing our dependency may also help the adoption of skimage in safety-critical system development (medical software) where dependency and SOUP analysis is crucial!

@hmaarrfk
Copy link
Member Author

That is very true. If you are willing to help push this through, then I can likely mustard some courage to revive certain PRs.

@stefanv
Copy link
Member

stefanv commented Oct 20, 2021

I don't think matplotlib is software of unknown pedigree. It is true that we mostly use it for visualization, but it is employed in a few places for splines, polygons, etc. I'd get rid of the Qt dependency and deprecate skimage.viewer, then lazy load matplotlib as necessary (i.e., if you don't use it, it never gets pulled in).

@rfezzani
Copy link
Member

@stefanv, even if matplotlib pedigree is well known, it's a huge dependency, and its risk analysis is far from being easy 😅.

then lazy load matplotlib as necessary (i.e., if you don't use it, it never gets pulled in).

Do you mean that it will be installed on user machine the first time a function involving it is called?

jni pushed a commit that referenced this pull request Nov 5, 2021
This PR supersedes #3129. It:
- defines `skimage._shared.has_mpl` flag
- uses `skimage._shared.version_requirements.require` decorator on the function using `matplotlib`
- Disable `skimage.viewer` default imports if `matplotlib` is not installed
- skip tests requiring `matplotlib` when it is not installed.

Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
Co-authored-by: Riadh <r.fezzani@vitadx.com>
@jni
Copy link
Member

jni commented Nov 7, 2021

Superseded by #5990. Thank you for getting the ball rolling 3+ years ago (!), @hmaarrfk!

@jni jni closed this Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚖️ Needs decision 🤖 type: Infrastructure CI, packaging, tools and automation 🔧 type: Maintenance Refactoring and maintenance of internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet