Skip to content

Commit 4e4756a

Browse files
committed
Update print methods to avoid using tabs
1 parent 5c7aa85 commit 4e4756a

File tree

9 files changed

+93
-58
lines changed

9 files changed

+93
-58
lines changed

lib/node_modules/@stdlib/stats/anova1/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ console.log( out.print() );
8484
Null Hypothesis: All Means Equal
8585
Alternate Hypothesis: At Least one Mean not Equal
8686
87-
df Sum Squares Mean Sum Sq. F Score P Value
88-
Treatment 3 15 5 0.3125 0.8161
89-
Errors 8 128 16
87+
df SS MSS F Score P Value
88+
Treatment 3 15 5 0.3125 0.8161
89+
Errors 8 128 16
9090
9191
Fail to Reject Null: 0.8161 >= 0.05
9292
*/
@@ -111,15 +111,15 @@ var table = out.print();
111111
Null Hypothesis: All Means Equal
112112
Alternate Hypothesis: At Least one Mean not Equal
113113
114-
df Sum Squares Mean Sum Sq. F Score P Value
115-
Treatment 2 3.75 1.875 0.1357 0.8754
116-
Errors 7 96.75 13.8214
114+
df SS MSS F Score P Value
115+
Treatment 3 15 5 0.3125 0.8161
116+
Errors 8 128 16
117117
118-
Fail to Reject Null: 0.8754 >= 0.05
118+
Fail to Reject Null: 0.8161 >= 0.05
119119
*/
120120

121121
out = anova1( x, y, {
122-
'alpha': 0.01
122+
'alpha': 0.9
123123
});
124124
table = out.print();
125125
/* e.g., returns
@@ -128,11 +128,11 @@ table = out.print();
128128
Null Hypothesis: All Means Equal
129129
Alternate Hypothesis: At Least one Mean not Equal
130130
131-
df Sum Squares Mean Sum Sq. F Score P Value
132-
Treatment 2 3.75 1.875 0.1357 0.8754
133-
Errors 7 96.75 13.8214
131+
df SS MSS F Score P Value
132+
Treatment 3 15 5 0.3125 0.8161
133+
Errors 8 128 16
134134
135-
Reject Null: 0.8754 <= 0.9
135+
Reject Null: 0.8161 <= 0.9
136136
*/
137137
```
138138

lib/node_modules/@stdlib/stats/anova1/lib/print.js

Lines changed: 59 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,28 @@
2323
var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' );
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2525
var roundn = require( '@stdlib/math/base/special/roundn' );
26+
var repeat = require( '@stdlib/string/repeat' );
27+
var max = require( '@stdlib/math/base/special/max' );
2628
var isBoolean = require( '@stdlib/assert/is-boolean' );
2729

2830

31+
// FUNCTIONS //
32+
33+
/**
34+
* Returns n spaces.
35+
*
36+
* @private
37+
* @param {integer} n - number of spaces
38+
* @returns {string} n spaces
39+
*/
40+
function spaces( n ) {
41+
if ( n <= 0 ) {
42+
return '';
43+
}
44+
return repeat( ' ', n );
45+
}
46+
47+
2948
// MAIN //
3049

3150
/**
@@ -49,6 +68,13 @@ function prettyPrint( results ) {
4968
*/
5069
function print( opts ) {
5170
var decision;
71+
var treatMSS;
72+
var treatSS;
73+
var errMSS;
74+
var extra1;
75+
var extra2;
76+
var errSS;
77+
var ndgts;
5278
var dgts;
5379
var str;
5480

@@ -68,7 +94,7 @@ function prettyPrint( results ) {
6894
decision = opts.decision;
6995
}
7096
}
71-
dgts = -dgts;
97+
ndgts = -dgts;
7298

7399
str = '';
74100
str += results.method;
@@ -80,52 +106,61 @@ function prettyPrint( results ) {
80106
str += 'Alternate Hypothesis: At Least one Mean not Equal';
81107
str += '\n\n';
82108

109+
treatSS = roundn( results.treatment.ss, ndgts ).toString();
110+
errSS = roundn( results.error.ss, ndgts ).toString();
111+
treatMSS = roundn( results.treatment.mss, ndgts ).toString();
112+
errMSS = roundn( results.error.mss, ndgts ).toString();
113+
114+
extra1 = max( max( treatSS.length, errSS.length ), 2 );
115+
extra2 = max( max( treatMSS.length, errMSS.length ), 3 );
116+
83117
// Formatted table
84-
str += '\t\t';
118+
str += ' ';
85119
str += 'df';
86-
str += '\t';
87-
str += 'Sum Squares';
88-
str += '\t';
89-
str += 'Mean Sum Sq.';
90-
str += '\t';
120+
str += spaces( 3 );
121+
str += 'SS';
122+
str += spaces( 2 + extra1 );
123+
str += 'MSS';
124+
str += spaces( extra2 );
91125
str += 'F Score';
92-
str += '\t';
126+
str += spaces( dgts - 1 );
93127
str += 'P Value';
94128
str += '\n';
95129

96130
// Now start adding in values
97131
str += 'Treatment';
98-
str += '\t';
132+
str += spaces( 5 );
99133
str += results.treatment.df;
100-
str += '\t';
101-
str += roundn( results.treatment.ss, dgts );
102-
str += '\t\t';
103-
str += roundn( results.treatment.mss, dgts );
104-
str += '\t\t';
105-
str += roundn( results.statistic, dgts );
106-
str += '\t';
107-
str += roundn( results.pValue, dgts );
134+
str += spaces( 4 );
135+
136+
str += treatSS;
137+
str += spaces( 4 + extra1 - treatSS.length );
138+
str += treatMSS;
139+
str += spaces( 3 + extra2 - treatMSS.length );
140+
str += roundn( results.statistic, ndgts );
141+
str += spaces( dgts );
142+
str += roundn( results.pValue, ndgts );
108143
str += '\n';
109144

110145
// Next line
111146
str += 'Errors';
112-
str += '\t\t';
147+
str += ' ';
113148
str += results.error.df;
114-
str += '\t';
115-
str += roundn( results.error.ss, dgts );
116-
str += '\t\t';
117-
str += roundn( results.error.mss, dgts );
149+
str += spaces( dgts );
150+
str += errSS;
151+
str += spaces( 4 + extra1 - errSS.length );
152+
str += errMSS;
118153

119154
if ( decision ) {
120155
str += '\n\n';
121156
if ( results.rejected ) {
122157
str += 'Reject Null: ';
123-
str += roundn( results.pValue, dgts );
158+
str += roundn( results.pValue, ndgts );
124159
str += ' <= ';
125160
str += results.alpha;
126161
} else {
127162
str += 'Fail to Reject Null: ';
128-
str += roundn( results.pValue, dgts );
163+
str += roundn( results.pValue, ndgts );
129164
str += ' >= ';
130165
str += results.alpha;
131166
}

lib/node_modules/@stdlib/stats/chi2gof/lib/print.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ function prettyPrint( results ) {
6767
str += '\n\n';
6868
str += 'Null hypothesis: population probabilities are equal to those in p';
6969
str += '\n\n';
70-
str += '\tpValue: ' + roundn( results.pValue, -dgts ) + '\n';
71-
str += '\tstatistic: ' + roundn( results.statistic, -dgts ) + '\n';
72-
str += '\tdegrees of freedom: ' + results.df + '\n';
70+
str += ' pValue: ' + roundn( results.pValue, -dgts ) + '\n';
71+
str += ' statistic: ' + roundn( results.statistic, -dgts ) + '\n';
72+
str += ' degrees of freedom: ' + results.df + '\n';
7373
str += '\n';
7474
str += 'Test Decision: ';
7575
if ( results.rejected ) {

lib/node_modules/@stdlib/stats/kstest/lib/print.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ function print( opts ) { // eslint-disable-line stdlib/no-redeclare
7171
}
7272
str += 'the reference CDF';
7373
str += '\n\n';
74-
str += '\tpValue: ' + roundn( this.pValue, -dgts ) + '\n';
75-
str += '\tstatistic: ' + roundn( this.statistic, -dgts );
74+
str += ' pValue: ' + roundn( this.pValue, -dgts ) + '\n';
75+
str += ' statistic: ' + roundn( this.statistic, -dgts );
7676
str += '\n\n';
7777
str += 'Test Decision: ';
7878
if ( this.rejected ) {

lib/node_modules/@stdlib/stats/pcorrtest/lib/print.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ function print( opts ) { // eslint-disable-line stdlib/no-redeclare
7171
}
7272
str += this.nullValue;
7373
str += '\n\n';
74-
str += '\tpValue: ' + roundn( this.pValue, -dgts ) + '\n';
75-
str += '\tstatistic: ' + roundn( this.statistic, -dgts ) + '\n';
76-
str += '\t' + ((1.0-this.alpha)*100) + '% confidence interval: [' +
74+
str += ' pValue: ' + roundn( this.pValue, -dgts ) + '\n';
75+
str += ' statistic: ' + roundn( this.statistic, -dgts ) + '\n';
76+
str += ' ' + ((1.0-this.alpha)*100) + '% confidence interval: [' +
7777
roundn( this.ci[0], -dgts ) +
7878
',' +
7979
roundn( this.ci[1], -dgts ) +

lib/node_modules/@stdlib/stats/ttest/lib/print.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ function print( opts ) { // eslint-disable-line stdlib/no-redeclare
7575
}
7676
str += this.nullValue;
7777
str += '\n\n';
78-
str += '\tpValue: ' + roundn( this.pValue, -dgts ) + '\n';
79-
str += '\tstatistic: ' + roundn( this.statistic, -dgts ) + '\n';
80-
str += '\tdf: ' + this.df + '\n';
81-
str += '\t' + ((1.0-this.alpha)*100) + '% confidence interval: [' +
78+
str += ' pValue: ' + roundn( this.pValue, -dgts ) + '\n';
79+
str += ' statistic: ' + roundn( this.statistic, -dgts ) + '\n';
80+
str += ' df: ' + this.df + '\n';
81+
str += ' ' + ((1.0-this.alpha)*100) + '% confidence interval: [' +
8282
roundn( this.ci[0], -dgts ) +
8383
',' +
8484
roundn( this.ci[1], -dgts ) +

lib/node_modules/@stdlib/stats/ttest2/lib/print.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ function print( opts ) { // eslint-disable-line stdlib/no-redeclare
7272
}
7373
str += this.nullValue;
7474
str += '\n\n';
75-
str += '\tpValue: ' + roundn( this.pValue, -dgts ) + '\n';
76-
str += '\tstatistic: ' + roundn( this.statistic, -dgts ) + '\n';
77-
str += '\tdf: ' + roundn( this.df, -dgts ) + '\n';
78-
str += '\t' + ((1.0-this.alpha)*100) + '% confidence interval: [' +
75+
str += ' pValue: ' + roundn( this.pValue, -dgts ) + '\n';
76+
str += ' statistic: ' + roundn( this.statistic, -dgts ) + '\n';
77+
str += ' df: ' + roundn( this.df, -dgts ) + '\n';
78+
str += ' ' + ((1.0-this.alpha)*100) + '% confidence interval: [' +
7979
roundn( this.ci[0], -dgts ) +
8080
',' +
8181
roundn( this.ci[1], -dgts ) +

lib/node_modules/@stdlib/stats/ztest/lib/print.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ function print( opts ) { // eslint-disable-line stdlib/no-redeclare
7171
}
7272
str += this.nullValue;
7373
str += '\n\n';
74-
str += '\tpValue: ' + roundn( this.pValue, -dgts ) + '\n';
75-
str += '\tstatistic: ' + roundn( this.statistic, -dgts ) + '\n';
76-
str += '\t' + ((1.0-this.alpha)*100) + '% confidence interval: [' +
74+
str += ' pValue: ' + roundn( this.pValue, -dgts ) + '\n';
75+
str += ' statistic: ' + roundn( this.statistic, -dgts ) + '\n';
76+
str += ' ' + ((1.0-this.alpha)*100) + '% confidence interval: [' +
7777
roundn( this.ci[0], -dgts ) +
7878
',' +
7979
roundn( this.ci[1], -dgts ) +

lib/node_modules/@stdlib/stats/ztest2/lib/print.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ function print( opts ) { // eslint-disable-line stdlib/no-redeclare
7272
}
7373
str += this.nullValue;
7474
str += '\n\n';
75-
str += '\tpValue: ' + roundn( this.pValue, -dgts ) + '\n';
76-
str += '\tstatistic: ' + roundn( this.statistic, -dgts ) + '\n';
77-
str += '\t' + ((1.0-this.alpha)*100) + '% confidence interval: [' +
75+
str += ' pValue: ' + roundn( this.pValue, -dgts ) + '\n';
76+
str += ' statistic: ' + roundn( this.statistic, -dgts ) + '\n';
77+
str += ' ' + ((1.0-this.alpha)*100) + '% confidence interval: [' +
7878
roundn( this.ci[0], -dgts ) +
7979
',' +
8080
roundn( this.ci[1], -dgts ) +

0 commit comments

Comments
 (0)