Skip to content

Commit acd5dc9

Browse files
authored
Merge pull request #3445 from VesnaT/fix_mosaic
[FIX] Mosaic: Always reset discrete_data
2 parents c3dc8d4 + 019f294 commit acd5dc9

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Orange/widgets/visualize/owmosaic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import numpy as np
88
from scipy.stats import distributions
9-
from scipy.misc import comb
9+
from scipy.special import comb
1010
from AnyQt.QtCore import Qt, QSize, pyqtSignal as Signal
1111
from AnyQt.QtGui import QColor, QPainter, QPen, QStandardItem
1212
from AnyQt.QtWidgets import QGraphicsScene, QGraphicsLineItem
@@ -457,7 +457,7 @@ def reset_graph(self):
457457
self.update_graph()
458458

459459
def set_color_data(self):
460-
if self.data is None or len(self.data) < 2:
460+
if self.data is None:
461461
return
462462
self.bar_button.setEnabled(self.variable_color is not None)
463463
attrs = [v for v in self.model_1 if v and v is not self.variable_color]
@@ -712,7 +712,7 @@ def line(x1, y1, x2, y2):
712712
(apriori_dists[i][used_vals[i]] / float(s)
713713
for i in range(len(used_vals))))
714714
actual = conditionaldict[attr_vals]
715-
pearson = (actual - expected) / sqrt(expected)
715+
pearson = float((actual - expected) / sqrt(expected))
716716
if pearson == 0:
717717
ind = 0
718718
else:

Orange/widgets/visualize/tests/test_owmosaic.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from Orange.widgets.visualize.owmosaic import OWMosaicDisplay
1616
from Orange.widgets.tests.utils import simulate
1717

18+
1819
class TestOWMosaicDisplay(WidgetTest, WidgetOutputsTestMixin):
1920
@classmethod
2021
def setUpClass(cls):
@@ -112,6 +113,22 @@ def test_different_number_of_attributes(self, canvas_rectangle):
112113
self.widget.update_graph()
113114
self.assertEqual(canvas_rectangle.call_count, 7 + 2 ** (i + 1))
114115

116+
def test_change_domain(self):
117+
"""Test for GH-3419 fix"""
118+
self.send_signal(self.widget.Inputs.data, self.data[:, :2])
119+
subset = self.data[:1, 2:3]
120+
self.send_signal(self.widget.Inputs.data, subset)
121+
output = self.get_output(self.widget.Outputs.annotated_data)
122+
np.testing.assert_array_equal(output.X, subset.X)
123+
124+
def test_subset(self):
125+
"""Test for GH-3416 fix"""
126+
self.send_signal(self.widget.Inputs.data, self.data)
127+
self.send_signal(self.widget.Inputs.data_subset, self.data[10:])
128+
self.send_signal(self.widget.Inputs.data, self.data[:1])
129+
output = self.get_output(self.widget.Outputs.annotated_data)
130+
np.testing.assert_array_equal(output.X, self.data[:1].X)
131+
115132

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

0 commit comments

Comments
 (0)