Repository navigation
Make matplotlib an optional dependency - #5990
Conversation
|
Hello @rfezzani! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2021-11-03 14:28:38 UTC |
|
|
||
|
|
||
| @require("matplotlib", ">=3.0.3") | ||
| def _draw_polygon(ax, vertices, alpha=0.4): |
There was a problem hiding this comment.
I think the original comment was that we didn't want to start to ship analysis code where functionality depended on the libraries installed.
There was a problem hiding this comment.
😕 hum, I don't remember this discussion. Is it still the case?
Most function depending on matplotlib are visualization tools/utils. The only "real" functionality is draw.polygon_perimeter 🙁
There was a problem hiding this comment.
I think this was roughly 3 years ago, back when i was trying to slim down the dependencies .I don't remember you on the discussions at that time!
In either case, let me try to find it.
There was a problem hiding this comment.
I guess the discussion was elsewhere, but my attempt was to create our own implementation of the draw polygon algorithm.
There was a problem hiding this comment.
I see, OK, thank you @hmaarrfk. Let's wait to see if this is a strong requirement from @scikit-image/core members, otherwise I'll investigate more to overcome this 😉
grlee77
left a comment
There was a problem hiding this comment.
The implementation here looks good. The main question is whether or not we want to do this.
The main benefit is that a somewhat large dependency becomes optional. The primary downside is that there are a small subset of functions that will not be usable if the user has not installed matplotlib. As far as I can tell, these are:
skimage.draw.polygon_clip
skimage.draw.polygon_perimeter
skimage.draw.rectangle_perimeter
skimage.filters.try_all_threshold
skimage.future.graph.show_rag
skimage.future.manual_lasso_segmentation
skimage.future.manual_polygon_segmentation
I think I am weakly in favor of having this as an optional dependency, since there are likely many users that do not need the above functions. I would guess that a majority of these will already have Matplotlib or not care if it gets pulled in to a scikit-image install. For any users who really want a minimal install of scikit-image, though, this would help them.
|
The biggest advantage may be that we can release for new versions of Python earlier if we do not depend on Matplotlib wheels being available. Other than that, I am agnostic: most users will install them together anyway. |
jni
left a comment
There was a problem hiding this comment.
I 👍. I was the one who raised the most fuss about fixing the draw functions to not require mpl, but, three years later, I think the advantage of shipping without mpl as a dependency outweigh the fact that we would miss those three functions. If someone needs the functions and really needs to have them without mpl, perhaps they will be able to help with that implementation. ;) Thanks @rfezzani!
|
@scikit-image/core if there are no objections in the next ~24h I will go ahead and merge this. |
|
|
||
|
|
||
| @testing.skipif(not has_qt, reason="Qt not installed") | ||
| @pytest.mark.skipif(not has_qt, reason="Qt not installed") |
There was a problem hiding this comment.
It looks like instances of "Qt not installed" are more numerous than "Needs matplotlib" so maybe the consistency concern should be the other way around.
There was a problem hiding this comment.
Thank @mkcor for your review, I fixed it the way around: "Needs matplotlib" -> "matplotlib not installed"
@jni ok, I just left minor suggestions! |
Co-authored-by: Marianne Corvellec <[email protected]>
…ikit-image into Make_matplotlib_optional_dep
|
Thank you all for your comments and reviews 🎉 |
Description
This PR supersede @hmaarrfk PR #3129. It basically
skimage._shared.has_mplflagskimage._shared.version_requirements.requiredecorator on the function usingmatplotlibskimage.viewerdefault imports ifmatplotlibis not installedmatplotlibwhen it is not installed.Checklist
./doc/examples(new features only)./benchmarks, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py.doc/release/release_dev.rst.