Skip to content

Commit 232ae50

Browse files
committed
fix: apply review suggestions
--- 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: 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: na - task: lint_license_headers status: passed ---
1 parent e9a30f2 commit 232ae50

File tree

23 files changed

+69
-51
lines changed

23 files changed

+69
-51
lines changed

lib/node_modules/@stdlib/ndarray/base/some-by/README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Tests whether at least `n` elements in an ndarray pass a test implemented by a p
4444

4545
```javascript
4646
var Float64Array = require( '@stdlib/array/float64' );
47-
var scalar2ndarray = require( '@stdlib/ndarray/base/from-scalar' );
47+
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
4848

4949
function predicate( value ) {
5050
return value > 0.0;
@@ -72,15 +72,17 @@ var x = {
7272
'order': 'row-major'
7373
};
7474

75-
var n = scalar2ndarray( 3.0, 'generic', 'row-major' );
75+
var n = scalar2ndarray( 3, {
76+
'dtype': 'generic'
77+
});
7678

7779
var out = someBy( [ x, n ], predicate );
7880
// returns true
7981
```
8082

8183
The function accepts the following arguments:
8284

83-
- **arrays**: array-like object containing an input ndarray and a zero-dimensional ndarray.
85+
- **arrays**: array-like object containing an input ndarray and a zero-dimensional ndarray specifying the minimum number of elements in the input ndarray that must satisfy the predicate function.
8486
- **predicate**: predicate function.
8587
- **thisArg**: predicate function execution context (_optional_).
8688

@@ -105,7 +107,7 @@ To set the predicate function execution context, provide a `thisArg`.
105107

