Skip to content

Commit

Permalink
scatterplot: fix tests
Browse files Browse the repository at this point in the history
We will adapt tests for sampling accordingly once the implementation of interactive sampling is finalised and if it will be included in the master.
  • Loading branch information
JakaKokosar committed Jul 18, 2023
1 parent 22422ab commit 82c0a3c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
17 changes: 17 additions & 0 deletions Orange/widgets/visualize/tests/test_owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,23 @@ class TestOWScatterPlotWithDask(TestOWScatterPlot):
def init(self):
self.data = temp_dasktable("iris")

def test_data_column_nans(self):
table = temp_dasktable(datasets.data_one_column_nans())
self.send_signal(self.widget.Inputs.data, table)
cb_attr_color = self.widget.controls.attr_color
simulate.combobox_activate_item(cb_attr_color, "b")
simulate.combobox_activate_item(self.widget.cb_attr_x, "a")
simulate.combobox_activate_item(self.widget.cb_attr_y, "a")

# self.widget.update_graph()
self.widget.graph.reset_graph()

def test_data_column_infs(self):
table = temp_dasktable(datasets.data_one_column_infs())
self.send_signal(self.widget.Inputs.data, table)
attr_x = self.widget.controls.attr_x
simulate.combobox_activate_item(attr_x, "b")


if __name__ == "__main__":
import unittest
Expand Down
14 changes: 13 additions & 1 deletion Orange/widgets/visualize/tests/test_owscatterplotbase.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# pylint: disable=missing-docstring,too-many-lines,too-many-public-methods
# pylint: disable=protected-access
import unittest
from itertools import count
from unittest.mock import patch, Mock
import numpy as np
import dask.array as da

from AnyQt.QtCore import QRectF, Qt
from AnyQt.QtGui import QColor
Expand All @@ -26,6 +28,7 @@ def __init__(self):
super().__init__()
self.graph = OWScatterPlotBase(self)
self.xy = None, None
self.data = None

def get_coordinates_data(self):
return self.xy
Expand Down Expand Up @@ -167,11 +170,13 @@ def test_update_coordinates_and_density(self):
graph.update_coordinates()
graph.update_density.assert_called_with()

@unittest.skip("Reset graph does not call reset view anymore")
def test_update_coordinates_reset_view(self):
graph = self.graph
graph.view_box.setRange = self.setRange
xy = self.master.xy = (np.array([2, 1]), np.array([3, 10]))
self.master.get_label_data = lambda: np.array(["a", "b"])

graph.reset_graph()
self.assertEqual(self.last_setRange, [[1, 2], [3, 10]])

Expand All @@ -193,6 +198,7 @@ def test_update_coordinates_indices(self):
np.testing.assert_almost_equal(
graph.scatterplot_item.data["data"], [0, 1])

@unittest.skip("This sampling mechanism is different from what 'interactive' sampling will support")
def test_sampling(self):
graph = self.graph
master = self.master
Expand Down Expand Up @@ -1650,6 +1656,12 @@ def test_self_data(this, *_, **_1):
np.testing.assert_equal(y, np.arange(20, 25))


class TestOWScatterPlotBaseWithDask(TestOWScatterPlotBase):
def setUp(self):
super().setUp()
self.master.xy = (da.from_array(np.arange(10, dtype=float)),
da.from_array(np.arange(10, dtype=float)))


if __name__ == "__main__":
import unittest
unittest.main()

0 comments on commit 82c0a3c

Please sign in to comment.