Skip to content

Commit

Permalink
Merge pull request #1972 from ales-erjavec/fixes/paint-nan-input
Browse files Browse the repository at this point in the history
[FIX] owpaintdata: Fix an error when the input dataset contains NaN
(cherry picked from commit ef56cfb)
  • Loading branch information
janezd authored and astaric committed Feb 3, 2017
1 parent de51706 commit b97746d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 3 additions & 5 deletions Orange/widgets/data/owpaintdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1226,18 +1226,16 @@ def pen(color):
self.plot.removeItem(self._scatter_item)
self._scatter_item = None

nclasses = len(self.class_model)
pens = [pen(self.colors[i]) for i in range(nclasses)]

x = self.__buffer[:, 0].copy()
if self.hasAttr2:
y = self.__buffer[:, 1].copy()
else:
y = np.zeros(self.__buffer.shape[0])
pen = [pens[ci] for ci in self.__buffer[:, 2].astype(int)]

colors = self.colors[self.__buffer[:, 2]]
pens = [pen(c) for c in colors]
self._scatter_item = pg.ScatterPlotItem(
x, y, symbol="+", pen=pen
x, y, symbol="+", pen=pens
)
self.plot.addItem(self._scatter_item)

Expand Down
6 changes: 5 additions & 1 deletion Orange/widgets/data/tests/test_owpaintdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from Orange.data import Table
from Orange.widgets.data import owpaintdata
from Orange.widgets.data.owpaintdata import OWPaintData
from Orange.widgets.tests.base import WidgetTest
from Orange.widgets.tests.base import WidgetTest, datasets


class TestOWPaintData(WidgetTest):
Expand All @@ -25,6 +25,10 @@ def test_empty_data(self):
self.send_signal("Data", data)
self.send_signal("Data", Table(data.domain))

def test_nan_data(self):
data = datasets.missing_data_2()
self.send_signal("Data", data)

def test_output_shares_internal_buffer(self):
data = Table("iris")[::5]
self.send_signal("Data", data)
Expand Down

0 comments on commit b97746d

Please sign in to comment.