Skip to content

feat: add boolean dtype support to strided/dtypes #2508

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 5 commits into from
Jul 4, 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
18 changes: 7 additions & 11 deletions lib/node_modules/@stdlib/strided/dtypes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@license Apache-2.0

Copyright (c) 2020 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 @@ -46,12 +46,13 @@ Returns a list of strided array data types.

```javascript
var out = dtypes();
// returns [ 'binary', 'complex64', 'complex128', 'float32', 'float64', 'generic', 'int16', 'int32', 'int8', 'uint16', 'uint32', 'uint8', 'uint8c' ]
// e.g., returns [ 'binary', 'bool', 'complex64', ... ]
```

The output `array` contains the following data types:
The output array contains the following data types:

- `binary`: binary.
- `bool`: boolean values.
- `complex64`: single-precision complex floating-point numbers.
- `complex128`: double-precision complex floating-point numbers.
- `float32`: single-precision floating-point numbers.
Expand Down Expand Up @@ -86,17 +87,12 @@ The output `array` contains the following data types:
<!-- eslint no-undef: "error" -->

```javascript
var indexOf = require( '@stdlib/utils/index-of' );
var contains = require( '@stdlib/array/base/assert/contains' ).factory;
var dtypes = require( '@stdlib/strided/dtypes' );

var DTYPES = dtypes();
var bool;
var isdtype = contains( dtypes() );

function isdtype( str ) {
return ( indexOf( DTYPES, str ) >= 0 );
}

bool = isdtype( 'float64' );
var bool = isdtype( 'float64' );
// returns true

bool = isdtype( 'int16' );
Expand Down
1 change: 1 addition & 0 deletions lib/node_modules/@stdlib/strided/dtypes/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
The output array contains the following data types:

- binary: binary.
- bool: boolean values.
- complex64: single-precision complex floating-point numbers.
- complex128: double-precision complex floating-point numbers.
- float32: single-precision floating-point numbers.
Expand Down
11 changes: 3 additions & 8 deletions lib/node_modules/@stdlib/strided/dtypes/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@

'use strict';

var indexOf = require( '@stdlib/utils/index-of' );
var contains = require( '@stdlib/array/base/assert/contains' ).factory;
var dtypes = require( './../lib' );

var DTYPES = dtypes();
var bool;
var isdtype = contains( dtypes() );

function isdtype( str ) {
return ( indexOf( DTYPES, str ) >= 0 );
}

bool = isdtype( 'float64' );
var bool = isdtype( 'float64' );
console.log( bool );
// => true

Expand Down
3 changes: 2 additions & 1 deletion lib/node_modules/@stdlib/strided/dtypes/lib/dtypes.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
"binary",
"binary",
"bool",
"complex64",
"complex128",
"float32",
Expand Down
7 changes: 5 additions & 2 deletions lib/node_modules/@stdlib/strided/dtypes/test/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2020 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 @@ -43,7 +43,9 @@ var DTYPES = [
'float64',

'complex64',
'complex128'
'complex128',

'bool'
];


Expand All @@ -61,6 +63,7 @@ tape( 'the function returns a list of strided array data type strings', function

expected = [
'binary',
'bool',
'complex64',
'complex128',
'float32',
Expand Down
Loading