Skip to content

Commit 4794f9e

Browse files
committed
test: use functional accessors and ensure support for non-string dtypes
--- 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: na - 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: 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: passed - task: lint_license_headers status: passed ---
1 parent 91a321e commit 4794f9e

File tree

7 files changed

+138
-111
lines changed

7 files changed

+138
-111
lines changed

lib/node_modules/@stdlib/ndarray/base/from-array/README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@ var array2ndarray = require( '@stdlib/ndarray/base/from-array' );
4545
Returns a one-dimensional [ndarray][@stdlib/ndarray/base/ctor] which wraps a provided input array.
4646

4747
```javascript
48+
var getShape = require( '@stdlib/ndarray/shape' );
49+
var getDType = require( '@stdlib/ndarray/dtype' );
50+
4851
var x = array2ndarray( [ 1, 2, 3 ], 'row-major' );
4952
// returns <ndarray>
5053

51-
var sh = x.shape;
54+
var sh = getShape( x );
5255
// returns [ 3 ]
5356

54-
var dt = x.dtype;
57+
var dt = String( getDType( x ) );
5558
// returns 'generic'
5659
```
5760

@@ -81,29 +84,29 @@ The function supports the following parameters:
8184
<!-- eslint no-undef: "error" -->
8285

8386
```javascript
84-
var dtype = require( '@stdlib/ndarray/dtype' );
87+
var getDType = require( '@stdlib/ndarray/dtype' );
8588
var typedarray = require( '@stdlib/array/typed' );
8689
var array2ndarray = require( '@stdlib/ndarray/base/from-array' );
8790

8891
var buf = typedarray( 10, 'float64' );
8992
var x = array2ndarray( buf, 'row-major' );
90-
console.log( dtype( x ) );
91-
// => 'float64'
93+
var dt = String( getDType( x ) );
94+
// returns 'float64'
9295

9396
buf = typedarray( 10, 'int32' );
9497
x = array2ndarray( buf, 'row-major' );
95-
console.log( dtype( x ) );
96-
// => 'int32'
98+
dt = String( getDType( x ) );
99+
// returns 'int32'
97100

98101
buf = typedarray( 10, 'complex128' );
99102
x = array2ndarray( buf, 'row-major' );
100-
console.log( dtype( x ) );
101-
// => 'complex128'
103+
dt = String( getDType( x ) );
104+
// returns 'complex128'
102105

103106
buf = typedarray( 10, 'bool' );
104107
x = array2ndarray( buf, 'row-major' );
105-
console.log( dtype( x ) );
106-
// => 'bool'
108+
dt = String( getDType( x ) );
109+
// returns 'bool'
107110
```
108111

109112
</section>

