Skip to content

Commit 5e2bbef

Browse files
committed
fix: add missing boolean array support
--- 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 4b99e9c commit 5e2bbef

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

lib/node_modules/@stdlib/ndarray/base/ctor/lib/tostring.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ var CTORS = {
4040
'generic': '[ {{data}} ]',
4141
'binary': 'new Buffer( [ {{data}} ] )',
4242
'complex64': 'new Complex64Array( [ {{data}} ] )',
43-
'complex128': 'new Complex128Array( [ {{data}} ] )'
43+
'complex128': 'new Complex128Array( [ {{data}} ] )',
44+
'bool': 'new BooleanArray( [ {{data}} ] )'
4445
};
4546

4647

lib/node_modules/@stdlib/ndarray/base/ctor/test/test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var Float64Array = require( '@stdlib/array/float64' );
2626
var Uint8Array = require( '@stdlib/array/uint8' );
2727
var Complex64Array = require( '@stdlib/array/complex64' );
2828
var Complex128Array = require( '@stdlib/array/complex128' );
29+
var BooleanArray = require( '@stdlib/array/bool' );
2930
var Complex64 = require( '@stdlib/complex/float32/ctor' );
3031
var Complex128 = require( '@stdlib/complex/float64/ctor' );
3132
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
@@ -3445,6 +3446,37 @@ tape( 'an ndarray has a custom `toString()` method (complex type)', function tes
34453446
t.end();
34463447
});
34473448

3449+
tape( 'an ndarray has a custom `toString()` method (boolean type)', function test( t ) {
3450+
var expected;
3451+
var strides;
3452+
var actual;
3453+
var buffer;
3454+
var offset;
3455+
var dtype;
3456+
var order;
3457+
var shape;
3458+
var arr;
3459+
3460+
dtype = 'bool';
3461+
buffer = new BooleanArray( [ true, false, true, false ] );
3462+
shape = [ 2, 2 ];
3463+
order = 'row-major';
3464+
strides = [ 2, 1 ];
3465+
offset = 0;
3466+
3467+
arr = ndarray( dtype, buffer, shape, strides, offset, order );
3468+
3469+
t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' );
3470+
t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' );
3471+
t.strictEqual( isFunction( arr.toString ), true, 'has method' );
3472+
3473+
expected = 'ndarray( \'bool\', new BooleanArray( [ true, false, true, false ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )';
3474+
actual = arr.toString();
3475+
t.strictEqual( actual, expected, 'returns expected value' );
3476+
3477+
t.end();
3478+
});
3479+
34483480
tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) {
34493481
var expected;
34503482
var strides;

0 commit comments

Comments
 (0)