Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitad9a64f

Browse files
committed
OWSieve: cosmetic changes in Cochran rule testing; translations to Slovenian
1 parent71e1801 commitad9a64f

File tree

3 files changed

+36
-29
lines changed

3 files changed

+36
-29
lines changed

‎Orange/widgets/visualize/owsieve.py‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Outputs:
8585
graph_name="canvas"# QGraphicsScene
8686

8787
classWarning(OWWidget.Warning):
88-
cochran=Msg("Doesnot meet Cochran's rule\n{}")
88+
cochran=Msg("Data doesnot meet the Cochran's rule\n{}")
8989

9090
want_control_area=False
9191

@@ -108,10 +108,10 @@ def __init__(self):
108108
self.mainArea.layout().setSpacing(0)
109109
self.attr_box=gui.hBox(self.mainArea,margin=0)
110110
self.domain_model=DomainModel(valid_types=DomainModel.PRIMITIVE)
111-
combo_args={
112-
"widget":self.attr_box,"master":self,"contentsLength":12,
113-
"searchable":True,"sendSelectedValue":True,
114-
"callback":self.attr_changed,"model":self.domain_model}
111+
combo_args=dict(
112+
widget=self.attr_box,master=self,contentsLength=12,
113+
searchable=True,sendSelectedValue=True,
114+
callback=self.attr_changed,model=self.domain_model)
115115
fixed_size= (QSizePolicy.Fixed,QSizePolicy.Fixed)
116116
gui.comboBox(value="attr_x",**combo_args)
117117
gui.widgetLabel(self.attr_box,"\u2717",sizePolicy=fixed_size)
@@ -442,7 +442,7 @@ def _oper(attr, txt):
442442

443443
returnf"{xt}<br/>{yt}<hr/>{ct}"
444444

445-
445+
self.Warning.cochran.clear()
446446
foriteminself.canvas.items():
447447
self.canvas.removeItem(item)
448448
ifself.dataisNoneorlen(self.data)==0or \
@@ -520,27 +520,26 @@ def _oper(attr, txt):
520520
# Assume similar height for both lines
521521
text("N = "+fmt(chi.n),0,bottom-xl.boundingRect().height())
522522
msg=self._check_cochran(chi)
523-
ifmsgisNone:
524-
self.Warning.cochran.clear()
525-
else:
523+
ifmsgisnotNone:
526524
self.Warning.cochran(msg)
527525

528-
def_check_cochran(self,chi):
526+
@staticmethod
527+
def_check_cochran(chi):
529528
"""
530529
Check Cochran's rule.
531-
Return None if it is met, a string describing the problem.
530+
Return None if it is met,otherwisea string describing the problem.
532531
"""
533532
expected=np.asarray(chi.expected,dtype=float)
534-
cells=int(expected.size)
533+
cells=expected.size
535534
ifcells==0:
536535
return"no cells in contingency table"
537536
eps=1e-12
538-
num_lt1=int((expected<1.0-eps).sum())
539-
num_lt5=int((expected<5.0-eps).sum())
537+
num_lt1=(expected<1.0-eps).sum()
538+
num_lt5=(expected<5.0-eps).sum()
540539
ifnum_lt1>0:
541-
return"some expected frequencies< 1"
540+
return"some expected frequenciesare below 1"
542541
ifnum_lt5>0.2*cells:
543-
return"more than 20% of expected frequencies< 5"
542+
return"more than 20% of expected frequenciesare below 5"
544543
returnNone
545544

546545
defget_widget_name_extension(self):

‎Orange/widgets/visualize/tests/test_owsieve.py‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,28 +111,31 @@ def test_chisquare(self):
111111
self.assertFalse(isnan(chi.chisq))
112112

113113
deftest_cochran_messages(self):
114-
a=DiscreteVariable("A",values=("a1","a2","a3"))
115-
b=DiscreteVariable("B",values=("b1","b2","b3"))
114+
a=DiscreteVariable("A",values=("a1","a2","a3"))
115+
b=DiscreteVariable("B",values=("b1","b2","b3"))
116116

