From 90b23a8b34b6d5ec442b4e21abd14703d7a09c5b Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Sun, 28 Nov 2021 13:29:15 -0500 Subject: [PATCH] Eschew deprecated numpy aliases for builtins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces “np.int” with “int”, and “np.float” with “float”, since these aliases are deprecated in numpy 1.20.0. See https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations for details and justification. Fixes #56. --- niaaml/pipeline.py | 2 +- niaaml/preprocessing/feature_selection/select_k_best.py | 4 ++-- niaaml/preprocessing/feature_selection/variance_threshold.py | 2 +- niaaml/utilities.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/niaaml/pipeline.py b/niaaml/pipeline.py index 66a0c6f..bc7660d 100644 --- a/niaaml/pipeline.py +++ b/niaaml/pipeline.py @@ -472,7 +472,7 @@ def evaluate_pipeline( ) if ( i[0][key].param_type is np.intc - or i[0][key].param_type is np.int + or i[0][key].param_type is int or i[0][key].param_type is np.uintc or i[0][key].param_type is np.uint ): diff --git a/niaaml/preprocessing/feature_selection/select_k_best.py b/niaaml/preprocessing/feature_selection/select_k_best.py index a508049..0aa06dd 100644 --- a/niaaml/preprocessing/feature_selection/select_k_best.py +++ b/niaaml/preprocessing/feature_selection/select_k_best.py @@ -62,8 +62,8 @@ def select_features(self, x, y, **kwargs): """ if self.__k is None: self.__k = x.shape[1] - self._params["k"] = ParameterDefinition(MinMax(1, self.__k), np.int) - val = np.int(np.around(np.random.uniform(1, self.__k))) + self._params["k"] = ParameterDefinition(MinMax(1, self.__k), int) + val = int(np.around(np.random.uniform(1, self.__k))) self.__select_k_best.set_params(k=val) self.__select_k_best.fit(x, y) diff --git a/niaaml/preprocessing/feature_selection/variance_threshold.py b/niaaml/preprocessing/feature_selection/variance_threshold.py index 6c6208b..45cb8f5 100644 --- a/niaaml/preprocessing/feature_selection/variance_threshold.py +++ b/niaaml/preprocessing/feature_selection/variance_threshold.py @@ -30,7 +30,7 @@ class VarianceThreshold(FeatureSelectionAlgorithm): def __init__(self, **kwargs): r"""Initialize VarianceThreshold feature selection algorithm.""" - self._params = dict(threshold=ParameterDefinition(MinMax(0, 0.1), np.float)) + self._params = dict(threshold=ParameterDefinition(MinMax(0, 0.1), float)) self.__variance_threshold = VarThr() def set_parameters(self, **kwargs): diff --git a/niaaml/utilities.py b/niaaml/utilities.py index 10d91e4..29ffc3f 100644 --- a/niaaml/utilities.py +++ b/niaaml/utilities.py @@ -20,7 +20,7 @@ def get_bin_index(value, number_of_bins): Returns: uint: Calculated index. """ - bin_index = np.int(np.floor(value / (1.0 / number_of_bins))) + bin_index = int(np.floor(value / (1.0 / number_of_bins))) if bin_index >= number_of_bins: bin_index -= 1 return bin_index