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] Select Rows: None on output when no data #2726

Merged
merged 2 commits into from
Nov 10, 2017
Merged

[FIX] Select Rows: None on output when no data #2726

merged 2 commits into from
Nov 10, 2017

Conversation

jerneju
Copy link
Contributor

@jerneju jerneju commented Oct 30, 2017

Issue

Rank widget crashes because receives empty Table and empty Domain which is created by Select Rows.

Description of changes

Select Rows commits None.

Includes
  • Code changes
  • Tests
  • Documentation

@jerneju
Copy link
Contributor Author

jerneju commented Oct 30, 2017

@codecov-io
Copy link

codecov-io commented Oct 30, 2017

Codecov Report

Merging #2726 into master will increase coverage by 0.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #2726      +/-   ##
==========================================
+ Coverage   76.03%   76.04%   +0.01%     
==========================================
  Files         338      338              
  Lines       59628    59641      +13     
==========================================
+ Hits        45339    45356      +17     
+ Misses      14289    14285       -4

Copy link
Contributor

@janezd janezd left a comment

Choose a reason for hiding this comment

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

A comment for other potential reviewers: it is not clear what widget should output in this case. @jerneju proposed None and I agreed. It makes sense from the user perspective: with None, the canvas shows that the widgets hasn't output anything. Otherwise, the canvas indicates that the widget has output something ... but this something is empty, which is a confusing non-difference for the user.

None is also better technically since most widgets do not expect empty tables and, worse, empty domains on inputs. (This is not to say that a well-behaved widget should not crash if this happens.)

self.Outputs.matching_data.send(matching_output)
self.Outputs.unmatched_data.send(non_matching_output)
def output_filter(output):
return output if output is not None and len(output) else None
Copy link
Contributor

Choose a reason for hiding this comment

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

I here agree with @astaric's usual comment about my code. If-else expressions in Python are mostly unreadable. I'd prefer

if output is not None and len(output):
    return output

You don't even need return None here, but you may add it to make it explicit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, besides, I don't like the function at all. I'd prefer having

if not len(matching_output):
    matching_output = None

and the same for non_matching_output.

The same amount of code, but way more explicit.

@janezd
Copy link
Contributor

janezd commented Oct 31, 2017

I made the change. Another option is to allow empty tables, but not empty domains. In this case we don't call remover if not len(data).

@jerneju jerneju added this to the 3.8 milestone Nov 3, 2017
@janezd janezd merged commit ef8fccc into biolab:master Nov 10, 2017
@jerneju jerneju deleted the rank-value-max branch November 10, 2017 11:47
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.

3 participants