Skip to content

Commit 3ae71d5

Browse files
committed
feat: add accessor protocol support to
--- 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: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 77c2bfd commit 3ae71d5

File tree

14 files changed

+524
-118
lines changed

14 files changed

+524
-118
lines changed

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Ali Salesi <[email protected]>
1717
Aman Bhansali <[email protected]>
1818
Amit Jimiwal <[email protected]>
1919
Anudeep Sanapala <[email protected]>
20+
Aryan Bhirud <[email protected]>
2021
Athan Reines <[email protected]>
2122
2223
Brendan Graetz <[email protected]>

lib/node_modules/@stdlib/stats/base/variancepn/README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
@license Apache-2.0
44
5-
Copyright (c) 2020 The Stdlib Authors.
5+
Copyright (c) 2025 The Stdlib Authors.
66
77
Licensed under the Apache License, Version 2.0 (the "License");
88
you may not use this file except in compliance with the License.
@@ -197,18 +197,12 @@ var v = variancepn.ndarray( N, 1, x, 2, 1 );
197197
<!-- eslint no-undef: "error" -->
198198

199199
```javascript
200-
var randu = require( '@stdlib/random/base/randu' );
201-
var round = require( '@stdlib/math/base/special/round' );
202-
var Float64Array = require( '@stdlib/array/float64' );
200+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
203201
var variancepn = require( '@stdlib/stats/base/variancepn' );
204202

205-
var x;
206-
var i;
207-
208-
x = new Float64Array( 10 );
209-
for ( i = 0; i < x.length; i++ ) {
210-
x[ i ] = round( (randu()*100.0) - 50.0 );
211-
}
203+
var x = discreteUniform( 10, -50, 50, {
204+
'dtype': 'float64'
205+
});
212206
console.log( x );
213207

214208
var v = variancepn( x.length, 1, x, 1 );

lib/node_modules/@stdlib/stats/base/variancepn/benchmark/benchmark.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2020 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -21,13 +21,20 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var pow = require( '@stdlib/math/base/special/pow' );
2727
var pkg = require( './../package.json' ).name;
2828
var variancepn = require( './../lib/variancepn.js' );
2929

3030

31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'generic'
35+
};
36+
37+
3138
// FUNCTIONS //
3239

3340
/**
@@ -38,13 +45,7 @@ var variancepn = require( './../lib/variancepn.js' );
3845
* @returns {Function} benchmark function
3946
*/
4047
function createBenchmark( len ) {
41-
var x;
42-
var i;
43-
44-
x = [];
45-
for ( i = 0; i < len; i++ ) {
46-
x.push( ( randu()*20.0 ) - 10.0 );
47-
}
48+
var x = uniform( len, -10, 10, options );
4849
return benchmark;
4950

5051
function benchmark( b ) {

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2020 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -21,13 +21,20 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var pow = require( '@stdlib/math/base/special/pow' );
2727
var pkg = require( './../package.json' ).name;
2828
var variancepn = require( './../lib/ndarray.js' );
2929

3030

31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'generic'
35+
};
36+
37+
3138
// FUNCTIONS //
3239

3340
/**
@@ -38,13 +45,7 @@ var variancepn = require( './../lib/ndarray.js' );
3845
* @returns {Function} benchmark function
3946
*/
4047
function createBenchmark( len ) {
41-
var x;
42-
var i;
43-
44-
x = [];
45-
for ( i = 0; i < len; i++ ) {
46-
x.push( ( randu()*20.0 ) - 10.0 );
47-
}
48+
var x = uniform( len, -10, 10, options );
4849
return benchmark;
4950

5051
function benchmark( b ) {

lib/node_modules/@stdlib/stats/base/variancepn/docs/repl.txt

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
{{alias}}( N, correction, x, stride )
33
Computes the variance of a strided array using a two-pass algorithm.
44

5-
The `N` and `stride` parameters determine which elements in `x` are accessed
6-
at runtime.
5+
The `N` and stride parameters determine which elements in the strided array
6+
are accessed at runtime.
77

88
Indexing is relative to the first index. To introduce an offset, use a typed
99
array view.
@@ -31,7 +31,7 @@
3131
Input array.
3232

3333
stride: integer
34-
Index increment.
34+
Stride length.
3535

3636
Returns
3737
-------
@@ -45,21 +45,20 @@
4545
> {{alias}}( x.length, 1, x, 1 )
4646
~4.3333
4747

48-
// Using `N` and `stride` parameters:
48+
// Using `N` and stride parameters:
4949
> x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ];
50-
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
5150
> var stride = 2;
52-
> {{alias}}( N, 1, x, stride )
51+
> {{alias}}( 3, 1, x, stride )
5352
~4.3333
5453

5554
// Using view offsets:
5655
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
5756
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
58-
> N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
5957
> stride = 2;
60-
> {{alias}}( N, 1, x1, stride )
58+
> {{alias}}( 3, 1, x1, stride )
6159
~4.3333
6260

61+
6362
{{alias}}.ndarray( N, correction, x, stride, offset )
6463
Computes the variance of a strided array using a two-pass algorithm and
6564
alternative indexing semantics.
@@ -89,7 +88,7 @@
8988
Input array.
9089

9190
stride: integer
92-
Index increment.
91+
Stride length.
9392

9493
offset: integer
9594
Starting index.
@@ -108,8 +107,7 @@
108107

109108
// Using offset parameter:
110109
> var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ];
111-
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
112-
> {{alias}}.ndarray( N, 1, x, 2, 1 )
110+
> {{alias}}.ndarray( 3, 1, x, 2, 1 )
113111
~4.3333
114112

115113
See Also

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2020 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -20,14 +20,20 @@
2020

2121
/// <reference types="@stdlib/types"/>
2222

23-
import { NumericArray } from '@stdlib/types/array';
23+
import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array';
24+
25+
/**
26+
* Input array.
27+
*/
28+
type InputArray = NumericArray | Collection<number> | AccessorArrayLike<number>;
29+
2430

2531
/**
2632
* Interface describing `variancepn`.
2733
*/
2834
interface Routine {
2935
/**
30-
* Computes the variance of a strided array using a two-pass algorithm.
36+
* Computes the variance of a strided array using a two-pass algorithm and alternative indexing semantics.
3137
*
3238
* @param N - number of indexed elements
3339
* @param correction - degrees of freedom adjustment
@@ -38,10 +44,10 @@ interface Routine {
3844
* @example
3945
* var x = [ 1.0, -2.0, 2.0 ];
4046
*
41-
* var v = variancepn( x.length, 1, x, 1 );
47+
* var v = variancepn( x.length, 1, x, 1, 0 );
4248
* // returns ~4.3333
4349
*/
44-
( N: number, correction: number, x: NumericArray, stride: number ): number;
50+
( N: number, correction: number, x: NumericArray | InputArray, stride: number ): number;
4551

4652
/**
4753
* Computes the variance of a strided array using a two-pass algorithm and alternative indexing semantics.
@@ -59,7 +65,7 @@ interface Routine {
5965
* var v = variancepn.ndarray( x.length, 1, x, 1, 0 );
6066
* // returns ~4.3333
6167
*/
62-
ndarray( N: number, correction: number, x: NumericArray, stride: number, offset: number ): number;
68+
ndarray( N: number, correction: number, x: InputArray, stride: number, offset: number ): number;
6369
}
6470

6571
/**

lib/node_modules/@stdlib/stats/base/variancepn/docs/types/test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2020 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19+
import AccessorArray = require( '@stdlib/array/base/accessor' );
1920
import variancepn = require( './index' );
2021

2122

@@ -26,6 +27,7 @@ import variancepn = require( './index' );
2627
const x = new Float64Array( 10 );
2728

2829
variancepn( x.length, 1, x, 1 ); // $ExpectType number
30+
variancepn( x.length, 1, new AccessorArray( x ), 1 ); // $ExpectType number
2931
}
3032

3133
// The compiler throws an error if the function is provided a first argument which is not a number...
@@ -101,6 +103,7 @@ import variancepn = require( './index' );
101103
const x = new Float64Array( 10 );
102104

103105
variancepn.ndarray( x.length, 1, x, 1, 0 ); // $ExpectType number
106+
variancepn.ndarray( x.length, 1, new AccessorArray( x ), 1, 0 ); // $ExpectType number
104107
}
105108

106109
// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...

lib/node_modules/@stdlib/stats/base/variancepn/examples/index.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2020 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -18,18 +18,12 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
22-
var round = require( '@stdlib/math/base/special/round' );
23-
var Float64Array = require( '@stdlib/array/float64' );
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2422
var variancepn = require( './../lib' );
2523

26-
var x;
27-
var i;
28-
29-
x = new Float64Array( 10 );
30-
for ( i = 0; i < x.length; i++ ) {
31-
x[ i ] = round( (randu()*100.0) - 50.0 );
32-
}
24+
var x = discreteUniform( 10, -50, 50, {
25+
'dtype': 'float64'
26+
});
3327
console.log( x );
3428

3529
var v = variancepn( x.length, 1, x, 1 );

0 commit comments

Comments
 (0)