Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] owfile: Prevent setting empty feature names #2039

Merged
merged 1 commit into from
Feb 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the additional indent here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PYLINT demands some additional spaces.

[(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