lib/node_modules/@stdlib/ndarray/base/from-array/docs/types/index.d.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ import { float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray
3131
* @returns one-dimensional ndarray
3232
*
3333
* @example
34+
* var getDType = require( '@stdlib/ndarray/dtype' );
3435
* var Float64Array = require( '@stdlib/array/float64' );
3536
*
3637
* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
3738
*
3839
* var x = array2ndarray( arr, 'row-major' );
3940
* // returns <ndarray>
4041
*
41-
* var dt = x.dtype;
42+
* var dt = String( getDType( x ) );
4243
* // returns 'float64'
4344
*/
4445
declare function array2ndarray( buf: Float64Array, order: Order ): float64ndarray;
@@ -51,14 +52,15 @@ declare function array2ndarray( buf: Float64Array, order: Order ): float64ndarra
5152
* @returns one-dimensional ndarray
5253
*
5354
* @example
55+
* var getDType = require( '@stdlib/ndarray/dtype' );
5456
* var Float32Array = require( '@stdlib/array/float32' );
5557
*
5658
* var arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] );
5759
*
5860
* var x = array2ndarray( arr, 'row-major' );
5961
* // returns <ndarray>
6062
*
61-
* var dt = x.dtype;
63+
* var dt = String( getDType( x ) );
6264
* // returns 'float32'
6365
*/
6466
declare function array2ndarray( buf: Float32Array, order: Order ): float32ndarray;
@@ -71,14 +73,15 @@ declare function array2ndarray( buf: Float32Array, order: Order ): float32ndarra
7173
* @returns one-dimensional ndarray
7274
*
7375
* @example
76+
* var getDType = require( '@stdlib/ndarray/dtype' );
7477
* var Complex128Array = require( '@stdlib/array/complex128' );
7578
*
7679
* var arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] );
7780
*
7881
* var x = array2ndarray( arr, 'row-major' );
7982
* // returns <ndarray>
8083
*
81-
* var dt = x.dtype;
84+
* var dt = String( getDType( x ) );
8285
* // returns 'complex128'
8386
*/
8487
declare function array2ndarray( buf: Complex128Array, order: Order ): complex128ndarray;
@@ -91,14 +94,15 @@ declare function array2ndarray( buf: Complex128Array, order: Order ): complex128
9194
* @returns one-dimensional ndarray
9295
*
9396
* @example
97+
* var getDType = require( '@stdlib/ndarray/dtype' );
9498
* var Complex64Array = require( '@stdlib/array/complex64' );
9599
*
96100
* var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
97101
*
98102
* var x = array2ndarray( arr, 'row-major' );
99103
* // returns <ndarray>
100104
*
101-
* var dt = x.dtype;
105+
* var dt = String( getDType( x ) );
102106
* // returns 'complex64'
103107
*/
104108
declare function array2ndarray( buf: Complex64Array, order: Order ): complex64ndarray;
@@ -111,14 +115,15 @@ declare function array2ndarray( buf: Complex64Array, order: Order ): complex64nd
111115
* @returns one-dimensional ndarray
112116
*
113117
* @example
118+
* var getDType = require( '@stdlib/ndarray/dtype' );
114119
* var Int32Array = require( '@stdlib/array/int32' );
115120
*
116121
* var arr = new Int32Array( [ 1, 2, 3, 4 ] );
117122
*
118123
* var x = array2ndarray( arr, 'row-major' );
119124
* // returns <ndarray>
120125
*
121-
* var dt = x.dtype;
126+
* var dt = String( getDType( x ) );
122127
* // returns 'int32'
123128
*/
124129
declare function array2ndarray( buf: Int32Array, order: Order ): int32ndarray;
@@ -131,14 +136,15 @@ declare function array2ndarray( buf: Int32Array, order: Order ): int32ndarray;
131136
* @returns one-dimensional ndarray
132137
*
133138
* @example
139+
* var getDType = require( '@stdlib/ndarray/dtype' );
134140
* var Int16Array = require( '@stdlib/array/int16' );
135141
*
136142
* var arr = new Int16Array( [ 1, 2, 3, 4 ] );
137143
*
138144
* var x = array2ndarray( arr, 'row-major' );
139145
* // returns <ndarray>
140146
*
141-
* var dt = x.dtype;
147+
* var dt = String( getDType( x ) );
142148
* // returns 'int16'
143149
*/
144150
declare function array2ndarray( buf: Int16Array, order: Order ): int16ndarray;
@@ -151,14 +157,15 @@ declare function array2ndarray( buf: Int16Array, order: Order ): int16ndarray;
151157
* @returns one-dimensional ndarray
152158
*
153159
* @example
160+
* var getDType = require( '@stdlib/ndarray/dtype' );
154161
* var Int8Array = require( '@stdlib/array/int8' );
155162
*
156163
* var arr = new Int8Array( [ 1, 2, 3, 4 ] );
157164
*
158165
* var x = array2ndarray( arr, 'row-major' );
159166
* // returns <ndarray>
160167
*
161-
* var dt = x.dtype;
168+
* var dt = String( getDType( x ) );
162169
* // returns 'int8'
163170
*/
164171
declare function array2ndarray( buf: Int8Array, order: Order ): int8ndarray;
@@ -171,14 +178,15 @@ declare function array2ndarray( buf: Int8Array, order: Order ): int8ndarray;
171178
* @returns one-dimensional ndarray
172179
*
173180
* @example
181+
* var getDType = require( '@stdlib/ndarray/dtype' );
174182
* var Uint32Array = require( '@stdlib/array/uint32' );
175183
*
176184
* var arr = new Uint32Array( [ 1, 2, 3, 4 ] );
177185
*
178186
* var x = array2ndarray( arr, 'row-major' );
179187
* // returns <ndarray>
180188
*
181-
* var dt = x.dtype;
189+
* var dt = String( getDType( x ) );
182190
* // returns 'uint32'
183191
*/
184192
declare function array2ndarray( buf: Uint32Array, order: Order ): uint32ndarray;
@@ -191,14 +199,15 @@ declare function array2ndarray( buf: Uint32Array, order: Order ): uint32ndarray;
191199
* @returns one-dimensional ndarray
192200
*
193201
* @example
202+
* var getDType = require( '@stdlib/ndarray/dtype' );
194203
* var Uint16Array = require( '@stdlib/array/uint16' );
195204
*
196205
* var arr = new Uint16Array( [ 1, 2, 3, 4 ] );
197206
*
198207
* var x = array2ndarray( arr, 'row-major' );
199208
* // returns <ndarray>
200209
*
201-
* var dt = x.dtype;
210+
* var dt = String( getDType( x ) );
202211
* // returns 'uint16'
203212
*/
204213
declare function array2ndarray( buf: Uint16Array, order: Order ): uint16ndarray;
@@ -211,14 +220,15 @@ declare function array2ndarray( buf: Uint16Array, order: Order ): uint16ndarray;
211220
* @returns one-dimensional ndarray
212221
*
213222
* @example
223+
* var getDType = require( '@stdlib/ndarray/dtype' );
214224
* var Uint8Array = require( '@stdlib/array/uint8' );
215225
*
216226
* var arr = new Uint8Array( [ 1, 2, 3, 4 ] );
217227
*
218228
* var x = array2ndarray( arr, 'row-major' );
219229
* // returns <ndarray>
220230
*
221-
* var dt = x.dtype;
231+
* var dt = String( getDType( x ) );
222232
* // returns 'uint8'
223233
*/
224234
declare function array2ndarray( buf: Uint8Array, order: Order ): uint8ndarray;
@@ -231,14 +241,15 @@ declare function array2ndarray( buf: Uint8Array, order: Order ): uint8ndarray;
231241
* @returns one-dimensional ndarray
232242
*
233243
* @example
244+
* var getDType = require( '@stdlib/ndarray/dtype' );
234245
* var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
235246
*
236247
* var arr = new Uint8ClampedArray( [ 1, 2, 3, 4 ] );
237248
*
238249
* var x = array2ndarray( arr, 'row-major' );
239250
* // returns <ndarray>
240251
*
241-
* var dt = x.dtype;
252+
* var dt = String( getDType( x ) );
242253
* // returns 'uint8c'
243254
*/
244255
declare function array2ndarray( buf: Uint8ClampedArray, order: Order ): uint8cndarray;
@@ -251,14 +262,15 @@ declare function array2ndarray( buf: Uint8ClampedArray, order: Order ): uint8cnd
251262
* @returns one-dimensional ndarray
252263
*
253264
* @example
265+
* var getDType = require( '@stdlib/ndarray/dtype' );
254266
* var BooleanArray = require( '@stdlib/array/bool' );
255267
*
256268
* var arr = new BooleanArray( [ true, false, true, false ] );
257269
*
258270
* var x = array2ndarray( arr, 'row-major' );
259271
* // returns <ndarray>
260272
*
261-
* var dt = x.dtype;
273+
* var dt = String( getDType( x ) );
262274
* // returns 'bool'
263275
*/
264276
declare function array2ndarray( buf: BooleanArray, order: Order ): boolndarray;
@@ -271,12 +283,14 @@ declare function array2ndarray( buf: BooleanArray, order: Order ): boolndarray;
271283
* @returns one-dimensional ndarray
272284
*
273285
* @example
286+
* var getDType = require( '@stdlib/ndarray/dtype' );
287+
*
274288
* var arr = [ 1, 2, 3, 4 ];
275289
*
276290
* var x = array2ndarray( arr, 'row-major' );
277291
* // returns <ndarray>
278292
*
279-
* var dt = x.dtype;
293+
* var dt = String( getDType( x ) );
280294
* // returns 'generic'
281295
*/
282296
declare function array2ndarray<T = unknown>( buf: Array<T> | Collection<T> | AccessorArrayLike<T>, order: Order ): genericndarray<T>;

