Open mgrady3 opened 3 years ago
Thanks for raising this!
Do you think there's an easy fix?
Very happy to look at a pull request if it's not too difficult to deal with ...
No problem.
From what I can tell, if no user configuration file if present, i.e. ~/.config/GPy/user.cfg
, then GPy
will fallback to the configuration as specified in the defaults.cfg
file, which in this case defaults to library=matplotlib
for the [plotting]
section of the config:
https://github.com/SheffieldML/GPy/blob/v1.9.7/GPy/util/config.py#L17 https://github.com/SheffieldML/GPy/blob/v1.9.7/GPy/defaults.cfg#L33
So, one option would be to change the default configuration setting in the [plotting]
section to library=none
.
That should make matplotlib truly into an optional dependency. That said, I have not yet tested this to see if there are any further consequences.
I can take a look at what, if anything, would break from that change, but it will take me a bit to get a development environment setup.
The
setup.py
file forgpy
declaresmatplotlib
as an optional/extra dependency for theplotting
sub-package.However, due to the way the
plotting
subpackage is imported in the top-level__init__.py
, https://github.com/SheffieldML/GPy/blob/devel/GPy/__init__.py#L15, there does not seem to be a way to import anything fromGPy
withoutmatplotlib
installed. See the example below from a clean pip install ofgpy-1.9.9
.I understand that the
plotting
subpackage has some instructions about settings in a.cfg
file that could be used to prevent this import error, but that seems rather cumbersome, and given that the suggestion here, https://github.com/SheffieldML/GPy/blob/devel/GPy/plotting/__init__.py#L22, is to put a file in a User-wide config location, that becomes problematic when you have mutiple projects that may want to useGPy
in different ways, i.e. one that cares about plotting and one that does not.