Skip to content

Commit 46f9e71

Browse files
committed
chore: clean-up
--- 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: passed - 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: na - task: lint_license_headers status: passed ---
1 parent b3dc77d commit 46f9e71

File tree

10 files changed

+1119
-297
lines changed

10 files changed

+1119
-297
lines changed

lib/node_modules/@stdlib/ndarray/fill-slice/README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# fillSlice
2222

23-
> Fill an input [`ndarray`][@stdlib/ndarray/ctor] slice with a specified value.
23+
> Fill an input [`ndarray`][@stdlib/ndarray/ctor] view with a specified value.
2424
2525
<section class="intro">
2626

@@ -38,7 +38,7 @@ var fillSlice = require( '@stdlib/ndarray/fill-slice' );
3838

3939
#### fillSlice( x, value, ...s\[, options] )
4040

41-
Fills an input [`ndarray`][@stdlib/ndarray/ctor] slice with a specified value.
41+
Fills an input [`ndarray`][@stdlib/ndarray/ctor] view with a specified value.
4242

4343
```javascript
4444
var zeros = require( '@stdlib/ndarray/zeros' );
@@ -68,9 +68,9 @@ var arr = ndarray2array( x );
6868

6969
The function accepts the following arguments:
7070

71-
- **x**: array-like object containing an input [`ndarray`][@stdlib/ndarray/ctor].
72-
- **value**: scalar value.
73-
- **s**: [`MultiSlice`][@stdlib/slice/multi] instance, an array of slice arguments, or slice arguments as separate arguments.
71+
- **x**: input [`ndarray`][@stdlib/ndarray/ctor].
72+
- **value**: fill value.
73+
- **s**: a [`MultiSlice`][@stdlib/slice/multi] instance, an array of slice arguments, or slice arguments as separate arguments.
7474
- **options**: function options.
7575

7676
The function supports three (mutually exclusive) means for providing slice arguments:
@@ -107,20 +107,20 @@ var arr = ndarray2array( out );
107107
// 2. Using an array of slice arguments:
108108
x = zeros( [ 3, 4 ], opts );
109109

110-
out = fillSlice( x, 5.0, [ s0, s1 ] );
110+
out = fillSlice( x, 6.0, [ s0, s1 ] );
111111
// returns <ndarray>
112112

113113
arr = ndarray2array( out );
114-
// returns [ [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 5.0, 5.0 ], [ 0.0, 0.0, 5.0, 5.0 ] ]
114+
// returns [ [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 6.0, 6.0 ], [ 0.0, 0.0, 6.0, 6.0 ] ]
115115

116116
// 3. Providing separate arguments:
117117
x = zeros( [ 3, 4 ], opts );
118118

119-
out = fillSlice( x, 5.0, s0, s1 );
119+
out = fillSlice( x, 7.0, s0, s1 );
120120
// returns <ndarray>
121121

122122
arr = ndarray2array( out );
123-
// returns [ [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 5.0, 5.0 ], [ 0.0, 0.0, 5.0, 5.0 ] ]
123+
// returns [ [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 7.0, 7.0 ], [ 0.0, 0.0, 7.0, 7.0 ] ]
124124
```
125125

126126
The function supports the following options:
@@ -163,8 +163,9 @@ var arr = ndarray2array( x );
163163
## Notes
164164

165165
- An input [`ndarray`][@stdlib/ndarray/ctor] **must** be writable. If provided a **read-only** [`ndarray`][@stdlib/ndarray/ctor], the function throws an error.
166-
- If an input `value` is a number and `x` has a complex [data type][@stdlib/ndarray/dtypes], the function fills an input [`ndarray`][@stdlib/ndarray/ctor] with a complex number whose real component equals the provided scalar `value` and whose imaginary component is zero.
167-
- An input `value` must be able to safely cast to the input [`ndarray`][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes]. Scalar values having floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., a scalar double-precision floating-point number can be used to fill a `'float32'` input [`ndarray`][@stdlib/ndarray/ctor]).
166+
- A **slice argument** must be either a [`Slice`][@stdlib/slice/ctor], an integer, `null`, or `undefined`.
167+
- If a fill value is a number and `x` has a complex [data type][@stdlib/ndarray/dtypes], the function fills an input [`ndarray`][@stdlib/ndarray/ctor] with a complex number whose real component equals the provided fill `value` and whose imaginary component is zero.
168+
- A fill value must be able to safely cast to the input [`ndarray`][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes]. Fill values having floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., a scalar double-precision floating-point number can be used to fill a `'float32'` input [`ndarray`][@stdlib/ndarray/ctor]).
168169
- The function **mutates** the input [`ndarray`][@stdlib/ndarray/ctor].
169170

