diff --git a/pyproject.toml b/pyproject.toml index cd7859bb..baa388b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,11 +13,9 @@ classifiers = [ ] dynamic = ["version"] dependencies = [ - "matplotlib", "numpy", "scipy >= 1.9.0", - "scikit-learn", - "tables_io >= 0.7.7", + "tables-io >= 0.8.0", "deprecated", ] @@ -45,7 +43,18 @@ build-backend = "setuptools.build_meta" write_to = "src/qp/_version.py" [project.optional-dependencies] +full = [ + "tables-io[full]", +] +all = [ + "tables-io[full]", + "matplotlib", + "scikit-learn", +] dev = [ + "tables-io[full]", + "matplotlib", + "scikit-learn", "pytest", "pytest-cov", "packaging", @@ -55,7 +64,6 @@ dev = [ "kiwisolver", "joblib", "threadpoolctl", - "h5py", "pylint", "mpi4py", "coverage", diff --git a/requirements.txt b/requirements.txt index a990665e..25bd9b93 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,5 @@ numpy scipy>=1.9.0 scikit-learn setuptools_scm -tables_io>=0.7.7 +tables-io[full] deprecated diff --git a/src/qp/__init__.py b/src/qp/__init__.py index 13d5bd7e..26e18b10 100644 --- a/src/qp/__init__.py +++ b/src/qp/__init__.py @@ -13,6 +13,7 @@ from .packed_interp_pdf import * from .ensemble import Ensemble from .factory import instance, add_class, create, read, convert, concatenate, iterator, data_length, from_tables +from .lazy_modules import * from . import utils diff --git a/src/qp/conversion_funcs.py b/src/qp/conversion_funcs.py index c1c64253..39d68fb4 100644 --- a/src/qp/conversion_funcs.py +++ b/src/qp/conversion_funcs.py @@ -4,11 +4,11 @@ """ import numpy as np -from sklearn import mixture from scipy import integrate as sciint from scipy import interpolate as sciinterp from .sparse_rep import indices2shapes, build_sparse_representation, decode_sparse_indices +from .lazy_modules import mixture def extract_vals_at_x(in_dist, **kwargs): """Convert using a set of x and y values. diff --git a/src/qp/factory.py b/src/qp/factory.py index e8e0b91b..d786a5ae 100644 --- a/src/qp/factory.py +++ b/src/qp/factory.py @@ -122,10 +122,10 @@ def create(self, class_name, data, method=None): def from_tables(self, tables): """Build this ensemble from a tables - + Parameters ---------- - tables: `dict` + tables: `dict` Notes ----- @@ -149,7 +149,7 @@ def from_tables(self, tables): if reader_convert is not None: #pragma: no cover data = reader_convert(data) return Ensemble(ctor_func, data=data, ancil=ancil_table) - + def read(self, filename): """Read this ensemble from a file diff --git a/src/qp/lazy_modules.py b/src/qp/lazy_modules.py new file mode 100644 index 00000000..057a91e9 --- /dev/null +++ b/src/qp/lazy_modules.py @@ -0,0 +1,7 @@ +""" Lazy loading modules """ + +from tables_io.lazy_modules import lazyImport + +mpl = lazyImport('matplotlib') +plt = lazyImport('matplotlib.pyplot') +mixture = lazyImport('sklearn.mixture') diff --git a/src/qp/plotting.py b/src/qp/plotting.py index c97d720f..fb7bde69 100644 --- a/src/qp/plotting.py +++ b/src/qp/plotting.py @@ -2,8 +2,7 @@ import numpy as np -import matplotlib as mpl -import matplotlib.pyplot as plt +from .lazy_modules import mpl, plt def init_matplotlib():