Skip to content

Commit 9d02160

Browse files
committed
fix: normalize all dtypes to strings
--- 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: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 86003ad commit 9d02160

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

lib/node_modules/@stdlib/blas/ext/linspace/lib/assign.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
2929
var isComplexLike = require( '@stdlib/assert/is-complex-like' );
3030
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
3131
var nonCoreShape = require( '@stdlib/ndarray/base/complement-shape' );
32+
var resolveStr = require( '@stdlib/ndarray/base/dtype-resolve-str' );
3233
var getDType = require( '@stdlib/ndarray/dtype' );
3334
var getOrder = require( '@stdlib/ndarray/order' );
3435
var getShape = require( '@stdlib/ndarray/shape' );
@@ -100,7 +101,7 @@ function assign( x, start, stop ) {
100101
if ( sh.length < 1 ) {
101102
throw new TypeError( 'invalid argument. First argument must be an ndarray having at least one dimension.' );
102103
}
103-
dt = String( getDType( x ) );
104+
dt = resolveStr( getDType( x ) );
104105
if ( !contains( DTYPES.odtypes, dt ) ) {
105106
throw new TypeError( format( 'invalid argument. First argument must have one of the following data types: "%s". Data type: `%s`.', join( DTYPES.odtypes, '", "' ), dt ) );
106107
}
@@ -111,7 +112,7 @@ function assign( x, start, stop ) {
111112
types[ 0 ] = ENUMS.COMPLEX;
112113
} else if ( isndarrayLike( start ) ) {
113114
types[ 0 ] = ENUMS.NDARRAY;
114-
dt = String( getDType( start ) );
115+
dt = resolveStr( getDType( start ) );
115116
if ( !contains( DTYPES.idtypes0, dt ) ) {
116117
throw new TypeError( format( 'invalid argument. Second argument must have one of the following data types: "%s". Data type: `%s`.', join( DTYPES.idtypes0, '", "' ), dt ) );
117118
}
@@ -124,7 +125,7 @@ function assign( x, start, stop ) {
124125
types[ 1 ] = ENUMS.COMPLEX;
125126
} else if ( isndarrayLike( stop ) ) {
126127
types[ 1 ] = ENUMS.NDARRAY;
127-
dt = String( getDType( stop ) );
128+
dt = resolveStr( getDType( stop ) );
128129
if ( !contains( DTYPES.idtypes1, dt ) ) {
129130
throw new TypeError( format( 'invalid argument. Third argument must have one of the following data types: "%s". Data type: `%s`.', join( DTYPES.idtypes1, '", "' ), dt ) );
130131
}
@@ -151,7 +152,7 @@ function assign( x, start, stop ) {
151152
// Case: assign( x, start, stop, endpoint_ndarray )
152153
else if ( isndarrayLike( o ) ) {
153154
endpoint = o;
154-
dt = String( getDType( endpoint ) );
155+
dt = resolveStr( getDType( endpoint ) );
155156
if ( !contains( DTYPES.idtypes2, dt ) ) {
156157
throw new TypeError( format( 'invalid argument. Fourth argument must have one of the following data types: "%s". Data type: `%s`.', join( DTYPES.idtypes2, '", "' ), dt ) );
157158
}
@@ -174,7 +175,7 @@ function assign( x, start, stop ) {
174175
types[ 2 ] = ENUMS.BOOLEAN;
175176
} else if ( isndarrayLike( endpoint ) ) {
176177
types[ 2 ] = ENUMS.NDARRAY;
177-
dt = String( getDType( endpoint ) );
178+
dt = resolveStr( getDType( endpoint ) );
178179
if ( !contains( DTYPES.idtypes2, dt ) ) {
179180
throw new TypeError( format( 'invalid argument. Fourth argument must have one of the following data types: "%s". Data type: `%s`.', join( DTYPES.idtypes2, '", "' ), dt ) );
180181
}
@@ -199,7 +200,7 @@ function assign( x, start, stop ) {
199200

200201
// Resolve argument data types:
201202
dtypes = resolveDataTypes( args.slice( 0, 2 ), types );
202-
dtypes[ 3 ] = getDType( x );
203+
dtypes[ 3 ] = resolveStr( getDType( x ) );
203204

204205
// Resolve the complement of the operation dimensions:
205206
ncsh = nonCoreShape( sh, options.dims );

lib/node_modules/@stdlib/blas/ext/linspace/lib/dtypes.js

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

2121
// MODULES //
2222

23+
var dtypes2strings = require( '@stdlib/ndarray/base/dtypes2strings' );
2324
var dtypes = require( '@stdlib/ndarray/dtypes' );
2425

2526

2627
// MAIN //
2728

2829
var dt = {
29-
'idtypes0': dtypes( 'numeric_and_generic' ), // start of interval
30-
'idtypes1': dtypes( 'numeric_and_generic' ), // end of interval
31-
'idtypes2': dtypes( 'boolean_and_generic' ), // endpoint
32-
'odtypes': dtypes( 'floating_point_and_generic' )
30+
'idtypes0': dtypes2strings( dtypes( 'numeric_and_generic' ) ), // start of interval
31+
'idtypes1': dtypes2strings( dtypes( 'numeric_and_generic' ) ), // end of interval
32+
'idtypes2': dtypes2strings( dtypes( 'boolean_and_generic' ) ), // endpoint
33+
'odtypes': dtypes2strings( dtypes( 'floating_point_and_generic' ) )
3334
};
3435

3536

lib/node_modules/@stdlib/blas/ext/linspace/lib/main.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
3333
var isOrder = require( '@stdlib/ndarray/base/assert/is-order' );
3434
var isDataType = require( '@stdlib/ndarray/base/assert/is-data-type' );
3535
var nonCoreShape = require( '@stdlib/ndarray/base/complement-shape' );
36+
var resolveStr = require( '@stdlib/ndarray/base/dtype-resolve-str' );
3637
var getDType = require( '@stdlib/ndarray/base/dtype' );
3738
var empty = require( '@stdlib/ndarray/empty' );
3839
var contains = require( '@stdlib/array/base/assert/contains' );
@@ -61,7 +62,7 @@ var base = require( './base.js' );
6162
* @param {*} [options.dtype] - output ndarray data type
6263
* @param {string} [options.order] - ndarray order
6364
* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed ndarray dimensions
64-
* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed ndarray dimensions on a per dimension basis
65+
* @param {ArrayLikeObject<string>} [options.submode=["throw"]] - specifies how to handle subscripts which exceed ndarray dimensions on a per dimension basis
6566
* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers
6667
* @throws {TypeError} second argument must be either a number, complex number, or an ndarray-like object
6768
* @throws {TypeError} third argument must be either a number, complex number, or an ndarray-like object
@@ -109,7 +110,7 @@ function linspace( shape, start, stop ) {
109110
types[ 0 ] = ENUMS.COMPLEX;
110111
} else if ( isndarrayLike( start ) ) {
111112
types[ 0 ] = ENUMS.NDARRAY;
112-
dt = String( getDType( start ) );
113+
dt = resolveStr( getDType( start ) );
113114
if ( !contains( DTYPES.idtypes0, dt ) ) {
114115
throw new TypeError( format( 'invalid argument. Second argument must have one of the following data types: "%s". Data type: `%s`.', join( DTYPES.idtypes0, '", "' ), dt ) );
115116
}
@@ -122,7 +123,7 @@ function linspace( shape, start, stop ) {
122123
types[ 1 ] = ENUMS.COMPLEX;
123124
} else if ( isndarrayLike( stop ) ) {
124125
types[ 1 ] = ENUMS.NDARRAY;
125-
dt = String( getDType( stop ) );
126+
dt = resolveStr( getDType( stop ) );
126127
if ( !contains( DTYPES.idtypes1, dt ) ) {
127128
throw new TypeError( format( 'invalid argument. Third argument must have one of the following data types: "%s". Data type: `%s`.', join( DTYPES.idtypes1, '", "' ), dt ) );
128129
}
@@ -149,7 +150,7 @@ function linspace( shape, start, stop ) {
149150
// Case: linspace( shape, start, stop, endpoint_ndarray )
150151
else if ( isndarrayLike( o ) ) {
151152
endpoint = o;
152-
dt = String( getDType( endpoint ) );
153+
dt = resolveStr( getDType( endpoint ) );
153154
if ( !contains( DTYPES.idtypes2, dt ) ) {
154155
throw new TypeError( format( 'invalid argument. Fourth argument must have one of the following data types: "%s". Data type: `%s`.', join( DTYPES.idtypes2, '", "' ), dt ) );
155156
}
@@ -172,7 +173,7 @@ function linspace( shape, start, stop ) {
172173
types[ 2 ] = ENUMS.BOOLEAN;
173174
} else if ( isndarrayLike( endpoint ) ) {
174175
types[ 2 ] = ENUMS.NDARRAY;
175-
dt = String( getDType( endpoint ) );
176+
dt = resolveStr( getDType( endpoint ) );
176177
if ( !contains( DTYPES.idtypes2, dt ) ) {
177178
throw new TypeError( format( 'invalid argument. Fourth argument must have one of the following data types: "%s". Data type: `%s`.', join( DTYPES.idtypes2, '", "' ), dt ) );
178179
}
@@ -187,10 +188,11 @@ function linspace( shape, start, stop ) {
187188
// Resolve options...
188189
if ( opts ) {
189190
if ( hasOwnProp( opts, 'dtype' ) ) {
190-
if ( !isDataType( opts.dtype ) || !contains( DTYPES.odtypes, String( opts.dtype ) ) ) { // eslint-disable-line max-len
191+
dt = resolveStr( opts.dtype );
192+
if ( !isDataType( opts.dtype ) || !contains( DTYPES.odtypes, dt ) ) { // eslint-disable-line max-len
191193
throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'dtype', join( DTYPES.odtypes, '", "' ), opts.dtype ) );
192194
}
193-
options.dtype = opts.dtype;
195+
options.dtype = dt;
194196
}
195197
if ( hasOwnProp( opts, 'order' ) ) {
196198
if ( !isOrder( opts.order ) ) {

lib/node_modules/@stdlib/blas/ext/linspace/lib/resolve_data_types.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var promoteDataTypes = require( '@stdlib/ndarray/base/promote-dtypes' );
2424
var getDType = require( '@stdlib/ndarray/base/dtype' );
25+
var resolveStr = require( '@stdlib/ndarray/base/dtype-resolve-str' );
2526
var complexDataType = require( '@stdlib/complex/dtype' );
2627
var ENUMS = require( './type_enums.js' );
2728

@@ -55,7 +56,7 @@ function resolveDataTypes( args, types ) {
5556
// Why 'float64'? Because we don't have any way of knowing whether a number primitive is intended to be 'float32' or 'float64', and, in order to preserve precision, we simply assume 'float64'. Note that this may lead to undesired type promotion when resolving an output data type...
5657
dt = 'float64';
5758
} else if ( t === ENUMS.NDARRAY ) {
58-
dt = getDType( args[ i ] );
59+
dt = resolveStr( getDType( args[ i ] ) );
5960
} else { // t === ENUMS.COMPLEX
6061
dt = complexDataType( args[ i ] );
6162
if ( dt === null ) {

lib/node_modules/@stdlib/blas/ext/linspace/test/test.main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,6 @@ tape( 'the function throws an error if provided an invalid `dtype` option (endpo
918918
values = [
919919
'5',
920920
'foo',
921-
5,
922921
NaN,
923922
true,
924923
false,

0 commit comments

Comments
 (0)