106108
```javascript
107109
var Float64Array = require( '@stdlib/array/float64' );
108-
var scalar2ndarray = require( '@stdlib/ndarray/base/from-scalar' );
110+
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
109111

110112
function predicate( value ) {
111113
this.count += 1;
@@ -134,7 +136,9 @@ var x = {
134136
'order': 'row-major'
135137
};
136138

137-
var n = scalar2ndarray( 6.0, 'generic', 'row-major' );
139+
var n = scalar2ndarray( 6, {
140+
'dtype': 'generic'
141+
});
138142

139143
var ctx = {
140144
'count': 0
@@ -189,7 +193,7 @@ var x = {
189193
};
190194
console.log( ndarray2array( x.data, x.shape, x.strides, x.offset, x.order ) );
191195

192-
var n = scalar2ndarray( 5.0, {
196+
var n = scalar2ndarray( 5, {
193197
'dtype': 'generic'
194198
});
195199

lib/node_modules/@stdlib/ndarray/base/some-by/benchmark/benchmark.1d_rowmajor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function createBenchmark( len, shape, xtype ) {
7070
'offset': 0,
7171
'order': order
7272
};
73-
n = scalar2ndarray( 5.0, {
73+
n = scalar2ndarray( 5, {
7474
'dtype': 'generic',
7575
'order': order
7676
});

lib/node_modules/@stdlib/ndarray/base/some-by/docs/repl.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
Parameters
2323
----------
2424
arrays: ArrayLikeObject<ndarray>
25-
Array-like object containing an input ndarray and a 0-dimensional
26-
ndarray containing number of elements.
25+
Array-like object containing an input ndarray and a zero-dimensional
26+
ndarray specifying the minimum number of elements in the input ndarray
27+
that must satisfy the predicate function.
2728

2829
predicate: Function
2930
Predicate function.
@@ -52,7 +53,7 @@
5253

5354
// Using an ndarray...
5455
> var x = {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord );
55-
> var n = {{alias:@stdlib/ndarray/from-scalar}}( 3, { 'dtype': 'generic' });
56+
> var n = {{alias:@stdlib/ndarray/from-scalar}}( 3 );
5657
> {{alias}}( [ x, n ], clbk )
5758
true
5859

lib/node_modules/@stdlib/ndarray/base/some-by/docs/types/index.d.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

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

23-
import { ArrayLike } from '@stdlib/types/array';
2423
import { typedndarray } from '@stdlib/types/ndarray';
2524

2625
/**
@@ -70,10 +69,10 @@ type Predicate<T, U> = Nullary<U> | Unary<T, U> | Binary<T, U> | Ternary<T, U>;
7069
/**
7170
* Tests whether at least `n` elements in an ndarray pass a test implemented by a predicate function.
7271
*
73-
* @param arrays - array-like object containing an input ndarray and a 0-dimensional ndarray containing the number of elements
72+
* @param arrays - array-like object containing an input ndarray and a zero-dimensional ndarray specifying the minimum number of elements in the input ndarray that must satisfy the predicate function
7473
* @param predicate - predicate function
7574
* @param thisArg - predicate function execution context
76-
* @returns boolean indicating whether all elements pass a test
75+
* @returns boolean indicating whether `n` elements pass a test
7776
*
7877
* @example
7978
* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
@@ -97,13 +96,13 @@ type Predicate<T, U> = Nullary<U> | Unary<T, U> | Binary<T, U> | Ternary<T, U>;
9796
*
9897
* // Create the input ndarray:
9998
* var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );
100-
* var n = scalar2ndarray( 3.0, { 'dtype': 'generic' } );
99+
* var n = scalar2ndarray( 3, { 'dtype': 'generic' } );
101100
*
102101
* // Test elements:
103102
* var out = someBy( [ x, n ], predicate );
104103
* // returns true
105104
*/
106-
declare function someBy<T = unknown, U = unknown>( arrays: ArrayLike<typedndarray<T>>, predicate: Predicate<T, U>, thisArg?: ThisParameterType<Predicate<T, U>> ): boolean;
105+
declare function someBy<T = unknown, U = unknown>( arrays: [ typedndarray<T>, typedndarray<number>], predicate: Predicate<T, U>, thisArg?: ThisParameterType<Predicate<T, U>> ): boolean;
107106

108107

109108
// EXPORTS //

lib/node_modules/@stdlib/ndarray/base/some-by/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var x = {
3939
};
4040
console.log( ndarray2array( x.data, x.shape, x.strides, x.offset, x.order ) );
4141

42-
var n = scalar2ndarray( 5.0, {
42+
var n = scalar2ndarray( 5, {
4343
'dtype': 'generic'
4444
});
4545

lib/node_modules/@stdlib/ndarray/base/some-by/lib/0d.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @param {PositiveInteger} n - number of elements
3636
* @param {Function} predicate - predicate function
3737
* @param {*} thisArg - predicate function execution context
38-
* @returns {boolean} boolean indicating whether all elements pass a test
38+
* @returns {boolean} boolean indicating whether at least `n` elements pass a test
3939
*
4040
* @example
4141
* var Float64Array = require( '@stdlib/array/float64' );
@@ -72,6 +72,9 @@
7272
* // returns true
7373
*/
7474
function some0d( x, n, predicate, thisArg ) {
75+
if ( n > 1 ) {
76+
return false;
77+
}
7578
if ( predicate.call( thisArg, x.data[ x.offset ], [], x.ref ) ) {
7679
return true;
7780
}

lib/node_modules/@stdlib/ndarray/base/some-by/lib/0d_accessors.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* @param {PositiveInteger} n - number of elements
3737
* @param {Function} predicate - predicate function
3838
* @param {*} thisArg - predicate function execution context
39-
* @returns {boolean} boolean indicating whether all elements pass a test
39+
* @returns {boolean} boolean indicating whether at least `n` elements pass a test
4040
*
4141
* @example
4242
* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
@@ -75,6 +75,9 @@
7575
* // returns true
7676
*/
7777
function every0d( x, n, predicate, thisArg ) {
78+
if ( n > 1 ) {
79+
return false;
80+
}
7881
if ( predicate.call( thisArg, x.accessors[ 0 ]( x.data, x.offset ), [], x.ref ) ) { // eslint-disable-line max-len
7982
return true;
8083
}

lib/node_modules/@stdlib/ndarray/base/some-by/lib/1d.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @param {PositiveInteger} n - number of elements
3636
* @param {Function} predicate - predicate function
3737
* @param {*} thisArg - predicate function execution context
38-
* @returns {boolean} boolean indicating whether all elements pass a test
38+
* @returns {boolean} boolean indicating whether at least `n` elements pass a test
3939
*
4040
* @example
4141
* var Float64Array = require( '@stdlib/array/float64' );

lib/node_modules/@stdlib/ndarray/base/some-by/lib/1d_accessors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* @param {PositiveInteger} n - number of elements
3737
* @param {Function} predicate - predicate function
3838
* @param {*} thisArg - predicate function execution context
39-
* @returns {boolean} boolean indicating whether all elements pass a test
39+
* @returns {boolean} boolean indicating whether at least `n` elements pass a test
4040
*
4141
* @example
4242
* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
@@ -103,7 +103,7 @@ function some1d( x, n, predicate, thisArg ) {
103103

104104
// Iterate over the ndarray dimensions...
105105
for ( i0 = 0; i0 < S0; i0++ ) {
106-
if ( predicate.call( thisArg, get( xbuf, ix ), [ i0 ], x.ref) ) {
106+
if ( predicate.call( thisArg, get( xbuf, ix ), [ i0 ], x.ref ) ) {
107107
count += 1;
108108
if ( count === n ) {
109109
return true;

lib/node_modules/@stdlib/ndarray/base/some-by/lib/2d.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
4343
* @param {PositiveInteger} n - number of elements
4444
* @param {Function} predicate - predicate function
4545
* @param {*} thisArg - predicate function execution context
46-
* @returns {boolean} boolean indicating whether all elements pass a test
46+
* @returns {boolean} boolean indicating whether at least `n` elements pass a test
4747
*
4848
* @example
4949
* var Float64Array = require( '@stdlib/array/float64' );

0 commit comments

Comments
 (0)