From a8de34c350d0ce1a119c2a75a203de11dafb2e44 Mon Sep 17 00:00:00 2001 From: Angela Date: Mon, 2 May 2022 21:28:34 -0400 Subject: [PATCH] fixed missing distl made scikit-learn a soft dependency as well --- ligeor/ebai/ebai.py | 14 ++++++++++---- ligeor/utils/processing.py | 5 ++++- tests/test_ebai.py | 0 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 tests/test_ebai.py diff --git a/ligeor/ebai/ebai.py b/ligeor/ebai/ebai.py index f715ca4..f49779d 100644 --- a/ligeor/ebai/ebai.py +++ b/ligeor/ebai/ebai.py @@ -1,18 +1,24 @@ import numpy as np import warnings -from sklearn.neighbors import KNeighborsRegressor -from sklearn.neural_network import MLPRegressor import matplotlib.pyplot as plt -from sklearn.preprocessing import MinMaxScaler plt.style.use('science') from scipy.interpolate import interp1d -from sklearn.model_selection import GridSearchCV + try: import cmasher as cmr _use_cmr = True except: _use_cmr = False +try: + from sklearn.preprocessing import MinMaxScaler + from sklearn.neighbors import KNeighborsRegressor + from sklearn.neural_network import MLPRegressor + from sklearn.model_selection import GridSearchCV +except: + raise ImportError('scikit-learn needs to be installed to run EBAI.') + + class Ebai(): def __init__(self, model=None, model_type='knn', diff --git a/ligeor/utils/processing.py b/ligeor/utils/processing.py index 26ee98f..4f04c51 100644 --- a/ligeor/utils/processing.py +++ b/ligeor/utils/processing.py @@ -1,5 +1,8 @@ import numpy as np -import distl +try: + import distl +except: + raise ImportError('distl needs to be installed for sampling distributions.') def sample_skewed_gaussian(mean, sigma_low, sigma_high, size=1000): diff --git a/tests/test_ebai.py b/tests/test_ebai.py new file mode 100644 index 0000000..e69de29