lib/node_modules/@stdlib/ndarray/base/from-array/docs/types/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import array2ndarray = require( './index' );
3535
array2ndarray( zeros( 1, 'uint16' ), 'row-major' ); // $ExpectType uint16ndarray
3636
array2ndarray( zeros( 1, 'uint8' ), 'row-major' ); // $ExpectType uint8ndarray
3737
array2ndarray( zeros( 1, 'uint8c' ), 'row-major' ); // $ExpectType uint8cndarray
38-
array2ndarray( zeros( 1, 'generic' ), 'row-major' ); // $ExpectType genericndarray<number>
38+
array2ndarray<number>( zeros( 1, 'generic' ), 'row-major' ); // $ExpectType genericndarray<number>
3939
}
4040

4141
// The compiler throws an error if the function is provided a second argument which is not a recognized/supported order...

lib/node_modules/@stdlib/ndarray/base/from-array/examples/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@
1818

1919
'use strict';
2020

21-
var dtype = require( '@stdlib/ndarray/dtype' );
21+
var getDType = require( '@stdlib/ndarray/dtype' );
2222
var typedarray = require( '@stdlib/array/typed' );
2323
var array2ndarray = require( './../lib' );
2424

2525
var buf = typedarray( 10, 'float64' );
2626
var x = array2ndarray( buf, 'row-major' );
27-
console.log( dtype( x ) );
27+
console.log( String( getDType( x ) ) );
2828
// => 'float64'
2929

