Skip to content

Commit

Permalink
Merge pull request #2039 from jerneju/pickleerror-owfile
Browse files Browse the repository at this point in the history
[FIX] Prevent PickleError (owfile.py)
  • Loading branch information
lanzagar authored Feb 22, 2017
2 parents 4a22791 + 4addff6 commit 9c8241c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
3 changes: 1 addition & 2 deletions Orange/widgets/data/owfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import numpy as np
from AnyQt.QtWidgets import \
QStyle, QComboBox, QMessageBox, QFileDialog, QGridLayout, QLabel, \
QLineEdit
from AnyQt.QtWidgets import QSizePolicy as Policy
QLineEdit, QSizePolicy as Policy
from AnyQt.QtCore import Qt, QTimer, QSize

from Orange.canvas.gui.utils import OSX_NSURL_toLocalFile
Expand Down
12 changes: 12 additions & 0 deletions Orange/widgets/data/tests/test_owfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,15 @@ def test_file_not_found(self):
# Open a sample dataset
self.open_dataset("iris")
self.assertFalse(self.widget.Error.file_not_found.is_shown())

def test_check_column_noname(self):
"""
GH-2018
"""
self.open_dataset("iris")
idx = self.widget.domain_editor.model().createIndex(1, 0)
temp = self.widget.domain_editor.model().data(idx, Qt.DisplayRole)
self.widget.domain_editor.model().setData(idx, " ", Qt.EditRole)
self.assertEqual(self.widget.domain_editor.model().data(idx, Qt.DisplayRole), temp)
self.widget.domain_editor.model().setData(idx, "", Qt.EditRole)
self.assertEqual(self.widget.domain_editor.model().data(idx, Qt.DisplayRole), temp)
13 changes: 7 additions & 6 deletions Orange/widgets/utils/domaineditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def setData(self, index, value, role):
row, col = index.row(), index.column()
row_data = self.variables[row]
if role == Qt.EditRole:
if col == Column.name:
if col == Column.name and not (value.isspace() or value == ""):
row_data[col] = value
elif col == Column.tpe:
vartype = self.name2type[value]
Expand Down Expand Up @@ -125,7 +125,7 @@ def showPopup(self, *args):
def hidePopup(me):
if me.popup_shown:
self.view.model().setData(
index, me.highlighted_text, Qt.EditRole)
index, me.highlighted_text, Qt.EditRole)
self.popup_shown = False
super().hidePopup()
self.view.closeEditor(me, self.NoHint)
Expand Down Expand Up @@ -211,9 +211,9 @@ def is_missing(x):

for (name, tpe, place, _, _), (orig_var, orig_plc) in \
zip(variables,
chain([(at, Place.feature) for at in domain.attributes],
[(cl, Place.class_var) for cl in domain.class_vars],
[(mt, Place.meta) for mt in domain.metas])):
chain([(at, Place.feature) for at in domain.attributes],
[(cl, Place.class_var) for cl in domain.class_vars],
[(mt, Place.meta) for mt in domain.metas])):
if place == Place.skip:
continue
if orig_plc == Place.meta:
Expand Down Expand Up @@ -277,7 +277,8 @@ def may_be_numeric(var):
return False

def discrete_value_display(value_list):
result = ", ".join(str(v) for v in value_list[:VarTableModel.DISCRETE_VALUE_DISPLAY_LIMIT])
result = ", ".join(str(v)
for v in value_list[:VarTableModel.DISCRETE_VALUE_DISPLAY_LIMIT])
if len(value_list) > VarTableModel.DISCRETE_VALUE_DISPLAY_LIMIT:
result += ", ..."
return result
Expand Down

0 comments on commit 9c8241c

Please sign in to comment.