Skip to content

Commit cc09c3f

Browse files
author
minjk-bl
committed
Edit ANOVA to show install button instead of force-insert install codes
1 parent 0796673 commit cc09c3f

File tree

2 files changed

+53
-22
lines changed

2 files changed

+53
-22
lines changed

visualpython/html/m_stats/anova.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
<div class="vp-st-option one-way two-way vp-grid-col-130">
5151
<label for="sigLevel" class="vp-orange-text">Significance level</label>
5252
<input type="number" id="sigLevel" class="vp-state vp-input" required/>
53-
<label for="covariate" class="vp-orange-text">Post hoc analysis</label>
54-
<div class="vp-grid-col-rp3">
53+
<label for="tukeyHSD" class="vp-orange-text">Post hoc analysis</label>
54+
<div class="vp-grid-col-rp3 vp-st-posthoc-box">
5555
<label><input type="checkbox" id="tukeyHSD" class="vp-state" checked><span>Tukey HSD</span></label>
5656
<label><input type="checkbox" id="tukey" class="vp-state"><span>Tukey</span></label>
5757
<span></span>

visualpython/js/m_stats/Anova.js

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ define([
6060

6161
this.columnBindList = ['depVar', 'factor', 'factorA', 'factorB', 'covariate'];
6262

63+
this.tmpInstallCode = []; // install codes
64+
6365
this.subsetEditor = {};
6466
}
6567

@@ -74,6 +76,29 @@ define([
7476

7577
$(that.wrapSelector('.vp-st-option')).hide();
7678
$(that.wrapSelector('.vp-st-option.' + testType)).show();
79+
80+
that.tmpInstallCode = [];
81+
that.hideInstallButton();
82+
83+
if (testType === 'one-way' || testType === 'two-way') {
84+
if (that.state.tukey || that.state.scheffe || that.state.duncan) {
85+
// Add installation code
86+
if (vpConfig.extensionType === 'lite') {
87+
that.tmpInstallCode = ["%pip install scikit-posthocs"];
88+
} else {
89+
that.tmpInstallCode = ["!pip install scikit-posthocs"];
90+
}
91+
that.showInstallButton();
92+
}
93+
} else if (testType === 'ancova') {
94+
// Add installation code : # pip install pingouin
95+
if (vpConfig.extensionType === 'lite') {
96+
that.tmpInstallCode = ["%pip install pingouin"];
97+
} else {
98+
that.tmpInstallCode = ["!pip install pingouin"];
99+
}
100+
that.showInstallButton();
101+
}
77102
});
78103

79104
$(this.wrapSelector('#data')).on('change', function() {
@@ -91,6 +116,28 @@ define([
91116
com_generator.vp_bindColumnSource(that, 'data', that.columnBindList, 'select', false, false);
92117
}
93118
});
119+
120+
$(this.wrapSelector('.vp-st-posthoc-box .vp-state')).on('change', function() {
121+
let id = $(this)[0].id;
122+
let checked = $(this).prop('checked') === true;
123+
that.state[id] = checked;
124+
let { testType, tukey, scheffe, duncan } = that.state;
125+
if (testType === 'one-way' || testType === 'two-way') {
126+
if (tukey || scheffe || duncan) {
127+
// Add installation code
128+
if (vpConfig.extensionType === 'lite') {
129+
that.tmpInstallCode = ["%pip install scikit-posthocs"];
130+
} else {
131+
that.tmpInstallCode = ["!pip install scikit-posthocs"];
132+
}
133+
that.showInstallButton();
134+
} else {
135+
that.hideInstallButton();
136+
}
137+
}
138+
});
139+
140+
$(this.wrapSelector(''))
94141
}
95142

96143
templateForBody() {
@@ -147,6 +194,10 @@ define([
147194
$(this.wrapSelector('.vp-st-option.' + this.state.testType)).show();
148195
}
149196

197+
generateInstallCode() {
198+
return this.tmpInstallCode;
199+
}
200+
150201
generateCode() {
151202
let {
152203
testType, data, depVar, factor, factorA, factorB, covariate, sigLevel,
@@ -253,12 +304,6 @@ define([
253304
}
254305

255306
if (tukey === true || scheffe === true || duncan === true) {
256-
if (vpConfig.extensionType === 'lite') {
257-
codeList.push("%pip install scikit-posthocs");
258-
} else {
259-
codeList.push("!pip install scikit-posthocs");
260-
}
261-
262307
// Post hoc analysis - Tukey
263308
if (tukey === true) {
264309
code.appendLine();
@@ -383,13 +428,6 @@ define([
383428
code.append("display(_res[0])");
384429
}
385430
if (tukey === true || scheffe === true || duncan === true) {
386-
// Add installation code
387-
if (vpConfig.extensionType === 'lite') {
388-
codeList.push("%pip install scikit-posthocs");
389-
} else {
390-
codeList.push("!pip install scikit-posthocs");
391-
}
392-
393431
// Post hoc analysis - Tukey
394432
if (tukey === true) {
395433
code.appendLine();
@@ -453,13 +491,6 @@ define([
453491
code.append(" plt.show()");
454492
}
455493

456-
// Add installation code : # pip install pingouin
457-
if (vpConfig.extensionType === 'lite') {
458-
codeList.push("%pip install pingouin");
459-
} else {
460-
codeList.push("!pip install pingouin");
461-
}
462-
463494
code.appendLine();
464495
code.appendLine();
465496
code.appendLine("# ANCOVA - Analysis of covariance");

0 commit comments

Comments
 (0)