diff --git a/Orange/classification/__init__.py b/Orange/classification/__init__.py index 6639bc12d0a..2ef08288a9f 100644 --- a/Orange/classification/__init__.py +++ b/Orange/classification/__init__.py @@ -1,5 +1,5 @@ # Pull members from modules to Orange.classification namespace -# pylint: disable=wildcard-import +# pylint: disable=wildcard-import,broad-except from .base_classification import (ModelClassification as Model, LearnerClassification as Learner, @@ -23,7 +23,7 @@ from .scoringsheet import * try: from .catgb import * -except ModuleNotFoundError: +except Exception: pass from .gb import * try: diff --git a/Orange/data/io_base.py b/Orange/data/io_base.py index 4b0b74e0218..df3d7155796 100644 --- a/Orange/data/io_base.py +++ b/Orange/data/io_base.py @@ -381,7 +381,7 @@ def get_arrays(self) -> Tuple[np.ndarray, np.ndarray, (self.cols_W, float)) X, Y, M, W = [self._list_into_ndarray(lst, dt) for lst, dt in lists] if X is None: - X = np.empty((self.data.shape[0], 0), dtype=np.float_) + X = np.empty((self.data.shape[0], 0), dtype=np.float64) return X, Y, M, W @staticmethod @@ -393,7 +393,7 @@ def _list_into_ndarray(lst: List, dtype=None) -> Optional[np.ndarray]: if dtype is not None: array.astype(dtype) else: - assert array.dtype == np.float_ + assert array.dtype == np.float64 return array diff --git a/Orange/data/util.py b/Orange/data/util.py index bee1f7feac4..79bacea75e4 100644 --- a/Orange/data/util.py +++ b/Orange/data/util.py @@ -50,7 +50,7 @@ def scale(values, min=0, max=1): """Return values scaled to [min, max]""" if len(values) == 0: return np.array([]) - minval = np.float_(bn.nanmin(values)) + minval = np.float64(bn.nanmin(values)) ptp = bn.nanmax(values) - minval if ptp == 0: return np.clip(values, min, max) diff --git a/Orange/preprocess/_relieff.pyx b/Orange/preprocess/_relieff.pyx index 3b2ae39786a..db493954f6a 100644 --- a/Orange/preprocess/_relieff.pyx +++ b/Orange/preprocess/_relieff.pyx @@ -371,7 +371,7 @@ cdef tuple prepare(X, y, is_discrete, contingencies): is_defined = np.logical_not(np.isnan(y)) X = X[is_defined] y = y[is_defined] - attr_stats = np.row_stack((np.nanmean(X, 0), np.nanstd(X, 0))) + attr_stats = np.vstack((np.nanmean(X, 0), np.nanstd(X, 0))) is_discrete = np.asarray(is_discrete, dtype=np.int8) contingency_tables(X, y, is_discrete, contingencies) return X, y, attr_stats, is_discrete diff --git a/Orange/preprocess/discretize.py b/Orange/preprocess/discretize.py index ab5062c534a..fe06ba72bfb 100644 --- a/Orange/preprocess/discretize.py +++ b/Orange/preprocess/discretize.py @@ -44,7 +44,7 @@ def transform(self, c): if sp.issparse(c): return self.digitize(c, self.points) elif c.size: - return np.where(np.isnan(c), np.NaN, self.digitize(c, self.points)) + return np.where(np.isnan(c), np.nan, self.digitize(c, self.points)) else: return np.array([], dtype=int) diff --git a/Orange/preprocess/remove.py b/Orange/preprocess/remove.py index dddba413331..74b00f2d231 100644 --- a/Orange/preprocess/remove.py +++ b/Orange/preprocess/remove.py @@ -233,7 +233,7 @@ def remove_unused_values(var, data): if len(unique) == len(var.values): return var used_values = [var.values[i] for i in unique] - translation_table = np.array([np.NaN] * len(var.values)) + translation_table = np.array([np.nan] * len(var.values)) translation_table[unique] = range(len(used_values)) return DiscreteVariable(var.name, values=used_values, sparse=var.sparse, compute_value=Lookup(var, translation_table)) diff --git a/Orange/regression/__init__.py b/Orange/regression/__init__.py index 74d68ed6a38..a0315ef65cf 100644 --- a/Orange/regression/__init__.py +++ b/Orange/regression/__init__.py @@ -17,7 +17,7 @@ from ..classification.simple_tree import * try: from .catgb import * -except ModuleNotFoundError: +except Exception: pass from .gb import * try: diff --git a/Orange/tests/test_classification.py b/Orange/tests/test_classification.py index 05ba316a21a..af476168cc0 100644 --- a/Orange/tests/test_classification.py +++ b/Orange/tests/test_classification.py @@ -347,7 +347,7 @@ def test_multinomial(self): def test_nan_columns(self): data = Orange.data.Table("iris") with data.unlocked(): - data.X[:, (1, 3)] = np.NaN + data.X[:, (1, 3)] = np.nan lr = LogisticRegressionLearner() cv = CrossValidation(k=2, store_models=True) res = cv(data, [lr]) diff --git a/Orange/tests/test_domain.py b/Orange/tests/test_domain.py index a5e32660a06..1c79c0d2a8d 100644 --- a/Orange/tests/test_domain.py +++ b/Orange/tests/test_domain.py @@ -430,7 +430,7 @@ def test_preprocessor_chaining(self): domain = Domain([DiscreteVariable("a", values="01"), DiscreteVariable("b", values="01")], DiscreteVariable("y", values="01")) - table = Table.from_list(domain, [[0, 1], [1, np.NaN]], [0, 1]) + table = Table.from_list(domain, [[0, 1], [1, np.nan]], [0, 1]) pre1 = Continuize()(Impute()(table)) pre2 = table.transform(pre1.domain) np.testing.assert_almost_equal(pre1.X, pre2.X) diff --git a/Orange/tests/test_preprocess.py b/Orange/tests/test_preprocess.py index 99fd76a4ad9..6e190901009 100644 --- a/Orange/tests/test_preprocess.py +++ b/Orange/tests/test_preprocess.py @@ -80,7 +80,7 @@ class TestRemoveNaNColumns(unittest.TestCase): def test_column_filtering(self): data = Table("iris") with data.unlocked(): - data.X[:, (1, 3)] = np.NaN + data.X[:, (1, 3)] = np.nan new_data = RemoveNaNColumns()(data) self.assertEqual(len(new_data.domain.attributes), @@ -88,7 +88,7 @@ def test_column_filtering(self): data = Table("iris") with data.unlocked(): - data.X[0, 0] = np.NaN + data.X[0, 0] = np.nan new_data = RemoveNaNColumns()(data) self.assertEqual(len(new_data.domain.attributes), len(data.domain.attributes)) diff --git a/Orange/widgets/data/owselectbydataindex.py b/Orange/widgets/data/owselectbydataindex.py index 192c7a30bf2..17b64c1beb0 100644 --- a/Orange/widgets/data/owselectbydataindex.py +++ b/Orange/widgets/data/owselectbydataindex.py @@ -83,7 +83,7 @@ def commit(self): if self.data_subset and \ not np.intersect1d(subset_ids, self.data.ids).size: self.Warning.instances_not_matching() - row_sel = np.in1d(self.data.ids, subset_ids) + row_sel = np.isin(self.data.ids, subset_ids) matching_output = self.data[row_sel] non_matching_output = self.data[~row_sel] annotated_output = create_annotated_table(self.data, row_sel) diff --git a/Orange/widgets/data/owselectrows.py b/Orange/widgets/data/owselectrows.py index 9bc57c17515..248285bd61b 100644 --- a/Orange/widgets/data/owselectrows.py +++ b/Orange/widgets/data/owselectrows.py @@ -652,7 +652,7 @@ def commit(self): filters.negate = True non_matching_output = filters(self.data) - row_sel = np.in1d(self.data.ids, matching_output.ids) + row_sel = np.isin(self.data.ids, matching_output.ids) annotated_output = create_annotated_table(self.data, row_sel) # if hasattr(self.data, "name"): diff --git a/Orange/widgets/data/tests/test_owcontinuize.py b/Orange/widgets/data/tests/test_owcontinuize.py index af84bd1d526..eb784a7c127 100644 --- a/Orange/widgets/data/tests/test_owcontinuize.py +++ b/Orange/widgets/data/tests/test_owcontinuize.py @@ -56,7 +56,7 @@ def test_one_column_equal_values(self): def test_one_column_nan_values_normalize_sd(self): table = Table("iris") with table.unlocked(): - table[:, 2] = np.NaN + table[:, 2] = np.nan self.send_signal(self.widget.Inputs.data, table) # Normalize.NormalizeBySD self.widget.continuous_treatment = 2 @@ -64,14 +64,14 @@ def test_one_column_nan_values_normalize_sd(self): table = Table("iris") with table.unlocked(): - table[1, 2] = np.NaN + table[1, 2] = np.nan self.send_signal(self.widget.Inputs.data, table) self.widget.commit.now() def test_one_column_nan_values_normalize_span(self): table = Table("iris") with table.unlocked(): - table[:, 2] = np.NaN + table[:, 2] = np.nan self.send_signal(self.widget.Inputs.data, table) # Normalize.NormalizeBySpan self.widget.continuous_treatment = 1 @@ -79,7 +79,7 @@ def test_one_column_nan_values_normalize_span(self): table = Table("iris") with table.unlocked(): - table[1, 2] = np.NaN + table[1, 2] = np.nan self.send_signal(self.widget.Inputs.data, table) self.widget.commit.now() diff --git a/Orange/widgets/model/tests/test_owlogisticregression.py b/Orange/widgets/model/tests/test_owlogisticregression.py index 47139172f20..88b03a68bf1 100644 --- a/Orange/widgets/model/tests/test_owlogisticregression.py +++ b/Orange/widgets/model/tests/test_owlogisticregression.py @@ -106,7 +106,7 @@ def test_target_with_nan(self): """ table = Table("iris") with table.unlocked(): - table.Y[:5] = np.NaN + table.Y[:5] = np.nan self.send_signal(self.widget.Inputs.data, table) coef1 = self.get_output(self.widget.Outputs.coefficients) table = table[5:] diff --git a/Orange/widgets/tests/test_matplotlib_export.py b/Orange/widgets/tests/test_matplotlib_export.py index 334f7d1ae35..3fb67a3a8ff 100644 --- a/Orange/widgets/tests/test_matplotlib_export.py +++ b/Orange/widgets/tests/test_matplotlib_export.py @@ -11,6 +11,7 @@ def add_intro(a): r = "import matplotlib.pyplot as plt\n" + \ + "import numpy as np\n" + \ "from numpy import array\n" + \ "plt.clf()" return r + a diff --git a/Orange/widgets/visualize/owboxplot.py b/Orange/widgets/visualize/owboxplot.py index 6ac71e35d1b..efdf824a4bb 100644 --- a/Orange/widgets/visualize/owboxplot.py +++ b/Orange/widgets/visualize/owboxplot.py @@ -1180,7 +1180,7 @@ def commit(self): conditions = self._gather_conditions() if conditions: selected = Values(conditions, conjunction=False)(self.dataset) - selection = np.in1d( + selection = np.isin( self.dataset.ids, selected.ids, assume_unique=True).nonzero()[0] else: selected, selection = None, [] diff --git a/Orange/widgets/visualize/ownomogram.py b/Orange/widgets/visualize/ownomogram.py index d0a1392340d..6bbbbc168af 100644 --- a/Orange/widgets/visualize/ownomogram.py +++ b/Orange/widgets/visualize/ownomogram.py @@ -1062,7 +1062,7 @@ def offset(name, point): names = list(chain.from_iterable( [_get_labels(a, lr and lr[i] and lr[i][0] and lr[i][cls_index], OWNomogram.get_ruler_values(p.min(), p.max(), - scale * p.ptp(), False)) + scale * np.ptp(p), False)) for i, a, p in zip(attr_inds, attributes, points)])) points = list(chain.from_iterable(points)) @@ -1107,7 +1107,7 @@ def create_main_nomogram(self, attributes, attr_inds, name_items, points, name_item, attr, self.log_reg_cont_data_extremes[i][cls_index], self.get_ruler_values( point.min(), point.max(), - scale_x * point.ptp(), False), + scale_x * np.ptp(point), False), scale_x, name_offset, - scale_x * min_p) for i, attr, name_item, point in zip(attr_inds, attributes, name_items, points)] @@ -1151,7 +1151,7 @@ def key(x): def key(x): i, attr = x if attr.is_discrete: - ptp = self.points[i][class_value].ptp() + ptp = np.ptp(self.points[i][class_value]) else: coef = np.abs(self.log_reg_coeffs_orig[i][class_value]).mean() ptp = coef * np.ptp(self.log_reg_cont_data_extremes[i][class_value]) diff --git a/Orange/widgets/visualize/owradviz.py b/Orange/widgets/visualize/owradviz.py index 2eb217c14c7..e64798434af 100644 --- a/Orange/widgets/visualize/owradviz.py +++ b/Orange/widgets/visualize/owradviz.py @@ -309,7 +309,7 @@ def _manual_move(self, anchor_idx, x, y): def _send_components_x(self): components_ = super()._send_components_x() angle = np.arctan2(*components_[::-1]) - return np.row_stack((components_, angle)) + return np.vstack((components_, angle)) def _send_components_metas(self): return np.vstack((super()._send_components_metas(), ["angle"])) diff --git a/Orange/widgets/visualize/owsilhouetteplot.py b/Orange/widgets/visualize/owsilhouetteplot.py index d512feed6d0..e0a2b169048 100644 --- a/Orange/widgets/visualize/owsilhouetteplot.py +++ b/Orange/widgets/visualize/owsilhouetteplot.py @@ -1074,7 +1074,7 @@ def __itemDataAtPos(self, pos) -> Optional[Tuple[namespace, int, QRectF]]: def __selectionChanged(self, selected, deselected): for item, grp in zip(self.__plotItems(), self.__groups): select = np.flatnonzero( - np.in1d(grp.indices, selected, assume_unique=True)) + np.isin(grp.indices, selected, assume_unique=True)) items = item.items() if select.size: for i in select: @@ -1082,7 +1082,7 @@ def __selectionChanged(self, selected, deselected): items[i].setBrush(QBrush(QColor(*color))) deselect = np.flatnonzero( - np.in1d(grp.indices, deselected, assume_unique=True)) + np.isin(grp.indices, deselected, assume_unique=True)) if deselect.size: for i in deselect: items[i].setBrush(QBrush(QColor(*grp.color))) diff --git a/Orange/widgets/visualize/tests/test_owmosaic.py b/Orange/widgets/visualize/tests/test_owmosaic.py index be9989ed34e..0b9f8f8e191 100644 --- a/Orange/widgets/visualize/tests/test_owmosaic.py +++ b/Orange/widgets/visualize/tests/test_owmosaic.py @@ -421,9 +421,9 @@ def test_nan_column(self): Domain( [ContinuousVariable("a"), ContinuousVariable("b"), ContinuousVariable("c")]), np.array([ - [0, np.NaN, 0], - [0, np.NaN, 0], - [0, np.NaN, 0] + [0, np.nan, 0], + [0, np.nan, 0], + [0, np.nan, 0] ]) ) self.send_signal(self.widget.Inputs.data, table) diff --git a/Orange/widgets/visualize/tests/test_owsilhouetteplot.py b/Orange/widgets/visualize/tests/test_owsilhouetteplot.py index 917b1239895..3674722b61e 100644 --- a/Orange/widgets/visualize/tests/test_owsilhouetteplot.py +++ b/Orange/widgets/visualize/tests/test_owsilhouetteplot.py @@ -158,7 +158,7 @@ def test_bad_data_range(self): Silhouette Plot now sets axis range properly. GH-2377 """ - nan = np.NaN + nan = np.nan table = Table.from_list( Domain( [ContinuousVariable("a"), ContinuousVariable("b"), ContinuousVariable("c")], diff --git a/Orange/widgets/visualize/utils/heatmap.py b/Orange/widgets/visualize/utils/heatmap.py index 4a02765d5bb..5ed2e2ebd0a 100644 --- a/Orange/widgets/visualize/utils/heatmap.py +++ b/Orange/widgets/visualize/utils/heatmap.py @@ -1055,7 +1055,7 @@ def selectRows(self, selection: Sequence[int]): indices = np.hstack([r.normalized_indices for r in self.parts.rows]) else: indices = [] - condition = np.in1d(indices, selection) + condition = np.isin(indices, selection) visual_indices = np.flatnonzero(condition) self.__selection_manager.select_rows(visual_indices.tolist()) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index b82ed663e1f..500a6b86cd0 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -23,7 +23,7 @@ requirements: - python - pip - cython - - numpy + - numpy >= 2 - recommonmark - setuptools - sphinx >=4.2.0,<8 @@ -43,14 +43,13 @@ requirements: # core requirements - baycomp >=1.0.2 - bottleneck >=1.3.4 - - catboost >=1.0.1 - chardet >=3.0.2 - httpx >=0.21 - joblib >=1.2.0 - keyring - keyrings.alt - networkx - - numpy >=1.20.0,<2 + - numpy >=1.20.0 - openpyxl >=3.1.3 - openTSNE >=0.6.1,!=0.7.0 - pandas >=1.4.0,!=1.5.0,!=2.0.0 diff --git a/pyproject.toml b/pyproject.toml index 2b71a29257e..4f8c9b26b6e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [build-system] requires = [ "cython>=3.0", - "oldest-supported-numpy", + "numpy>=2.0", "recommonmark", "setuptools>=51.0", "sphinx", diff --git a/requirements-core.txt b/requirements-core.txt index 260f63470be..1d754302a1d 100644 --- a/requirements-core.txt +++ b/requirements-core.txt @@ -1,6 +1,5 @@ baycomp>=1.0.2 bottleneck>=1.3.4 -catboost>=1.0.1 # Encoding detection chardet>=3.0.2 httpx>=0.21.0 @@ -9,7 +8,7 @@ joblib>=1.2.0 keyring keyrings.alt # for alternative keyring implementations networkx -numpy>=1.20.0,<2 +numpy>=1.20.0 openpyxl>=3.1.3 openTSNE>=0.6.1,!=0.7.0 # 0.7.0 segfaults packaging