Skip to content

Commit 55e56f0

Browse files
committed
feat: add support for non-string data types
--- 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: 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent a74c0e2 commit 55e56f0

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

lib/node_modules/@stdlib/ndarray/base/assert/is-real-data-type/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var isRealDataType = require( '@stdlib/ndarray/base/assert/is-real-data-type' );
4242

4343
#### isRealDataType( value )
4444

45-
Tests if an input `value` is a supported ndarray real-valued data type.
45+
Tests if an input value is a supported ndarray real-valued data type.
4646

4747
```javascript
4848
var bool = isRealDataType( 'float32' );

lib/node_modules/@stdlib/ndarray/base/assert/is-real-data-type/lib/main.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ var contains = require( '@stdlib/array/base/assert/contains' ).factory;
2424
var dtypes = require( '@stdlib/ndarray/dtypes' );
2525

2626

27+
// VARIABLES //
28+
29+
var isDataType = contains( dtypes( 'real' ) );
30+
31+
2732
// MAIN //
2833

2934
/**
3035
* Tests whether an input value is a supported ndarray real-valued data type.
3136
*
32-
* @name isRealDataType
33-
* @type {Function}
3437
* @param {*} v - value to test
3538
* @returns {boolean} boolean indicating whether an input value is a supported ndarray real-valued data type
3639
*
@@ -74,7 +77,9 @@ var dtypes = require( '@stdlib/ndarray/dtypes' );
7477
* bool = isRealDataType( 'foo' );
7578
* // returns false
7679
*/
77-
var isRealDataType = contains( dtypes( 'real' ) );
80+
function isRealDataType( v ) {
81+
return isDataType( String( v ) );
82+
}
7883

7984

8085
// EXPORTS //

lib/node_modules/@stdlib/ndarray/base/assert/is-real-data-type/test/test.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24+
var DataType = require( '@stdlib/ndarray/dtype-ctor' );
2425
var isRealDataType = require( './../lib' );
2526

2627

@@ -46,7 +47,17 @@ tape( 'the function returns `true` if provided a supported ndarray real-valued d
4647
'uint8c',
4748
'int16',
4849
'int32',
49-
'int8'
50+
'int8',
51+
52+
new DataType( 'float32' ),
53+
new DataType( 'float64' ),
54+
new DataType( 'uint16' ),
55+
new DataType( 'uint32' ),
56+
new DataType( 'uint8' ),
57+
new DataType( 'uint8c' ),
58+
new DataType( 'int16' ),
59+
new DataType( 'int32' ),
60+
new DataType( 'int8' )
5061
];
5162
for ( i = 0; i < values.length; i++ ) {
5263
bool = isRealDataType( values[ i ] );
@@ -67,6 +78,8 @@ tape( 'the function returns `false` if not provided a supported ndarray real-val
6778
'complex128',
6879
'complex64',
6980

81+
new DataType( 'binary' ),
82+
7083
// Unsupported dtypes:
7184
'float',
7285
'int',

0 commit comments

Comments
 (0)