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] OWSieve: Fix crash for attribute with no values #1934

Merged
merged 2 commits into from
Jan 20, 2017

Conversation

VesnaT
Copy link
Contributor

@VesnaT VesnaT commented Jan 19, 2017

Issue

Fixes #1921

Description of changes

If any of chosen attributes has no values, show only another's values and a label "No data".

Includes
  • Code changes
  • Tests
  • Documentation

attr1 = data.domain[attr1]
attr2 = data.domain[attr2]
if attr1.is_discrete and not attr1.values or \
attr2.is_discrete and not data.domain[attr2].values:
Copy link
Contributor

Choose a reason for hiding this comment

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

Unlike attr1, attr2 is again mapped through data.domain.
Also indentation?

data.domain.index(attr1))[0], return_counts=True)[1]
self.probs_x = observed_x / self.n
self.observed = observed_x
if attr2.values:
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to use elif to make it clearer only one of these ifs can get executed.

@codecov-io
Copy link

codecov-io commented Jan 19, 2017

Current coverage is 89.30% (diff: 100%)

Merging #1934 into master will not change coverage

@@             master      #1934   diff @@
==========================================
  Files            86         86          
  Lines          9120       9120          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits           8145       8145          
  Misses          975        975          
  Partials          0          0          

Sunburst

Powered by Codecov. Last update 5ff92a9...c023d0d

text_ = "Features {} and {} have no values".format(disc_x, disc_y) \
if not disc_x.values and not disc_y.values and \
disc_x != disc_y else "Feature {} has no values".format(
disc_x if not disc_x.values else disc_y)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use a normal if statement, not expression? I guess it would be so much easier to read. Refuse if you disagree.

@janezd janezd merged commit 022b5d7 into biolab:master Jan 20, 2017
@astaric astaric added this to the 3.3.11 milestone Jan 20, 2017
astaric pushed a commit that referenced this pull request Feb 3, 2017
[FIX] OWSieve: Fix crash for attribute with no values
(cherry picked from commit 022b5d7)
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.

5 participants