Skip to content

Commit dce5ea9

Browse files
authored
Merge pull request #3602 from thocevar/sieve-tooltip
[FIX] OWSieve: Fix operators in tooltips
2 parents a05809c + 202958c commit dce5ea9

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

Orange/widgets/visualize/owsieve.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -401,34 +401,30 @@ def make_tooltip():
401401
the enclosing scope."""
402402
# pylint: disable=undefined-loop-variable
403403
def _oper(attr, txt):
404-
if self.data.domain[attr.name] is ddomain[attr.name]:
405-
return "="
404+
if self.data.domain[attr.name] == ddomain[attr.name]:
405+
return " = "
406406
return " " if txt[0] in "<≥" else " in "
407407

408-
return (
409-
"<b>{attr_x}{xeq}{xval_name}</b>: {obs_x}/{n} ({p_x:.0f} %)".
410-
format(attr_x=to_html(attr_x.name),
411-
xeq=_oper(attr_x, xval_name),
412-
xval_name=to_html(xval_name),
413-
obs_x=fmt(chi.probs_x[x] * n),
414-
n=int(n),
415-
p_x=100 * chi.probs_x[x]) +
416-
"<br/>" +
417-
"<b>{attr_y}{yeq}{yval_name}</b>: {obs_y}/{n} ({p_y:.0f} %)".
418-
format(attr_y=to_html(attr_y.name),
419-
yeq=_oper(attr_y, yval_name),
420-
yval_name=to_html(yval_name),
421-
obs_y=fmt(chi.probs_y[y] * n),
422-
n=int(n),
423-
p_y=100 * chi.probs_y[y]) +
424-
"<hr/>" +
425-
"""<b>combination of values: </b><br/>
408+
xt, yt = ["<b>{attr}{eq}{val_name}</b>: {obs}/{n} ({p:.0f} %)".format(
409+
attr=to_html(attr.name),
410+
eq=_oper(attr, val_name),
411+
val_name=to_html(val_name),
412+
obs=fmt(prob * n),
413+
n=int(n),
414+
p=100 * prob)
415+
for attr, val_name, prob in [(attr_x, xval_name, chi.probs_x[x]),
416+
(attr_y, yval_name, chi.probs_y[y])]]
417+
418+
ct = """<b>combination of values: </b><br/>
426419
&nbsp;&nbsp;&nbsp;expected {exp} ({p_exp:.0f} %)<br/>
427-
&nbsp;&nbsp;&nbsp;observed {obs} ({p_obs:.0f} %)""".
428-
format(exp=fmt(chi.expected[y, x]),
420+
&nbsp;&nbsp;&nbsp;observed {obs} ({p_obs:.0f} %)""".format(
421+
exp=fmt(chi.expected[y, x]),
429422
p_exp=100 * chi.expected[y, x] / n,
430423
obs=fmt(chi.observed[y, x]),
431-
p_obs=100 * chi.observed[y, x] / n))
424+
p_obs=100 * chi.observed[y, x] / n)
425+
426+
return f"{xt}<br/>{yt}<hr/>{ct}"
427+
432428

433429
for item in self.canvas.items():
434430
self.canvas.removeItem(item)

0 commit comments

Comments
 (0)