Skip to content

Commit 6758462

Browse files
authored
Merge pull request #2314 from jerneju/value-schemeedit
[FIX] Paint Data: now stores data in list and not np.array
2 parents 9b8c25d + e9d4d62 commit 6758462

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Orange/widgets/data/owpaintdata.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,13 @@ def __init__(self):
798798
self.class_model.rowsRemoved.connect(self._class_count_changed)
799799

800800
if self.data is None:
801-
self.data = np.zeros((0, 3))
802-
self.__buffer = self.data.copy()
801+
self.data = []
802+
self.__buffer = np.zeros((0, 3))
803+
elif isinstance(self.data, np.ndarray):
804+
self.__buffer = self.data.copy()
805+
self.data = self.data.tolist()
806+
else:
807+
self.__buffer = np.array(self.data)
803808

804809
self.colors = colorpalette.ColorPaletteGenerator(
805810
len(colorpalette.DefaultRGBColors))
@@ -1033,8 +1038,8 @@ def reset_to_input(self):
10331038
newindex = min(max(index, 0), len(self.class_model) - 1)
10341039
itemmodels.select_row(self.classValuesView, newindex)
10351040

1036-
self.data = self.input_data
1037-
self.__buffer = self.data.copy()
1041+
self.data = self.input_data.tolist()
1042+
self.__buffer = self.input_data.copy()
10381043

10391044
prev_attr2 = self.hasAttr2
10401045
self.hasAttr2 = self.input_has_attr2
@@ -1237,19 +1242,20 @@ def _attr_name_changed(self):
12371242
self.invalidate()
12381243

12391244
def invalidate(self):
1240-
self.data = self.__buffer.copy()
1245+
self.data = self.__buffer.tolist()
12411246
self.commit()
12421247

12431248
def commit(self):
1244-
if len(self.data) == 0:
1249+
data = np.array(self.data)
1250+
if len(data) == 0:
12451251
self.send("Data", None)
12461252
return
12471253
if self.hasAttr2:
1248-
X, Y = self.data[:, :2], self.data[:, 2]
1254+
X, Y = data[:, :2], data[:, 2]
12491255
attrs = (Orange.data.ContinuousVariable(self.attr1),
12501256
Orange.data.ContinuousVariable(self.attr2))
12511257
else:
1252-
X, Y = self.data[:, np.newaxis, 0], self.data[:, 2]
1258+
X, Y = data[:, np.newaxis, 0], data[:, 2]
12531259
attrs = (Orange.data.ContinuousVariable(self.attr1),)
12541260
if len(np.unique(Y)) >= 2:
12551261
domain = Orange.data.Domain(

0 commit comments

Comments
 (0)