Skip to content

Commit

Permalink
Merge pull request #6492 from ales-erjavec/deprecation-warnings
Browse files Browse the repository at this point in the history
Fix numpy deprecation warnings
  • Loading branch information
markotoplak committed Jun 30, 2023
2 parents 2825cbf + 338f70c commit ff152a9
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Orange/preprocess/_relieff.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ cdef void contingency_tables(np.ndarray X,

cdef tuple prepare(X, y, is_discrete, contingencies):
X = np.array(X, dtype=np.float64, order='C')
is_discrete = np.asarray(is_discrete, dtype=np.bool8)
is_discrete = np.asarray(is_discrete, dtype=np.bool_)
is_continuous = ~is_discrete
if is_continuous.any():
row_min = np.nanmin(X, 0)
Expand Down
2 changes: 1 addition & 1 deletion Orange/preprocess/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def score_data(self, data, feature):
from Orange.preprocess._relieff import relieff
weights = np.asarray(relieff(data.X, data.Y,
self.n_iterations, self.k_nearest,
np.array([a.is_discrete for a in data.domain.attributes]),
np.array([a.is_discrete for a in data.domain.attributes], dtype=bool),
rstate))
if feature:
return weights[0]
Expand Down
7 changes: 0 additions & 7 deletions Orange/widgets/unsupervised/tests/test_owdbscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from Orange.data import Table
from Orange.clustering import DBSCAN
from Orange.distance import Euclidean
from Orange.preprocess import Normalize, Continuize, SklImpute
from Orange.widgets.tests.base import WidgetTest
from Orange.widgets.tests.utils import simulate, possible_duplicate_table
Expand Down Expand Up @@ -173,12 +172,6 @@ def test_get_kth_distances(self):
# dists must be sorted
np.testing.assert_array_equal(dists, np.sort(dists)[::-1])

# test with different distance - e.g. Orange distance
dists = get_kth_distances(self.iris, Euclidean, k=5)
self.assertEqual(len(self.iris), len(dists))
# dists must be sorted
np.testing.assert_array_equal(dists, np.sort(dists)[::-1])

def test_metric_changed(self):
w = self.widget

Expand Down
4 changes: 2 additions & 2 deletions Orange/widgets/visualize/owfreeviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def update_anchors(self):
self.anchor_items = []
for point, label in zip(points, labels):
anchor = AnchorItem(line=QLineF(0, 0, *point), text=label)
anchor.setVisible(np.linalg.norm(point) > r)
anchor.setVisible(bool(np.linalg.norm(point) > r))
anchor.setPen(pg.mkPen((100, 100, 100)))
anchor.setFont(self.parameter_setter.anchor_font)
self.plot_widget.addItem(anchor)
Expand All @@ -98,7 +98,7 @@ def update_anchors(self):
for anchor, point, label in zip(self.anchor_items, points, labels):
anchor.setLine(QLineF(0, 0, *point))
anchor.setText(label)
anchor.setVisible(np.linalg.norm(point) > r)
anchor.setVisible(bool(np.linalg.norm(point) > r))
anchor.setFont(self.parameter_setter.anchor_font)

def update_circle(self):
Expand Down
4 changes: 2 additions & 2 deletions Orange/widgets/visualize/owlinearprojection.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,15 @@ def update_anchors(self):
anchor.setFont(self.parameter_setter.anchor_font)

visible = self.always_show_axes or np.linalg.norm(point) > r
anchor.setVisible(visible)
anchor.setVisible(bool(visible))
anchor.setPen(pg.mkPen((100, 100, 100)))
self.plot_widget.addItem(anchor)
self.anchor_items.append(anchor)
else:
for anchor, point, label in zip(self.anchor_items, points, labels):
anchor.setLine(QLineF(0, 0, *point))
visible = self.always_show_axes or np.linalg.norm(point) > r
anchor.setVisible(visible)
anchor.setVisible(bool(visible))
anchor.setFont(self.parameter_setter.anchor_font)

def update_circle(self):
Expand Down
2 changes: 1 addition & 1 deletion Orange/widgets/visualize/ownomogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ def calculate_log_reg_coefficients(self):
coef = self.log_reg_coeffs[i]
self.log_reg_coeffs[i] = np.hstack((coef * min_t, coef * max_t))
self.log_reg_cont_data_extremes.append(
[sorted([min_t, max_t], reverse=(c < 0)) for c in coef.flat])
[sorted([min_t, max_t], reverse=bool(c < 0)) for c in coef.flat])
else:
self.log_reg_cont_data_extremes.append([None])

Expand Down
2 changes: 1 addition & 1 deletion Orange/widgets/visualize/owradviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def _init_vizrank(self):
not np.isnan(self.data.get_column(self.attr_color)).all() and \
np.sum(np.all(np.isfinite(self.data.X), axis=1)) > 1 and \
np.all(np.nan_to_num(np.nanstd(self.data.X, 0)) != 0)
self.btn_vizrank.setEnabled(is_enabled)
self.btn_vizrank.setEnabled(bool(is_enabled))
if is_enabled:
self.vizrank.initialize()

Expand Down
6 changes: 3 additions & 3 deletions Orange/widgets/visualize/owscatterplotgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ def tickValues(self, minVal, maxVal, size):
# Remove ticks that will later be removed in AxisItem.generateDrawSpecs
# because they are out of range. Removing them here is needed so that
# they do not affect spaces and label format
ticks = ticks[(ticks[0] < minVal)
:len(ticks) - (ticks[-1] > maxVal)]
ticks = ticks[int((ticks[0] < minVal))
:len(ticks) - int((ticks[-1] > maxVal))]

max_steps = max(int(size / self._label_width), 1)
if len(ticks) > max_steps:
Expand Down Expand Up @@ -1269,7 +1269,7 @@ def update_labels(self):
mask = None

self._signal_too_many_labels(
mask is not None and mask.sum() > self.MAX_VISIBLE_LABELS)
bool(mask is not None and mask.sum() > self.MAX_VISIBLE_LABELS))
if self._too_many_labels or mask is None or not np.any(mask):
return

Expand Down

0 comments on commit ff152a9

Please sign in to comment.