[FIX] Correspondence: Prevent crashing when cont attr has one value#2149
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2149 +/- ##
==========================================
+ Coverage 67.78% 67.83% +0.05%
==========================================
Files 319 319
Lines 54940 54962 +22
==========================================
+ Hits 37240 37284 +44
+ Misses 17700 17678 -22 |
| list(zip( | ||
| ["0", "0", "0"] | ||
| ))) | ||
| self.send_signal("Data", table) |
There was a problem hiding this comment.
Cool trick. You will get the same results with list(zip("000")).
However, [('0',)]*3 or simply [(0,), (0,), (0,)] or np.zeros((3, 1)) would be more reader-friendly.
| self.component_x, self.component_y = 0, 1 | ||
| self.component_x = 0 | ||
| self.component_y = 1 if \ | ||
| len(self.varlist[self.selected_var_indices[-1]].values) > 1 else 0 |
There was a problem hiding this comment.
You don't need len here.
(I'd actually write self.component_y = bool(self.varlist[self.selected_var_indices[-1]].values), but basically just to annoy @astaric. :)
There was a problem hiding this comment.
He does need len, because he wants to check if it is >1 and not >0.
It is also harder to annoy @astaric, but the if ... else is unnecessary, so:
self.component_y = len(self.varlist[self.selected_var_indices[-1]].values) > 1
or if someone is the strict type:
int(len(self.varlist[self.selected_var_indices[-1]].values) > 1)
lanzagar
left a comment
There was a problem hiding this comment.
I still get strange behaviour and crashes when data has a variable with a single value.
I used titanic and feature constructor to add a constant discrete var.
| F = numpy.c_[D_r] * U * D | ||
| G = numpy.c_[D_c] * V.T * D | ||
|
|
||
| if F.shape == (1, 1) and F == numpy.array([[0]]): |
There was a problem hiding this comment.
I had to read this twice... Why not if F.shape == (1, 1) and F[0, 0] == 0? Simpler and less work for all. Also, F[0, 0] = 1 below. Sorry for overlooking this before.
|
Fixed. |
|
Seems to be broken. |
Issue
Widget crashes on discrete attributes with only one value.
https://sentry.io/biolab/orange3/issues/243133261/
Description of changes
Check if there is a second value.
Includes