117117
# PASS: all expected frequencies >= 5 (20/20/20 × 20/20/20)
118-
rows_ok= ["a1"]*20+ ["a2"]*20+ ["a3"]*20
119-
cols_ok= ["b1"]*20+ ["b2"]*20+ ["b3"]*20
118+
rows_ok= ["a1"]*20+ ["a2"]*20+ ["a3"]*20
119+
cols_ok= ["b1"]*20+ ["b2"]*20+ ["b3"]*20
120120
table_ok=Table.from_list(Domain([a,b]),list(zip(rows_ok,cols_ok)))
121121
self.send_signal(self.widget.Inputs.data,table_ok)
122122
self.widget.attr_x,self.widget.attr_y=a,b
123123
self.widget.update_graph()
124-
assertnotself.widget.Warning.cochran.is_shown()
124+
self.assertFalse(self.widget.Warning.cochran.is_shown())
125125

126126
# FAIL: some expected frequencies < 5 (10/20/30 × 20/20/20)
127-
rows_bad= ["a1"]*10+ ["a2"]*20+ ["a3"]*30
128-
cols_bad= ["b1"]*20+ ["b2"]*20+ ["b3"]*20
127+
rows_bad= ["a1"]*10+ ["a2"]*20+ ["a3"]*30
128+
cols_bad= ["b1"]*20+ ["b2"]*20+ ["b3"]*20
129129
table_bad=Table.from_list(Domain([a,b]),list(zip(rows_bad,cols_bad)))
130130
self.send_signal(self.widget.Inputs.data,table_bad)
131131
self.widget.attr_x,self.widget.attr_y=a,b
132132
self.widget.update_graph()
133-
assertself.widget.Warning.cochran.is_shown()
133+
self.assertTrue(self.widget.Warning.cochran.is_shown())
134134
msg_text=str(self.widget.Warning.cochran)
135-
assert"expected"inmsg_text.lower()
135+
self.assertIn("expected",msg_text.lower())
136+
137+
self.send_signal(self.widget.Inputs.data,None)
138+
self.assertFalse(self.widget.Warning.cochran.is_shown())
136139

137140
deftest_metadata(self):
138141
"""
@@ -204,7 +207,6 @@ def test_input_features(self):
204207
# Attributes should now follow the provided features
205208
self.assertEqual((self.widget.attr_x,self.widget.attr_y), (a0,a1))
206209

207-
# Existing checks
208210
self.assertFalse(self.widget.attr_box.isEnabled())
209211
self.assertFalse(self.widget.vizrank_button().isEnabled())
210212

‎i18n/si/msgs.jaml‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ util.py:
196196
def `funcv`:
197197
unsafe: false
198198
version.py:
199-
3.39.0: false
200-
3.39.0.dev0+0a43fd4: false
201-
0a43fd438e4e20613c4d9899c1781f874d33d921: false
199+
3.40.0: false
200+
3.40.0.dev0+e599b5b: false
201+
e599b5bcc1999b32954f7a5693c9d7011fcabab7: false
202202
.dev: false
203203
canvas/__main__.py:
204204
ORANGE_STATISTICS_API_URL: false
@@ -14942,6 +14942,8 @@ widgets/visualize/owsieve.py:
1494214942
class `Outputs`:
1494314943
Selected Data: Izbrani podatki
1494414944
canvas: false
14945+
class `Warning`:
14946+
Data does not meet the Cochran's rule\n{}: Podatki ne ustrezajo Cochranovemu pravilu\n{}
1494514947
def `__init__`:
1494614948
attr_x: false
1494714949
\u2717: true
@@ -14980,6 +14982,10 @@ widgets/visualize/owsieve.py:
1498014982
Feature {} has no values: Spremenljivka {} nima znanih vrednosti.
1498114983
χ²={:.2f}, p={:.3f}: true
1498214984
'N = ': true
14985+
def `_check_cochran`:
14986+
no cells in contingency table: kontingenčna tabela nima celic
14987+
some expected frequencies are below 1: nekatere pričakovane pogostosti so manjše od 1
14988+
more than 20% of expected frequencies are below 5: več kot 20 % pričakovanih pogostosti je manjših od 5
1498314989
def `get_widget_name_extension`:
1498414990
{} vs {}: {} in {}
1498514991
__main__: false

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp