Skip to content

Commit 8808eb0

Browse files
committed
chore: modernize examples and benchmarks
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: skipped - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent d8ccb19 commit 8808eb0

14 files changed

Lines changed: 84 additions & 114 deletions

File tree

lib/node_modules/@stdlib/stats/base/ndarray/ztest/README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ var Float64Results = require( '@stdlib/stats/base/ztest/one-sample/results/float
5151
var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' );
5252
var structFactory = require( '@stdlib/array/struct-factory' );
5353
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
54+
var vector = require( '@stdlib/ndarray/vector/ctor' );
5455
var ndarray = require( '@stdlib/ndarray/ctor' );
5556

5657
var opts = {
5758
'dtype': 'generic'
5859
};
59-
var xbuf = [ 1.0, 3.0, 4.0, 2.0 ];
60-
var x = new ndarray( opts.dtype, xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
60+
var x = vector( [ 1.0, 3.0, 4.0, 2.0 ], 'generic' );
6161

6262
var alt = scalar2ndarray( resolveEnum( 'two-sided' ), {
6363
'dtype': 'int8'
@@ -77,14 +77,14 @@ var bool = ( v === out );
7777

7878
The function has the following parameters:
7979

80-
- **arrays**: array-like object containing the following ndarrays in order:
80+
- **arrays**: array-like object containing the following ndarrays:
8181

82-
1. a one-dimensional input ndarray.
83-
2. a zero-dimensional output ndarray containing a [results object][@stdlib/stats/base/ztest/one-sample/results/float64].
84-
3. a zero-dimensional ndarray specifying the alternative hypothesis.
85-
4. a zero-dimensional ndarray specifying the significance level.
86-
5. a zero-dimensional ndarray specifying the mean under the null hypothesis.
87-
6. a zero-dimensional ndarray specifying the known standard deviation.
82+
- a one-dimensional input ndarray.
83+
- a zero-dimensional output ndarray containing a [results object][@stdlib/stats/base/ztest/one-sample/results/float64].
84+
- a zero-dimensional ndarray specifying the alternative hypothesis.
85+
- a zero-dimensional ndarray specifying the significance level.
86+
- a zero-dimensional ndarray specifying the mean under the null hypothesis.
87+
- a zero-dimensional ndarray specifying the known standard deviation.
8888

8989
</section>
9090

@@ -110,7 +110,7 @@ The function has the following parameters:
110110
var Float64Results = require( '@stdlib/stats/base/ztest/one-sample/results/float64' );
111111
var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' );
112112
var structFactory = require( '@stdlib/array/struct-factory' );
113-
var normal = require( '@stdlib/random/array/normal' );
113+
var normal = require( '@stdlib/random/normal' );
114114
var ndarray = require( '@stdlib/ndarray/ctor' );
115115
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
116116
var ndarray2array = require( '@stdlib/ndarray/to-array' );
@@ -121,8 +121,7 @@ var opts = {
121121
};
122122

123123
// Create a one-dimensional ndarray containing pseudorandom numbers drawn from a normal distribution:
124-
var xbuf = normal( 100, 0.0, 1.0, opts );
125-
var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
124+
var x = normal( [ 100 ], 0.0, 1.0, opts );
126125
console.log( ndarray2array( x ) );
127126

128127
// Specify the alternative hypothesis:

lib/node_modules/@stdlib/stats/base/ndarray/ztest/benchmark/benchmark.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var normal = require( '@stdlib/random/array/normal' );
24+
var normal = require( '@stdlib/random/normal' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var pow = require( '@stdlib/math/base/special/pow' );
27-
var ndarray = require( '@stdlib/ndarray/base/ctor' );
28-
var scalar2ndarray = require( '@stdlib/ndarray/base/from-scalar' );
27+
var ndarray = require( '@stdlib/ndarray/ctor' );
28+
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
2929
var Float64Results = require( '@stdlib/stats/base/ztest/one-sample/results/float64' );
3030
var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' );
3131
var structFactory = require( '@stdlib/array/struct-factory' );
@@ -54,23 +54,23 @@ var ResultsArray = structFactory( Float64Results );
5454
function createBenchmark( len ) {
5555
var alpha;
5656
var sigma;
57-
var xbuf;
5857
var obuf;
5958
var out;
6059
var alt;
6160
var mu;
6261
var x;
6362

64-
xbuf = normal( len, 0.0, 1.0, options );
65-
x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' );
63+
x = normal( [ len ], 0.0, 1.0, options );
6664

6765
obuf = new ResultsArray( 1 );
6866
out = new ndarray( Float64Results, obuf, [], [ 0 ], 0, 'row-major' );
6967

70-
alt = scalar2ndarray( resolveEnum( 'two-sided' ), 'int8', 'row-major' );
71-
alpha = scalar2ndarray( 0.05, options.dtype, 'row-major' );
72-
mu = scalar2ndarray( 0.0, options.dtype, 'row-major' );
73-
sigma = scalar2ndarray( 1.0, options.dtype, 'row-major' );
68+
alt = scalar2ndarray( resolveEnum( 'two-sided' ), {
69+
'dtype': 'int8'
70+
});
71+
alpha = scalar2ndarray( 0.05, options );
72+
mu = scalar2ndarray( 0.0, options );
73+
sigma = scalar2ndarray( 1.0, options );
7474

7575
return benchmark;
7676

lib/node_modules/@stdlib/stats/base/ndarray/ztest/docs/repl.txt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Parameters
66
----------
77
arrays: ArrayLikeObject<ndarray>
8-
Array-like object containing the following ndarrays in order:
8+
Array-like object containing the following ndarrays:
99

1010
- a one-dimensional input ndarray.
1111
- a zero-dimensional output ndarray containing a results object.
@@ -23,25 +23,19 @@
2323
Examples
2424
--------
2525
// Create the input ndarray:
26-
> var xbuf = [ 1.0, -2.0, 2.0 ];
27-
> var dt = 'generic';
28-
> var sh = [ xbuf.length ];
29-
> var sx = [ 1 ];
30-
> var ox = 0;
31-
> var ord = 'row-major';
32-
> var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord );
26+
> var x = {{alias:@stdlib/ndarray/vector/ctor}}( [ 1.0, -2.0, 2.0 ], 'generic' );
3327

3428
// Create the output ndarray:
3529
> var S = {{alias:@stdlib/stats/base/ztest/one-sample/results/float64}};
3630
> var Results = {{alias:@stdlib/array/struct-factory}}( S );
3731
> var obuf = new Results( 1 );
38-
> var out = new {{alias:@stdlib/ndarray/ctor}}( S, obuf, [], [ 0 ], 0, ord );
32+
> var out = new {{alias:@stdlib/ndarray/ctor}}( S, obuf, [], [ 0 ], 0, 'row-major' );
3933

4034
// Specify the alternative hypothesis:
4135
> var alt = {{alias:@stdlib/ndarray/from-scalar}}( 'two-sided' );
4236

4337
// Specify the significance level:
44-
> var opts = { 'dtype': dt };
38+
> var opts = { 'dtype': 'generic' };
4539
> var alpha = {{alias:@stdlib/ndarray/from-scalar}}( 0.05, opts );
4640

4741
// Specify the mean under the null hypothesis:

lib/node_modules/@stdlib/stats/base/ndarray/ztest/docs/types/index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { typedndarray, ndarray } from '@stdlib/types/ndarray';
2727
*
2828
* ## Notes
2929
*
30-
* - The function expects the following ndarrays in order:
30+
* - The function expects the following ndarrays:
3131
*
3232
* - a one-dimensional input ndarray.
3333
* - a zero-dimensional output ndarray containing a results object.
@@ -44,15 +44,15 @@ import { typedndarray, ndarray } from '@stdlib/types/ndarray';
4444
* var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' );
4545
* var structFactory = require( '@stdlib/array/struct-factory' );
4646
* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
47+
* var vector = require( '@stdlib/ndarray/vector/ctor' );
4748
* var ndarray = require( '@stdlib/ndarray/ctor' );
4849
*
4950
* var opts = {
5051
* 'dtype': 'generic'
5152
* };
5253
*
5354
* // Define a one-dimensional input ndarray:
54-
* var xbuf = [ 1.0, 3.0, 4.0, 2.0 ];
55-
* var x = new ndarray( opts.dtype, xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
55+
* var x = vector( [ 1.0, 3.0, 4.0, 2.0 ], 'generic' );
5656
*
5757
* // Specify the alternative hypothesis:
5858
* var alt = scalar2ndarray( resolveEnum( 'two-sided' ), {
@@ -78,7 +78,7 @@ import { typedndarray, ndarray } from '@stdlib/types/ndarray';
7878
*
7979
* console.log( v.get().toString() );
8080
*/
81-
declare function ztest<T extends typedndarray<number>, U extends ndarray>( arrays: [ T, U, T, T, T, T ] ): U;
81+
declare function ztest<T extends ndarray>( arrays: [ typedndarray<number>, T, typedndarray<number>, typedndarray<number>, typedndarray<number>, typedndarray<number> ] ): T;
8282

8383

8484
// EXPORTS //

lib/node_modules/@stdlib/stats/base/ndarray/ztest/examples/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
var Float64Results = require( '@stdlib/stats/base/ztest/one-sample/results/float64' );
2222
var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' );
2323
var structFactory = require( '@stdlib/array/struct-factory' );
24-
var normal = require( '@stdlib/random/array/normal' );
24+
var normal = require( '@stdlib/random/normal' );
2525
var ndarray = require( '@stdlib/ndarray/ctor' );
2626
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
2727
var ndarray2array = require( '@stdlib/ndarray/to-array' );
@@ -32,8 +32,7 @@ var opts = {
3232
};
3333

3434
// Create a one-dimensional ndarray containing pseudorandom numbers drawn from a normal distribution:
35-
var xbuf = normal( 100, 0.0, 1.0, opts );
36-
var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
35+
var x = normal( [ 100 ], 0.0, 1.0, opts );
3736
console.log( ndarray2array( x ) );
3837

3938
// Specify the alternative hypothesis:

lib/node_modules/@stdlib/stats/base/ndarray/ztest/lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' );
2929
* var structFactory = require( '@stdlib/array/struct-factory' );
3030
* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
31+
* var vector = require( '@stdlib/ndarray/vector/ctor' );
3132
* var ndarray = require( '@stdlib/ndarray/ctor' );
3233
* var ztest = require( '@stdlib/stats/base/ndarray/ztest' );
3334
*
@@ -36,8 +37,7 @@
3637
* };
3738
*
3839
* // Define a one-dimensional input ndarray:
39-
* var xbuf = [ 1.0, 3.0, 4.0, 2.0 ];
40-
* var x = new ndarray( opts.dtype, xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
40+
* var x = vector( [ 1.0, 3.0, 4.0, 2.0 ], 'generic' );
4141
*
4242
* // Specify the alternative hypothesis:
4343
* var alt = scalar2ndarray( resolveEnum( 'two-sided' ), {

lib/node_modules/@stdlib/stats/base/ndarray/ztest/lib/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var strided = require( '@stdlib/stats/strided/ztest' ).ndarray;
3535
*
3636
* ## Notes
3737
*
38-
* - The function expects the following ndarrays in order:
38+
* - The function expects the following ndarrays:
3939
*
4040
* - a one-dimensional input ndarray.
4141
* - a zero-dimensional output ndarray containing a results object.
@@ -52,15 +52,15 @@ var strided = require( '@stdlib/stats/strided/ztest' ).ndarray;
5252
* var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' );
5353
* var structFactory = require( '@stdlib/array/struct-factory' );
5454
* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
55+
* var vector = require( '@stdlib/ndarray/vector/ctor' );
5556
* var ndarray = require( '@stdlib/ndarray/ctor' );
5657
*
5758
* var opts = {
5859
* 'dtype': 'generic'
5960
* };
6061
*
6162
* // Define a one-dimensional input ndarray:
62-
* var xbuf = [ 1.0, 3.0, 4.0, 2.0 ];
63-
* var x = new ndarray( opts.dtype, xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
63+
* var x = vector( [ 1.0, 3.0, 4.0, 2.0 ], 'generic' );
6464
*
6565
* // Specify the alternative hypothesis:
6666
* var alt = scalar2ndarray( resolveEnum( 'two-sided' ), {

lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,15 @@ var Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float
5353
var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' );
5454
var structFactory = require( '@stdlib/array/struct-factory' );
5555
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
56+
var vector = require( '@stdlib/ndarray/vector/ctor' );
5657
var ndarray = require( '@stdlib/ndarray/ctor' );
5758

5859
var opts = {
5960
'dtype': 'generic'
6061
};
6162

62-
var xbuf = [ 4.0, 4.0, 6.0, 6.0, 5.0 ];
63-
var x = new ndarray( opts.dtype, xbuf, [ 5 ], [ 1 ], 0, 'row-major' );
64-
65-
var ybuf = [ 3.0, 3.0, 5.0, 7.0, 7.0 ];
66-
var y = new ndarray( opts.dtype, ybuf, [ 5 ], [ 1 ], 0, 'row-major' );
63+
var x = vector( [ 4.0, 4.0, 6.0, 6.0, 5.0 ], 'generic' );
64+
var y = vector( [ 3.0, 3.0, 5.0, 7.0, 7.0 ], 'generic' );
6765

6866
var alt = scalar2ndarray( resolveEnum( 'two-sided' ), {
6967
'dtype': 'int8'
@@ -84,16 +82,16 @@ var bool = ( v === out );
8482

8583
The function has the following parameters:
8684

87-
- **arrays**: array-like object containing the following ndarrays in order:
85+
- **arrays**: array-like object containing the following ndarrays:
8886

89-
1. first one-dimensional input ndarray.
90-
2. second one-dimensional input ndarray.
91-
3. a zero-dimensional output ndarray containing a [results object][@stdlib/stats/base/ztest/two-sample/results/float64].
92-
4. a zero-dimensional ndarray specifying the alternative hypothesis.
93-
5. a zero-dimensional ndarray specifying the significance level.
94-
6. a zero-dimensional ndarray specifying the difference in means under the null hypothesis.
95-
7. a zero-dimensional ndarray specifying the known standard deviation of the first one-dimensional input ndarray.
96-
8. a zero-dimensional ndarray specifying the known standard deviation of the second one-dimensional input ndarray.
87+
- first one-dimensional input ndarray.
88+
- second one-dimensional input ndarray.
89+
- a zero-dimensional output ndarray containing a [results object][@stdlib/stats/base/ztest/two-sample/results/float64].
90+
- a zero-dimensional ndarray specifying the alternative hypothesis.
91+
- a zero-dimensional ndarray specifying the significance level.
92+
- a zero-dimensional ndarray specifying the difference in means under the null hypothesis.
93+
- a zero-dimensional ndarray specifying the known standard deviation of the first one-dimensional input ndarray.
94+
- a zero-dimensional ndarray specifying the known standard deviation of the second one-dimensional input ndarray.
9795

9896
</section>
9997

@@ -119,7 +117,7 @@ The function has the following parameters:
119117
var Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' );
120118
var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' );
121119
var structFactory = require( '@stdlib/array/struct-factory' );
122-
var normal = require( '@stdlib/random/array/normal' );
120+
var normal = require( '@stdlib/random/normal' );
123121
var ndarray = require( '@stdlib/ndarray/ctor' );
124122
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
125123
var ndarray2array = require( '@stdlib/ndarray/to-array' );
@@ -130,12 +128,10 @@ var opts = {
130128
};
131129

132130
// Create one-dimensional ndarrays containing pseudorandom numbers drawn from a normal distribution:
133-
var xbuf = normal( 100, 0.0, 1.0, opts );
134-
var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
131+
var x = normal( [ 100 ], 0.0, 1.0, opts );
135132
console.log( ndarray2array( x ) );
136133

137-
var ybuf = normal( 100, 0.0, 1.0, opts );
138-
var y = new ndarray( opts.dtype, ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
134+
var y = normal( [ 100 ], 0.0, 1.0, opts );
139135
console.log( ndarray2array( y ) );
140136

141137
// Specify the alternative hypothesis:

lib/node_modules/@stdlib/stats/base/ndarray/ztest2/benchmark/benchmark.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var normal = require( '@stdlib/random/array/normal' );
24+
var normal = require( '@stdlib/random/normal' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var pow = require( '@stdlib/math/base/special/pow' );
27-
var ndarray = require( '@stdlib/ndarray/base/ctor' );
28-
var scalar2ndarray = require( '@stdlib/ndarray/base/from-scalar' );
27+
var ndarray = require( '@stdlib/ndarray/ctor' );
28+
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
2929
var Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' );
3030
var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' );
3131
var structFactory = require( '@stdlib/array/struct-factory' );
@@ -56,28 +56,25 @@ function createBenchmark( len ) {
5656
var sigmay;
5757
var alpha;
5858
var diff;
59-
var xbuf;
60-
var ybuf;
6159
var obuf;
6260
var out;
6361
var alt;
6462
var x;
6563
var y;
6664

67-
xbuf = normal( len, 0.0, 1.0, options );
68-
x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' );
69-
70-
ybuf = normal( len, 0.0, 1.0, options );
71-
y = new ndarray( options.dtype, ybuf, [ len ], [ 1 ], 0, 'row-major' );
65+
x = normal( [ len ], 0.0, 1.0, options );
66+
y = normal( [ len ], 0.0, 1.0, options );
7267

7368
obuf = new ResultsArray( 1 );
7469
out = new ndarray( Float64Results, obuf, [], [ 0 ], 0, 'row-major' );
7570

76-
alt = scalar2ndarray( resolveEnum( 'two-sided' ), 'int8', 'row-major' );
77-
alpha = scalar2ndarray( 0.05, options.dtype, 'row-major' );
78-
diff = scalar2ndarray( 0.0, options.dtype, 'row-major' );
79-
sigmax = scalar2ndarray( 1.0, options.dtype, 'row-major' );
80-
sigmay = scalar2ndarray( 1.0, options.dtype, 'row-major' );
71+
alt = scalar2ndarray( resolveEnum( 'two-sided' ), {
72+
'dtype': 'int8'
73+
});
74+
alpha = scalar2ndarray( 0.05, options );
75+
diff = scalar2ndarray( 0.0, options );
76+
sigmax = scalar2ndarray( 1.0, options );
77+
sigmay = scalar2ndarray( 1.0, options );
8178

8279
return benchmark;
8380

0 commit comments

Comments
 (0)