Skip to content

Commit d908b1d

Browse files
committed
Auto-generated commit
1 parent 628110a commit d908b1d

File tree

10 files changed

+143
-187
lines changed

10 files changed

+143
-187
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2026-01-12)
7+
## Unreleased (2026-01-13)
88

99
<section class="features">
1010

@@ -708,6 +708,9 @@ A total of 40 issues were closed in this release:
708708

709709
<details>
710710

711+
- [`6aee8e2`](https://github.com/stdlib-js/stdlib/commit/6aee8e232a2cebd57d5246d76ffe08e67941c0a4) - **docs:** move content to notes _(by Athan Reines)_
712+
- [`93e0c79`](https://github.com/stdlib-js/stdlib/commit/93e0c79faa246da751b6d7a640b5133fefad00f2) - **refactor:** return the input ndarray and update examples _(by Athan Reines)_
713+
- [`d5ddfc7`](https://github.com/stdlib-js/stdlib/commit/d5ddfc76b9363a57791e018c8435c33dd18a9bee) - **style:** remove empty line _(by Athan Reines)_
711714
- [`afa33d2`](https://github.com/stdlib-js/stdlib/commit/afa33d21dadcaf449b9950ea9ec30a12f4596738) - **docs:** update examples [(#9700)](https://github.com/stdlib-js/stdlib/pull/9700) _(by stdlib-bot)_
712715
- [`fdfdf13`](https://github.com/stdlib-js/stdlib/commit/fdfdf139a4f787dd67d5cdcf94130bf6469c92a2) - **docs:** fix example to ensure valid type promotion _(by Athan Reines)_
713716
- [`f738a37`](https://github.com/stdlib-js/stdlib/commit/f738a37c1cc32a740c7ecc4cbc7982eca26f67d2) - **feat:** add `ternaryBlockSize` to namespace _(by Athan Reines)_

base/fill-by/README.md

Lines changed: 34 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -41,38 +41,20 @@ var fillBy = require( '@stdlib/ndarray/base/fill-by' );
4141
Fills an input ndarray according to a callback function.
4242

4343
```javascript
44-
var Float64Array = require( '@stdlib/array/float64' );
44+
var array = require( '@stdlib/ndarray/array' );
4545

46-
function fcn( value ) {
47-
return value * 10.0;
46+
function fcn() {
47+
return 10.0;
4848
}
4949

50-
// Create a data buffer:
51-
var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
52-
53-
// Define the shape of the input array:
54-
var shape = [ 3, 1, 2 ];
55-
56-
// Define the array strides:
57-
var sx = [ 2, 2, 1 ];
58-
59-
// Define the index offset:
60-
var ox = 0;
61-
62-
// Create the input ndarray-like object:
63-
var x = {
64-
'dtype': 'float64',
65-
'data': xbuf,
66-
'shape': shape,
67-
'strides': sx,
68-
'offset': ox,
69-
'order': 'row-major'
70-
};
50+
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );
51+
// returns <ndarray>[ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ]
7152

72-
fillBy( x, fcn );
53+
var out = fillBy( x, fcn );
54+
// returns <ndarray>[ [ [ 10.0, 10.0 ] ], [ [ 10.0, 10.0 ] ], [ [ 10.0, 10.0 ] ] ]
7355

74-
console.log( x.data );
75-
// => <Float64Array>[ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0 ]
56+
var bool = ( out === x );
57+
// returns true
7658
```
7759

7860
The function accepts the following arguments:
@@ -86,57 +68,25 @@ To set the callback function execution context, provide a `thisArg`.
8668
<!-- eslint-disable no-invalid-this -->
8769

8870
```javascript
89-
var Float64Array = require( '@stdlib/array/float64' );
71+
var array = require( '@stdlib/ndarray/array' );
9072

9173
function fcn( value ) {
92-
return value * this.factor;
74+
return value * 10.0;
9375
}
9476

95-
// Create a data buffer:
96-
var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
97-
98-
// Define the shape of the input array:
99-
var shape = [ 3, 1, 2 ];
100-
101-
// Define the array strides:
102-
var sx = [ 2, 2, 1 ];
103-
104-
// Define the index offset:
105-
var ox = 0;
106-
107-
// Create the input ndarray-like object:
108-
var x = {
109-
'dtype': 'float64',
110-
'data': xbuf,
111-
'shape': shape,
112-
'strides': sx,
113-
'offset': ox,
114-
'order': 'row-major'
115-
};
77+
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );
78+
// returns <ndarray>[ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ]
11679

11780
var ctx = {
11881
'factor': 10.0
11982
};
120-
fillBy( x, fcn, ctx );
121-
122-
console.log( x.data );
123-
// => <Float64Array>[ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0 ]
124-
```
12583

126-
A provided ndarray should be an object with the following properties:
84+
var out = fillBy( x, fcn, ctx );
85+
// returns <ndarray>[ [ [ 10.0, 20.0 ] ], [ [ 30.0, 40.0 ] ], [ [ 50.0, 60.0 ] ] ]
12786

128-
- **dtype**: data type.
129-
- **data**: data buffer.
130-
- **shape**: dimensions.
131-
- **strides**: stride lengths.
132-
- **offset**: index offset.
133-
- **order**: specifies whether an ndarray is row-major (C-style) or column major (Fortran-style).
134-
135-
The callback function is provided the following arguments:
136-
137-
- **value**: current array element.
138-
- **indices**: current array element indices.
139-
- **arr**: the input ndarray.
87+
var bool = ( out === x );
88+
// returns true
89+
```
14090

14191
</section>
14292

@@ -146,7 +96,23 @@ The callback function is provided the following arguments:
14696

14797
## Notes
14898

99+
- A provided ndarray should be an object with the following properties:
100+
101+
- **dtype**: data type.
102+
- **data**: data buffer.
103+
- **shape**: dimensions.
104+
- **strides**: stride lengths.
105+
- **offset**: index offset.
106+
- **order**: specifies whether an ndarray is row-major (C-style) or column major (Fortran-style).
107+
108+
- The callback function is provided the following arguments:
109+
110+
- **value**: current array element.
111+
- **indices**: current array element indices.
112+
- **arr**: the input ndarray.
113+
149114
- The function **mutates** the input ndarray.
115+
150116
- The function assumes that each element in the underlying input ndarray data buffer has one, and only one, corresponding element in input ndarray view (i.e., a provided ndarray is not a broadcasted ndarray view).
151117

152118
</section>

base/fill-by/docs/repl.txt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,28 @@
1717
Parameters
1818
----------
1919
x: ndarrayLike
20-
Input ndarray-like object.
20+
Input ndarray.
2121

2222
fcn: Function
2323
Callback function.
2424

2525
thisArg: any (optional)
2626
Callback function execution context.
2727

28+
Returns
29+
-------
30+
out: ndarrayLike
31+
Input ndarray.
32+
2833
Examples
2934
--------
3035
> var opts = { 'dtype': 'float64' };
3136
> var x = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ], opts );
32-
> x.get( 0, 0 )
33-
0.0
3437
> function fcn() { return 10.0; };
35-
> {{alias}}( x, fcn );
36-
> x.get( 0, 0 )
37-
10.0
38-
> x.get( 0, 1 )
39-
10.0
40-
> x.get( 1, 0 )
41-
10.0
42-
> x.get( 1, 1 )
43-
10.0
38+
> var out = {{alias}}( x, fcn )
39+
<ndarray>[ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]
40+
> var bool = ( out === x )
41+
true
4442

4543
See Also
4644
--------

base/fill-by/docs/types/index.d.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ type Callback<T, U, V, ThisArg> = Nullary<U, ThisArg> | Unary<T, U, ThisArg> | B
7272
* @param x - input ndarray
7373
* @param fcn - callback function
7474
* @param thisArg - callback function execution context
75+
* @returns input ndarray
7576
*
7677
* @example
7778
* var Complex128Array = require( '@stdlib/array/complex128' );
@@ -103,19 +104,23 @@ type Callback<T, U, V, ThisArg> = Nullary<U, ThisArg> | Unary<T, U, ThisArg> | B
103104
* 'order': 'row-major'
104105
* };
105106
*
106-
* fillBy( x, fcn );
107+
* var out = fillBy( x, fcn );
107108
*
108109
* console.log( x.data );
109110
* // => <Complex128Array>[ 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0 ]
111+
*
112+
* var bool = ( out === x );
113+
* // returns true
110114
*/
111-
declare function fillBy<T = unknown, U = unknown, V extends complexndarray = complexndarray, ThisArg = unknown>( x: V, fcn: Callback<T, U, V, ThisArg>, thisArg?: ThisParameterType<Callback<T, U, V, ThisArg>> ): void;
115+
declare function fillBy<T = unknown, U = unknown, V extends complexndarray = complexndarray, ThisArg = unknown>( x: V, fcn: Callback<T, U, V, ThisArg>, thisArg?: ThisParameterType<Callback<T, U, V, ThisArg>> ): V;
112116

113117
/**
114118
* Fills an input ndarray according to a callback function.
115119
*
116120
* @param x - input ndarray
117121
* @param fcn - callback function
118122
* @param thisArg - callback function execution context
123+
* @returns input ndarray
119124
*
120125
* @example
121126
* var Float64Array = require( '@stdlib/array/float64' );
@@ -146,12 +151,15 @@ declare function fillBy<T = unknown, U = unknown, V extends complexndarray = com
146151
* 'order': 'row-major'
147152
* };
148153
*
149-
* fillBy( x, fcn );
154+
* var out = fillBy( x, fcn );
150155
*
151156
* console.log( x.data );
152157
* // => <Float64Array>[ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ]
158+
*
159+
* var bool = ( out === x );
160+
* // returns true
153161
*/
154-
declare function fillBy<T = unknown, U = unknown, V extends typedndarray<T> = typedndarray<T>, ThisArg = unknown>( x: V, fcn: Callback<T, U, V, ThisArg>, thisArg?: ThisParameterType<Callback<T, U, V, ThisArg>> ): void;
162+
declare function fillBy<T = unknown, U = unknown, V extends typedndarray<T> = typedndarray<T>, ThisArg = unknown>( x: V, fcn: Callback<T, U, V, ThisArg>, thisArg?: ThisParameterType<Callback<T, U, V, ThisArg>> ): V;
155163

156164

157165
// EXPORTS //

base/fill-by/docs/types/test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ function fcn2(): ComplexLike {
4646

4747
// The function returns `undefined`...
4848
{
49-
fillBy( zeros( 'float64', [ 2, 2 ], 'row-major' ), fcn1 ); // $ExpectType void
50-
fillBy( zeros( 'complex128', [ 2, 2 ], 'row-major' ), fcn2 ); // $ExpectType void
51-
fillBy( zeros( 'generic', [ 2, 2 ], 'row-major' ), fcn1 ); // $ExpectType void
49+
fillBy( zeros( 'float64', [ 2, 2 ], 'row-major' ), fcn1 ); // $ExpectType float64ndarray
50+
fillBy( zeros( 'complex128', [ 2, 2 ], 'row-major' ), fcn2 ); // $ExpectType complex128ndarray
51+
fillBy( zeros( 'generic', [ 2, 2 ], 'row-major' ), fcn1 ); // $ExpectType genericndarray<number>
5252

53-
fillBy( zeros( 'float64', [ 2, 2 ], 'row-major' ), fcn1, {} ); // $ExpectType void
54-
fillBy( zeros( 'complex128', [ 2, 2 ], 'row-major' ), fcn2, {} ); // $ExpectType void
55-
fillBy( zeros( 'generic', [ 2, 2 ], 'row-major' ), fcn1, {} ); // $ExpectType void
53+
fillBy( zeros( 'float64', [ 2, 2 ], 'row-major' ), fcn1, {} ); // $ExpectType float64ndarray
54+
fillBy( zeros( 'complex128', [ 2, 2 ], 'row-major' ), fcn2, {} ); // $ExpectType complex128ndarray
55+
fillBy( zeros( 'generic', [ 2, 2 ], 'row-major' ), fcn1, {} ); // $ExpectType genericndarray<number>
5656
}
5757

5858
// The compiler throws an error if the function is provided a first argument which is not an ndarray-like object...

base/fill-by/lib/index.js

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,21 @@
2424
* @module @stdlib/ndarray/base/fill-by
2525
*
2626
* @example
27-
* var Float64Array = require( '@stdlib/array/float64' );
27+
* var array = require( '@stdlib/ndarray/array' );
2828
* var fillBy = require( '@stdlib/ndarray/base/fill-by' );
2929
*
3030
* function fcn() {
3131
* return 10.0;
3232
* }
3333
*
34-
* // Create a data buffer:
35-
* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
34+
* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );
35+
* // returns <ndarray>[ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ]
3636
*
37-
* // Define the shape of the input array:
38-
* var shape = [ 3, 1, 2 ];
37+
* var out = fillBy( x, fcn );
38+
* // returns <ndarray>[ [ [ 10.0, 10.0 ] ], [ [ 10.0, 10.0 ] ], [ [ 10.0, 10.0 ] ] ]
3939
*
40-
* // Define the array strides:
41-
* var sx = [ 2, 2, 1 ];
42-
*
43-
* // Define the index offset:
44-
* var ox = 0;
45-
*
46-
* // Create the input ndarray-like object:
47-
* var x = {
48-
* 'dtype': 'float64',
49-
* 'data': xbuf,
50-
* 'shape': shape,
51-
* 'strides': sx,
52-
* 'offset': ox,
53-
* 'order': 'row-major'
54-
* };
55-
*
56-
* fillBy( x, fcn );
57-
*
58-
* console.log( x.data );
59-
* // => <Float64Array>[ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ]
40+
* var bool = ( out === x );
41+
* // returns true
6042
*/
6143

6244
// MODULES //

base/fill-by/lib/main.js

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,53 +28,30 @@ var map = require( './../../../base/map' );
2828
/**
2929
* Fills an input ndarray according to a callback function.
3030
*
31-
* @param {ndarrayLike} x - ndarray-like object
32-
* @param {string} x.dtype - data type
33-
* @param {Collection} x.data - data buffer
34-
* @param {NonNegativeIntegerArray} x.shape - dimensions
35-
* @param {IntegerArray} x.strides - stride lengths
36-
* @param {NonNegativeInteger} x.offset - index offset
37-
* @param {string} x.order - specifies whether `x` is row-major (C-style) or column-major (Fortran-style)
31+
* @param {ndarrayLike} x - input ndarray
3832
* @param {Function} fcn - callback function
3933
* @param {*} [thisArg] - callback function execution context
40-
* @returns {void}
34+
* @returns {ndarrayLike} input ndarray
4135
*
4236
* @example
43-
* var Float64Array = require( '@stdlib/array/float64' );
37+
* var array = require( '@stdlib/ndarray/array' );
4438
*
4539
* function fcn() {
4640
* return 10.0;
4741
* }
4842
*
49-
* // Create a data buffer:
50-
* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
43+
* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );
44+
* // returns <ndarray>[ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ]
5145
*
52-
* // Define the shape of the input array:
53-
* var shape = [ 3, 1, 2 ];
46+
* var out = fillBy( x, fcn );
47+
* // returns <ndarray>[ [ [ 10.0, 10.0 ] ], [ [ 10.0, 10.0 ] ], [ [ 10.0, 10.0 ] ] ]
5448
*
55-
* // Define the array strides:
56-
* var sx = [ 2, 2, 1 ];
57-
*
58-
* // Define the index offset:
59-
* var ox = 0;
60-
*
61-
* // Create the input ndarray-like object:
62-
* var x = {
63-
* 'dtype': 'float64',
64-
* 'data': xbuf,
65-
* 'shape': shape,
66-
* 'strides': sx,
67-
* 'offset': ox,
68-
* 'order': 'row-major'
69-
* };
70-
*
71-
* fillBy( x, fcn );
72-
*
73-
* console.log( x.data );
74-
* // => <Float64Array>[ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ]
49+
* var bool = ( out === x );
50+
* // returns true
7551
*/
7652
function fillBy( x, fcn, thisArg ) {
7753
map( [ x, x ], fcn, thisArg );
54+
return x;
7855
}
7956

8057

0 commit comments

Comments
 (0)