-
Notifications
You must be signed in to change notification settings - Fork 652
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
optional dependencies (matplotlib and scipy) are not truly optional #1361
Comments
There isn't really a way for us to handle this more graceful then throwing an exception in those cases. For example in the pca case. If we can't import scipy that function can not return a suitable result because missing the integrator is a grave error justifying an exception. How would you imagine here a graceful error handling? |
So something we could do here would be to do all the imports at the top of the file, then raise warnings about things that won't work. Eg in |
I do note that some of the missing optional dependencies are already handled nicely in the code. Thank you for that. @kain88-de I'm just trying to express package dependencies correctly and let users uninstall dependencies listed in @richardjgowers Yes, that'd be awesome. |
So, this idea was already floated in #577, but we dropped when we realized it'd probably involve registering import hooks. In the meantime I found the I figure we can subclass |
Using |
There's some discussion in #1159 , which we haven't really concluded. I think we are moving towards making more "core scientific python packages" (see #1159 (comment) for qualifiers of this term...) standard requirements of MDAnalysis. |
Under this scheme,
is a big issue. But if |
If we decide that |
- updated all modules - removed any code that guards against scipy or matplotlib import - conforms to style guide https://github.com/MDAnalysis/mdanalysis/wiki/Style-Guide#module-imports-in-mdanalysisanalysis - fixes #1159 - fixes #1361
- updated all modules - removed any code that guards against scipy or matplotlib import - conforms to style guide https://github.com/MDAnalysis/mdanalysis/wiki/Style-Guide#module-imports-in-mdanalysisanalysis - fixes #1159 - fixes #1361
- updated all modules - removed any code that guards against scipy or matplotlib import - conforms to style guide https://github.com/MDAnalysis/mdanalysis/wiki/Style-Guide#module-imports-in-mdanalysisanalysis - fixes #1159 - fixes #1361
- require scipy and matplotlib in setup.py (fixes #1361) - scipy and matplotlib are imported at top in analysis - updated all modules - removed any code that guards against scipy or matplotlib import - conforms to style guide https://github.com/MDAnalysis/mdanalysis/wiki/Style-Guide#module-imports-in-mdanalysisanalysis - fixes #1159 - removed conditional skipping of tests when scipy or matplotlib are missing
- updated all modules - removed any code that guards against scipy or matplotlib import - conforms to style guide https://github.com/MDAnalysis/mdanalysis/wiki/Style-Guide#module-imports-in-mdanalysisanalysis - fixes #1159 - fixes #1361
- updated all modules - removed any code that guards against scipy or matplotlib import - conforms to style guide https://github.com/MDAnalysis/mdanalysis/wiki/Style-Guide#module-imports-in-mdanalysisanalysis - fixes #1159 - fixes #1361
- updated all modules - removed any code that guards against scipy or matplotlib import - conforms to style guide https://github.com/MDAnalysis/mdanalysis/wiki/Style-Guide#module-imports-in-mdanalysisanalysis - fixes MDAnalysis#1159 - fixes MDAnalysis#1361
- updated all modules - removed any code that guards against scipy or matplotlib import - conforms to style guide https://github.com/MDAnalysis/mdanalysis/wiki/Style-Guide#module-imports-in-mdanalysisanalysis - fixes MDAnalysis#1159 - fixes MDAnalysis#1361
Converted test_units to use parametrize Some hacking of test_distances to use pytest features Completed moving test_distances to pytest style rewrote test_transformations into pytest style make scipy and matplotlib full dependencies (MDAnalysis#1159) scipy and matplotlib are imported at top in analysis - updated all modules - removed any code that guards against scipy or matplotlib import - conforms to style guide https://github.com/MDAnalysis/mdanalysis/wiki/Style-Guide#module-imports-in-mdanalysisanalysis - fixes MDAnalysis#1159 - fixes MDAnalysis#1361 removed conditional skipping of tests when scipy or matplotlib are missing minor clean ups
Converted test_units to use parametrize Some hacking of test_distances to use pytest features Completed moving test_distances to pytest style rewrote test_transformations into pytest style make scipy and matplotlib full dependencies (MDAnalysis#1159) scipy and matplotlib are imported at top in analysis - updated all modules - removed any code that guards against scipy or matplotlib import - conforms to style guide https://github.com/MDAnalysis/mdanalysis/wiki/Style-Guide#module-imports-in-mdanalysisanalysis - fixes MDAnalysis#1159 - fixes MDAnalysis#1361 removed conditional skipping of tests when scipy or matplotlib are missing minor clean ups
Converted test_units to use parametrize Some hacking of test_distances to use pytest features Completed moving test_distances to pytest style rewrote test_transformations into pytest style make scipy and matplotlib full dependencies (MDAnalysis#1159) scipy and matplotlib are imported at top in analysis - updated all modules - removed any code that guards against scipy or matplotlib import - conforms to style guide https://github.com/MDAnalysis/mdanalysis/wiki/Style-Guide#module-imports-in-mdanalysisanalysis - fixes MDAnalysis#1159 - fixes MDAnalysis#1361 removed conditional skipping of tests when scipy or matplotlib are missing minor clean ups
- updated all modules - removed any code that guards against scipy or matplotlib import - conforms to style guide https://github.com/MDAnalysis/mdanalysis/wiki/Style-Guide#module-imports-in-mdanalysisanalysis - fixes MDAnalysis#1159 - fixes MDAnalysis#1361
Expected behaviour
The lack of any of the optional dependencies listed in
setup.py
(netcdf4, matplotlib, scipy, seaborn and sklearn) is handled gracefully, with no exceptions thrown.Actual behaviour
ImportError
exception will be thrown when matplotlib or scipy are missing.Code to reproduce the behaviour
The following imports don't catch ImportErrors when importing scipy:
and matplotlib:
Currently version of MDAnalysis:
0.16.0
The text was updated successfully, but these errors were encountered: