Skip to content

feat: add boolean dtype support to ndarray/defaults #2551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/node_modules/@stdlib/ndarray/defaults/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@license Apache-2.0

Copyright (c) 2023 The Stdlib Authors.
Copyright (c) 2024 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -62,6 +62,7 @@ The returned object has the following properties:
- **integer**: default integer data type.
- **signed_integer**: default signed integer data type.
- **unsigned_integer**: default unsigned integer data type.
- **boolean**: default boolean data type.

- **order**: default memory layout.

Expand Down Expand Up @@ -139,6 +140,10 @@ console.log( x.dtype );
opts.dtype = o.dtypes.unsigned_integer;
x = array( buf, opts );
console.log( x.dtype );

opts.dtype = o.dtypes.boolean;
x = array( buf, opts );
console.log( x.dtype );
```

</section>
Expand Down
3 changes: 3 additions & 0 deletions lib/node_modules/@stdlib/ndarray/defaults/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
out.dtypes.unsigned_integer: string
Default unsigned integer data type.

out.dtypes.boolean: string
Default boolean data type.

out.order: string
Default memory layout.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2023 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,6 +66,11 @@
* Default unsigned integer data type.
*/
unsigned_integer: 'uint32';

/**
* Default boolean value data type.
*/
boolean: 'bool';
}

/**
Expand Down Expand Up @@ -118,7 +123,7 @@
* var v = defaults.get( 'order' );
* // returns <string>
*/
get( name: string ): any;

Check warning on line 126 in lib/node_modules/@stdlib/ndarray/defaults/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected any. Specify a different type
}

/**
Expand Down
6 changes: 5 additions & 1 deletion lib/node_modules/@stdlib/ndarray/defaults/examples/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2023 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,3 +53,7 @@ console.log( x.dtype );
opts.dtype = o.dtypes.unsigned_integer;
x = array( buf, opts );
console.log( x.dtype );

opts.dtype = o.dtypes.boolean;
x = array( buf, opts );
console.log( x.dtype );
3 changes: 2 additions & 1 deletion lib/node_modules/@stdlib/ndarray/defaults/lib/get.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2023 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,6 +36,7 @@ var HASH = {
'dtypes.integer': DEFAULTS.dtypes.integer,
'dtypes.signed_integer': DEFAULTS.dtypes.signed_integer,
'dtypes.unsigned_integer': DEFAULTS.dtypes.unsigned_integer,
'dtypes.boolean': DEFAULTS.dtypes.boolean,
'order': DEFAULTS.order,
'casting': DEFAULTS.casting,
'index_mode': DEFAULTS.index_mode
Expand Down
5 changes: 3 additions & 2 deletions lib/node_modules/@stdlib/ndarray/defaults/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2023 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,7 +41,8 @@ function defaults() {
'complex_floating_point': 'complex128',
'integer': 'int32',
'signed_integer': 'int32',
'unsigned_integer': 'uint32'
'unsigned_integer': 'uint32',
'boolean': 'bool'
},

// Memory layout:
Expand Down
4 changes: 3 additions & 1 deletion lib/node_modules/@stdlib/ndarray/defaults/test/test.get.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2023 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,6 +54,7 @@ tape( 'if provided a recognized setting, the function returns a default value',
'dtypes.integer',
'dtypes.signed_integer',
'dtypes.unsigned_integer',
'dtypes.boolean',

'casting',
'order',
Expand All @@ -69,6 +70,7 @@ tape( 'if provided a recognized setting, the function returns a default value',
DEFAULTS.dtypes.integer,
DEFAULTS.dtypes.signed_integer,
DEFAULTS.dtypes.unsigned_integer,
DEFAULTS.dtypes.boolean,

DEFAULTS.casting,
DEFAULTS.order,
Expand Down
5 changes: 4 additions & 1 deletion lib/node_modules/@stdlib/ndarray/defaults/test/test.main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2023 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,6 +66,9 @@ tape( 'the function returns default ndarray settings', function test( t ) {
t.strictEqual( hasOwnProp( o.dtypes, 'unsigned_integer' ), true, 'has property' );
t.strictEqual( typeof o.dtypes.unsigned_integer, 'string', 'returns expected value' );

t.strictEqual( hasOwnProp( o.dtypes, 'boolean' ), true, 'has property' );
t.strictEqual( typeof o.dtypes.boolean, 'string', 'returns expected value' );

t.strictEqual( hasOwnProp( o, 'order' ), true, 'has property' );
t.strictEqual( typeof o.order, 'string', 'returns expected value' );

Expand Down
Loading