3030
buf = typedarray( 10, 'int32' );
3131
x = array2ndarray( buf, 'row-major' );
32-
console.log( dtype( x ) );
32+
console.log( String( getDType( x ) ) );
3333
// => 'int32'
3434

3535
buf = typedarray( 10, 'complex128' );
3636
x = array2ndarray( buf, 'row-major' );
37-
console.log( dtype( x ) );
37+
console.log( String( getDType( x ) ) );
3838
// => 'complex128'
3939

4040
buf = typedarray( 10, 'bool' );
4141
x = array2ndarray( buf, 'row-major' );
42-
console.log( dtype( x ) );
42+
console.log( String( getDType( x ) ) );
4343
// => 'bool'

lib/node_modules/@stdlib/ndarray/base/from-array/lib/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424
* @module @stdlib/ndarray/base/from-array
2525
*
2626
* @example
27+
* var getDType = require( '@stdlib/ndarray/dtype' );
2728
* var array2ndarray = require( '@stdlib/ndarray/base/from-array' );
2829
*
2930
* var arr = [ 1, 2, 3 ];
3031
*
3132
* var x = array2ndarray( arr, 'row-major' );
3233
* // returns <ndarray>
3334
*
34-
* var dt = x.dtype;
35+
* var dt = String( getDType( x ) );
3536
* // returns 'generic'
3637
*/
3738

lib/node_modules/@stdlib/ndarray/base/from-array/lib/main.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,26 @@ var ndarray = require( '@stdlib/ndarray/base/ctor' );
3434
* @returns {ndarray} ndarray
3535
*
3636
* @example
37+
* var getDType = require( '@stdlib/ndarray/dtype' );
38+
*
3739
* var arr = [ 1, 2, 3 ];
3840
*
3941
* var x = array2ndarray( arr, 'row-major' );
4042
* // returns <ndarray>
4143
*
42-
* var dt = x.dtype;
44+
* var dt = String( getDType( x ) );
4345
* // returns 'generic'
4446
*
4547
* @example
48+
* var getDType = require( '@stdlib/ndarray/dtype' );
4649
* var Float64Array = require( '@stdlib/array/float64' );
4750
*
4851
* var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] );
4952
*
5053
* var x = array2ndarray( arr, 'row-major' );
5154
* // returns <ndarray>
5255
*
53-
* var dt = x.dtype;
56+
* var dt = String( getDType( x ) );
5457
* // returns 'float64'
5558
*/
5659
function array2ndarray( buf, order ) {

0 commit comments

Comments
 (0)