Skip to content

Commit

Permalink
Merge pull request #3445 from VesnaT/fix_mosaic
Browse files Browse the repository at this point in the history
[FIX] Mosaic: Always reset discrete_data
  • Loading branch information
janezd authored Dec 6, 2018
2 parents c3dc8d4 + 019f294 commit acd5dc9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Orange/widgets/visualize/owmosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np
from scipy.stats import distributions
from scipy.misc import comb
from scipy.special import comb
from AnyQt.QtCore import Qt, QSize, pyqtSignal as Signal
from AnyQt.QtGui import QColor, QPainter, QPen, QStandardItem
from AnyQt.QtWidgets import QGraphicsScene, QGraphicsLineItem
Expand Down Expand Up @@ -457,7 +457,7 @@ def reset_graph(self):
self.update_graph()

def set_color_data(self):
if self.data is None or len(self.data) < 2:
if self.data is None:
return
self.bar_button.setEnabled(self.variable_color is not None)
attrs = [v for v in self.model_1 if v and v is not self.variable_color]
Expand Down Expand Up @@ -712,7 +712,7 @@ def line(x1, y1, x2, y2):
(apriori_dists[i][used_vals[i]] / float(s)
for i in range(len(used_vals))))
actual = conditionaldict[attr_vals]
pearson = (actual - expected) / sqrt(expected)
pearson = float((actual - expected) / sqrt(expected))
if pearson == 0:
ind = 0
else:
Expand Down
17 changes: 17 additions & 0 deletions Orange/widgets/visualize/tests/test_owmosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from Orange.widgets.visualize.owmosaic import OWMosaicDisplay
from Orange.widgets.tests.utils import simulate


class TestOWMosaicDisplay(WidgetTest, WidgetOutputsTestMixin):
@classmethod
def setUpClass(cls):
Expand Down Expand Up @@ -112,6 +113,22 @@ def test_different_number_of_attributes(self, canvas_rectangle):
self.widget.update_graph()
self.assertEqual(canvas_rectangle.call_count, 7 + 2 ** (i + 1))

def test_change_domain(self):
"""Test for GH-3419 fix"""
self.send_signal(self.widget.Inputs.data, self.data[:, :2])
subset = self.data[:1, 2:3]
self.send_signal(self.widget.Inputs.data, subset)
output = self.get_output(self.widget.Outputs.annotated_data)
np.testing.assert_array_equal(output.X, subset.X)

def test_subset(self):
"""Test for GH-3416 fix"""
self.send_signal(self.widget.Inputs.data, self.data)
self.send_signal(self.widget.Inputs.data_subset, self.data[10:])
self.send_signal(self.widget.Inputs.data, self.data[:1])
output = self.get_output(self.widget.Outputs.annotated_data)
np.testing.assert_array_equal(output.X, self.data[:1].X)


# Derive from WidgetTest to simplify creation of the Mosaic widget, although
# we are actually testing the MosaicVizRank dialog and not the widget
Expand Down

0 comments on commit acd5dc9

Please sign in to comment.