170171
</section>
@@ -190,13 +191,13 @@ var x = zeros( [ 2, 3, 4 ], {
190191
});
191192
console.log( ndarray2array( x ) );
192193

193-
// Define a fill region:
194+
// Specify the fill region:
194195
var s0 = new Slice( 1, 2 );
195196
var s1 = new Slice( null, null );
196197
var s2 = new Slice( 2, 4 );
197198
var s = new MultiSlice( s0, s1, s2 );
198199

199-
// Fill the region with a scalar value:
200+
// Fill a slice with a scalar value:
200201
fillSlice( x, 10.0, s );
201202
console.log( ndarray2array( x ) );
202203
```
@@ -217,6 +218,8 @@ console.log( ndarray2array( x ) );
217218

218219
[@stdlib/slice/multi]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/slice/multi
219220

221+
[@stdlib/slice/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/slice/ctor
222+
220223
[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/ctor
221224

222225
[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/dtypes

lib/node_modules/@stdlib/ndarray/fill-slice/benchmark/benchmark.1d.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
2525
var pow = require( '@stdlib/math/base/special/pow' );
2626
var zeros = require( '@stdlib/ndarray/zeros' );
2727
var MultiSlice = require( '@stdlib/slice/multi' );
28+
var getData = require( '@stdlib/ndarray/data-buffer' );
2829
var pkg = require( './../package.json' ).name;
2930
var fillSlice = require( './../lib' );
3031

@@ -48,12 +49,14 @@ var orders = [ 'row-major', 'column-major' ];
4849
* @returns {Function} benchmark function
4950
*/
5051
function createBenchmark( len, shape, xtype, order ) {
52+
var xbuf;
5153
var x;
5254

5355
x = zeros( shape, {
5456
'dtype': xtype,
5557
'order': order
5658
});
59+
xbuf = getData( x );
5760
return benchmark;
5861

5962
/**
@@ -63,17 +66,20 @@ function createBenchmark( len, shape, xtype, order ) {
6366
* @param {Benchmark} b - benchmark instance
6467
*/
6568
function benchmark( b ) {
69+
var s;
6670
var i;
6771

72+
s = new MultiSlice( null );
73+
6874
b.tic();
6975
for ( i = 0; i < b.iterations; i++ ) {
70-
fillSlice( x, i, new MultiSlice( null ) );
71-
if ( isnan( x.data[ i%len ] ) ) {
76+
fillSlice( x, i, s );
77+
if ( isnan( xbuf[ i%len ] ) ) {
7278
b.fail( 'should not return NaN' );
7379
}
7480
}
7581
b.toc();
76-
if ( isnan( x.data[ i%len ] ) ) {
82+
if ( isnan( xbuf[ i%len ] ) ) {
7783
b.fail( 'should not return NaN' );
7884
}
7985
b.pass( 'benchmark finished' );

lib/node_modules/@stdlib/ndarray/fill-slice/benchmark/benchmark.2d.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var floor = require( '@stdlib/math/base/special/floor' );
2727
var sqrt = require( '@stdlib/math/base/special/sqrt' );
2828
var zeros = require( '@stdlib/ndarray/zeros' );
2929
var MultiSlice = require( '@stdlib/slice/multi' );
30+
var getData = require( '@stdlib/ndarray/data-buffer' );
3031
var pkg = require( './../package.json' ).name;
3132
var fillSlice = require( './../lib' );
3233

@@ -50,12 +51,14 @@ var orders = [ 'row-major', 'column-major' ];
5051
* @returns {Function} benchmark function
5152
*/
5253
function createBenchmark( len, shape, xtype, order ) {
54+
var xbuf;
5355
var x;
5456

5557
x = zeros( shape, {
5658
'dtype': xtype,
5759
'order': order
5860
});
61+
xbuf = getData( x );
5962
return benchmark;
6063

6164
/**
@@ -65,17 +68,20 @@ function createBenchmark( len, shape, xtype, order ) {
6568
* @param {Benchmark} b - benchmark instance
6669
*/
6770
function benchmark( b ) {
71+
var s;
6872
var i;
6973

74+
s = new MultiSlice( null, null );
75+
7076
b.tic();
7177
for ( i = 0; i < b.iterations; i++ ) {
72-
fillSlice( x, i, new MultiSlice( null, null ) );
73-
if ( isnan( x.data[ i%len ] ) ) {
78+
fillSlice( x, i, s );
79+
if ( isnan( xbuf[ i%len ] ) ) {
7480
b.fail( 'should not return NaN' );
7581
}
7682
}
7783
b.toc();
78-
if ( isnan( x.data[ i%len ] ) ) {
84+
if ( isnan( xbuf[ i%len ] ) ) {
7985
b.fail( 'should not return NaN' );
8086
}
8187
b.pass( 'benchmark finished' );

lib/node_modules/@stdlib/ndarray/fill-slice/docs/repl.txt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
{{alias}}( x, value, ...s[, options] )
3-
Fills an input ndarray slice with a specified value.
3+
Fills an input ndarray view with a specified value.
44

55
The function supports three (mutually exclusive) means of providing slice
66
arguments:
@@ -25,11 +25,11 @@
2525
Input ndarray.
2626

2727
value: any
28-
Scalar value. Must be able to safely cast to the input ndarray data
29-
type. Scalar values having floating-point data types (both real and
30-
complex) are allowed to downcast to a lower precision data type of the
31-
same kind (e.g., a scalar double-precision floating-point number can be
32-
used to fill a 'float32' input ndarray).
28+
Fill value. Must be able to safely cast to the input ndarray data type.
29+
Fill values having floating-point data types (both real and complex) are
30+
allowed to downcast to a lower precision data type of the same kind
31+
(e.g., a scalar double-precision floating-point number can be used to
32+
fill a 'float32' input ndarray).
3333

3434
s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike
3535
Slice arguments.
@@ -38,8 +38,8 @@
3838
Options.
3939

4040
options.strict: boolean (optional)
41-
Boolean indicating whether to enforce strict bounds checking.
42-
Default: true.
41+
Boolean indicating whether to enforce strict bounds checking. Default:
42+
true.
4343

4444
Returns
4545
-------
@@ -49,14 +49,16 @@
4949
Examples
5050
--------
5151
> var x = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ], { 'dtype': 'float64' } );
52-
> x.get( 0, 0 )
53-
0.0
52+
> {{alias:@stdlib/ndarray/to-array}}( x )
53+
[ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]
5454
> var s0 = new {{alias:@stdlib/slice/ctor}}( 0, 1 );
5555
> var s1 = new {{alias:@stdlib/slice/ctor}}( null, null );
5656
> var s = new {{alias:@stdlib/slice/multi}}( s0, s1 );
57-
> {{alias}}( x, 10.0, s );
58-
> x.get( 0, 0 )
59-
10.0
57+
> var out = {{alias}}( x, 10.0, s );
58+
> var bool = ( out === x )
59+
true
60+
> {{alias:@stdlib/ndarray/to-array}}( x )
61+
[ [ 10.0, 10.0 ], [ 0.0, 0.0 ] ]
6062

6163
See Also
6264
--------

lib/node_modules/@stdlib/ndarray/fill-slice/docs/types/index.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type SliceArgument = Slice | number | null | undefined;
4747
type Element<U> = U extends typedndarray<infer T> ? T : never;
4848

4949
/**
50-
* Fills an input ndarray slice with a specified value.
50+
* Fills an input ndarray view with a specified value.
5151
*
5252
* @param x - input ndarray
5353
* @param value - fill value
@@ -101,7 +101,7 @@ type Element<U> = U extends typedndarray<infer T> ? T : never;
101101
declare function fillSlice<T extends complexndarray>( x: T, value: number | ComplexLike, s: MultiSlice | ArrayLike<SliceArgument>, options?: Options ): T;
102102

103103
/**
104-
* Fills an input ndarray slice with a specified value.
104+
* Fills an input ndarray view with a specified value.
105105
*
106106
* @param x - input ndarray
107107
* @param value - fill value
@@ -131,7 +131,7 @@ declare function fillSlice<T extends complexndarray>( x: T, value: number | Comp
131131
declare function fillSlice<T extends complexndarray>( x: T, value: number | ComplexLike, ...args: Array<SliceArgument | Options> ): T;
132132

133133
/**
134-
* Fills an input ndarray slice with a specified value.
134+
* Fills an input ndarray view with a specified value.
135135
*
136136
* @param x - input ndarray
137137
* @param value - fill value
@@ -191,7 +191,7 @@ declare function fillSlice<T extends complexndarray>( x: T, value: number | Comp
191191
declare function fillSlice<T = unknown, U extends typedndarray<T> = typedndarray<T>>( x: U, value: Element<U>, s: MultiSlice | ArrayLike<SliceArgument>, options?: Options ): U;
192192

193193
/**
194-
* Fills an input ndarray slice with a specified value.
194+
* Fills an input ndarray view with a specified value.
195195
*
196196
* @param x - input ndarray
197197
* @param value - fill value
@@ -224,7 +224,7 @@ declare function fillSlice<T = unknown, U extends typedndarray<T> = typedndarray
224224
declare function fillSlice<T = unknown, U extends typedndarray<T> = typedndarray<T>>( x: U, value: Element<U>, ...args: Array<SliceArgument | Options> ): U;
225225

226226
/**
227-
* Fills an input ndarray slice with a specified value.
227+
* Fills an input ndarray view with a specified value.
228228
*
229229
* @param x - input ndarray
230230
* @param value - fill value
@@ -284,7 +284,7 @@ declare function fillSlice<T = unknown, U extends typedndarray<T> = typedndarray
284284
declare function fillSlice<T = unknown, U = unknown>( x: genericndarray<T>, value: U, s: MultiSlice | ArrayLike<SliceArgument>, options?: Options ): genericndarray<T | U>;
285285

286286
/**
287-
* Fills an input ndarray slice with a specified value.
287+
* Fills an input ndarray view with a specified value.
288288
*
289289
* @param x - input ndarray
290290
* @param value - fill value

lib/node_modules/@stdlib/ndarray/fill-slice/examples/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ var x = zeros( [ 2, 3, 4 ], {
3030
});
3131
console.log( ndarray2array( x ) );
3232

33-
// Create a MultiSlice to specify the fill region:
33+
// Specify the fill region:
3434
var s0 = new Slice( 1, 2 );
3535
var s1 = new Slice( null, null );
3636
var s2 = new Slice( 2, 4 );
3737
var s = new MultiSlice( s0, s1, s2 );
3838

39-
// Fill the ndarray with a scalar value:
39+
// Fill a slice with a scalar value:
4040
fillSlice( x, 10.0, s );
4141
console.log( ndarray2array( x ) );

lib/node_modules/@stdlib/ndarray/fill-slice/lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Fill an input ndarray slice with a specified value.
22+
* Fill an input ndarray view with a specified value.
2323
*
2424
* @module @stdlib/ndarray/fill-slice
2525
*
@@ -39,7 +39,7 @@
3939
* var s1 = new Slice( 2, 4 );
4040
* var s = new MultiSlice( s0, s1 );
4141
*
42-
* // Fill the ndarray with a scalar value:
42+
* // Fill a slice with a scalar value:
4343
* var y = fillSlice( x, 5.0, s );
4444
* // returns <ndarray>
4545
*

0 commit comments

Comments
 (0)