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

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

merged 1 commit into from
Feb 22, 2017

Conversation

jerneju
Copy link
Contributor

@jerneju jerneju commented Feb 21, 2017

Issue

PickleError thrown if a column does not have a name.

Description of changes

Column name cannot be changed to an empty string or a string with whitespaces.

Includes
  • Code changes
  • Tests
  • Documentation

@astaric
Copy link
Member

astaric commented Feb 21, 2017

Could you give me the steps to reproduce this issue?

@jerneju
Copy link
Contributor Author

jerneju commented Feb 21, 2017

Put File and Scatter Plot widget and then connect them. Then open some data and delete a column name. Click Apply button and close the window and then the application. You do not need to save your work. The Pickle Error should pop up.

@jerneju
Copy link
Contributor Author

jerneju commented Feb 21, 2017

@BlazZupan suggested a better way to solve this problem. That is preventing a user to even write a blank column name (string with zero length or only with white spaces). I am now doing some changes in file domaineditor.py.

@lanzagar
Copy link
Contributor

lanzagar commented Feb 21, 2017

As it is, this warning should be an error and not allow the user to proceed.
But I think it is better to not burden the user with this at all. If there are columns with empty names in a file, orange could auto-set the names to Feature 1, Feature 2, ...
Also to be more certain we avoid later problems, name should be a required argument in Variable's constructor, which should also check that it is non-empty.

EDIT: I was a couple of minutes too late and didn't see the previous reply - I agree with @BlazZupan's comment (+ the above still holds)

@codecov-io
Copy link

codecov-io commented Feb 21, 2017

Codecov Report

Merging #2039 into master will increase coverage by 0.01%.
The diff coverage is 90.9%.

@@            Coverage Diff             @@
##           master    #2039      +/-   ##
==========================================
+ Coverage    70.7%   70.72%   +0.01%     
==========================================
  Files         343      343              
  Lines       54478    54486       +8     
==========================================
+ Hits        38519    38533      +14     
+ Misses      15959    15953       -6

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4a22791...4addff6. Read the comment docs.

@jerneju
Copy link
Contributor Author

jerneju commented Feb 21, 2017

@lanzagar: Orange already auto-set the empty names to Feature 1, Feature 2, etc. if there are such columns in a file.

@jerneju
Copy link
Contributor Author

jerneju commented Feb 21, 2017

@jerneju
Copy link
Contributor Author

jerneju commented Feb 21, 2017

@jerneju
Copy link
Contributor Author

jerneju commented Feb 21, 2017

@@ -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):
'''
Copy link
Contributor

Choose a reason for hiding this comment

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

Docstrings: ''' -> """

@@ -80,7 +80,8 @@ def setData(self, index, value, role):
row_data = self.variables[row]
if role == Qt.EditRole:
if col == Column.name:
row_data[col] = value
if not (value.isspace() or value == ""):
Copy link
Contributor

Choose a reason for hiding this comment

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

This results in the above if col == Column.name succeeding and then the inside if doing nothing for empty values. But the function still returns True in the end.
Instead, using if col == Column.name and not (value.isspace() or value == "") would result either in the value being updated or nothing happens and function returns False. Which means that after an "incorrect" edit the Apply button does not become enabled (same as cancelling the edit with Esc).

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.

PickleError thrown if a column does not have a name.

Column name cannot be changed to an empty string or a string with whitespaces.
@lanzagar lanzagar merged commit 9c8241c into biolab:master Feb 22, 2017
@lanzagar lanzagar changed the title [FIX] Prevent PickleError (owfile.py) [FIX] owfile: Prevent setting empty feature names Feb 22, 2017
@jerneju jerneju deleted the pickleerror-owfile branch April 20, 2017 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants