Skip to content

Commit

Permalink
reduced dependencies, minor delinting, added lazy_modules (#169)
Browse files Browse the repository at this point in the history
* reduced dependencies, minor delinting added lazy_modules

* fixes for testing

* change name from io to full in pyproject.toml

* try using tables_io[full] in pyproject.toml

* updated requirements.txt

* regularize to tables-io in pyproject.toml
  • Loading branch information
eacharles authored Apr 12, 2023
1 parent f95e378 commit 362ba6f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
16 changes: 12 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand Down Expand Up @@ -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",
Expand All @@ -55,7 +64,6 @@ dev = [
"kiwisolver",
"joblib",
"threadpoolctl",
"h5py",
"pylint",
"mpi4py",
"coverage",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ numpy
scipy>=1.9.0
scikit-learn
setuptools_scm
tables_io>=0.7.7
tables-io[full]
deprecated
1 change: 1 addition & 0 deletions src/qp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/qp/conversion_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/qp/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/qp/lazy_modules.py
Original file line number Diff line number Diff line change
@@ -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')
3 changes: 1 addition & 2 deletions src/qp/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 362ba6f

Please sign in to comment.