Skip to content

Commit 43a64a5

Browse files
committed
docs: add examples
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 0f1545f commit 43a64a5

File tree

1 file changed

+85
-0
lines changed
  • lib/node_modules/@stdlib/ndarray/base/unary-reduce-strided1d-to-struct/examples

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
var normal = require( '@stdlib/random/array/normal' );
22+
var ndarray2array = require( '@stdlib/ndarray/base/to-array' );
23+
var Float64Results = require( '@stdlib/stats/base/ztest/one-sample/results/float64' );
24+
var structFactory = require( '@stdlib/array/struct-factory' );
25+
var ztest = require( '@stdlib/stats/base/ndarray/ztest' );
26+
var unaryReduceStrided1d = require( './../lib' );
27+
28+
var ResultsArray = structFactory( Float64Results );
29+
30+
var N = 10;
31+
var x = {
32+
'dtype': 'generic',
33+
'data': normal( N, 0.0, 1.0, {
34+
'dtype': 'generic'
35+
}),
36+
'shape': [ 1, 5, 2 ],
37+
'strides': [ 10, 2, 1 ],
38+
'offset': 0,
39+
'order': 'row-major'
40+
};
41+
var y = {
42+
'dtype': Float64Results,
43+
'data': new ResultsArray( 2 ),
44+
'shape': [ 1, 2 ],
45+
'strides': [ 2, 1 ],
46+
'offset': 0,
47+
'order': 'row-major'
48+
};
49+
var alternative = {
50+
'dtype': 'generic',
51+
'data': [ 'two-sided' ],
52+
'shape': [ 1, 2 ],
53+
'strides': [ 0, 0 ],
54+
'offset': 0,
55+
'order': 'row-major'
56+
};
57+
var alpha = {
58+
'dtype': 'generic',
59+
'data': [ 0.05 ],
60+
'shape': [ 1, 2 ],
61+
'strides': [ 0, 0 ],
62+
'offset': 0,
63+
'order': 'row-major'
64+
};
65+
var mu = {
66+
'dtype': 'generic',
67+
'data': [ 0.0 ],
68+
'shape': [ 1, 2 ],
69+
'strides': [ 0, 0 ],
70+
'offset': 0,
71+
'order': 'row-major'
72+
};
73+
var sigma = {
74+
'dtype': 'generic',
75+
'data': [ 1.0 ],
76+
'shape': [ 1, 2 ],
77+
'strides': [ 0, 0 ],
78+
'offset': 0,
79+
'order': 'row-major'
80+
};
81+
82+
unaryReduceStrided1d( ztest, [ x, y, alternative, alpha, mu, sigma ], [ 1 ] );
83+
84+
console.log( ndarray2array( x.data, x.shape, x.strides, x.offset, x.order ) );
85+
console.log( ndarray2array( y.data, y.shape, y.strides, y.offset, y.order ) );

0 commit comments

Comments
 (0)