Skip to content

Commit 1ad91c5

Browse files
committed
Auto-generated commit
1 parent 21d1fe2 commit 1ad91c5

File tree

12 files changed

+733
-0
lines changed

12 files changed

+733
-0
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010

1111
### Features
1212

13+
- [`24c59ca`](https://github.com/stdlib-js/stdlib/commit/24c59ca8f9c70b81c705f4cd981dfd4816c29137) - add `broadcastArrayExceptDimensions` to namespace
14+
- [`0afeede`](https://github.com/stdlib-js/stdlib/commit/0afeedeeaff3c0d7f394b79125d633454fa7f9e3) - add `unaryAddonDispatch` to namespace
15+
- [`8917ae2`](https://github.com/stdlib-js/stdlib/commit/8917ae2818c6864d62edc83cc5b74013d6dfc672) - add `nullaryStrided1dDispatch` to namespace
16+
- [`4da672a`](https://github.com/stdlib-js/stdlib/commit/4da672aa92eaebdef7407e74663126c7c2db6d4a) - add `binaryReduceStrided1dDispatchFactory` to namespace
17+
- [`c611553`](https://github.com/stdlib-js/stdlib/commit/c611553443ef655ec5f0ed8ab9dbe983b7248af1) - add `binaryReduceStrided1dDispatch` to namespace
18+
- [`154866d`](https://github.com/stdlib-js/stdlib/commit/154866dc56a678fbc3d349cd8d2964fe2ef2301d) - add `binaryInputCastingDataType` to namespace
19+
- [`f2c44fb`](https://github.com/stdlib-js/stdlib/commit/f2c44fb0b3c470367bb3f4ff8aef32eaf72e58c3) - add `dtypes2enums` to namespace
20+
- [`882ff45`](https://github.com/stdlib-js/stdlib/commit/882ff45ea084b274ef5efe3e8eed537300162ba6) - add `ndarray/base/dtypes2enums`
1321
- [`cc715fa`](https://github.com/stdlib-js/stdlib/commit/cc715fa508b46f9bc8fbf516ce5185050adc4cf8) - add `ndarray/base/binary-reduce-strided1d-dispatch-factory` [(#7950)](https://github.com/stdlib-js/stdlib/pull/7950)
1422
- [`ce2a417`](https://github.com/stdlib-js/stdlib/commit/ce2a4171ac366e3023a240d01c154f8e9bfdfa5e) - add `ndarray/base/binary-reduce-strided1d-dispatch` [(#7908)](https://github.com/stdlib-js/stdlib/pull/7908)
1523
- [`17e89e8`](https://github.com/stdlib-js/stdlib/commit/17e89e85928ef1e38ad554975c62ea96c15c6c04) - generate loops for mostly safe casts
@@ -519,6 +527,14 @@ A total of 24 issues were closed in this release:
519527

520528
<details>
521529

530+
- [`24c59ca`](https://github.com/stdlib-js/stdlib/commit/24c59ca8f9c70b81c705f4cd981dfd4816c29137) - **feat:** add `broadcastArrayExceptDimensions` to namespace _(by Athan Reines)_
531+
- [`0afeede`](https://github.com/stdlib-js/stdlib/commit/0afeedeeaff3c0d7f394b79125d633454fa7f9e3) - **feat:** add `unaryAddonDispatch` to namespace _(by Athan Reines)_
532+
- [`8917ae2`](https://github.com/stdlib-js/stdlib/commit/8917ae2818c6864d62edc83cc5b74013d6dfc672) - **feat:** add `nullaryStrided1dDispatch` to namespace _(by Athan Reines)_
533+
- [`4da672a`](https://github.com/stdlib-js/stdlib/commit/4da672aa92eaebdef7407e74663126c7c2db6d4a) - **feat:** add `binaryReduceStrided1dDispatchFactory` to namespace _(by Athan Reines)_
534+
- [`c611553`](https://github.com/stdlib-js/stdlib/commit/c611553443ef655ec5f0ed8ab9dbe983b7248af1) - **feat:** add `binaryReduceStrided1dDispatch` to namespace _(by Athan Reines)_
535+
- [`154866d`](https://github.com/stdlib-js/stdlib/commit/154866dc56a678fbc3d349cd8d2964fe2ef2301d) - **feat:** add `binaryInputCastingDataType` to namespace _(by Athan Reines)_
536+
- [`f2c44fb`](https://github.com/stdlib-js/stdlib/commit/f2c44fb0b3c470367bb3f4ff8aef32eaf72e58c3) - **feat:** add `dtypes2enums` to namespace _(by Athan Reines)_
537+
- [`882ff45`](https://github.com/stdlib-js/stdlib/commit/882ff45ea084b274ef5efe3e8eed537300162ba6) - **feat:** add `ndarray/base/dtypes2enums` _(by Athan Reines)_
522538
- [`1e5c77a`](https://github.com/stdlib-js/stdlib/commit/1e5c77a53d8b81c99ca0be177b1e828dbfc12173) - **refactor:** use array utility _(by Athan Reines)_
523539
- [`351db28`](https://github.com/stdlib-js/stdlib/commit/351db2889ebd45eb0dc55efd4edb1e4d6e20daa7) - **refactor:** use array utility _(by Athan Reines)_
524540
- [`01bc84c`](https://github.com/stdlib-js/stdlib/commit/01bc84cc252dbb2e46ff575e10ceb45a9a19cb92) - **refactor:** use array utility _(by Athan Reines)_

base/dtypes2enums/README.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# dtypes2enums
22+
23+
> Resolve a list of [data type][@stdlib/ndarray/dtypes] enumeration constants.
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26+
27+
<section class="intro">
28+
29+
</section>
30+
31+
<!-- /.intro -->
32+
33+
<!-- Package usage documentation. -->
34+
35+
<section class="usage">
36+
37+
## Usage
38+
39+
```javascript
40+
var dtypes2enums = require( '@stdlib/ndarray/base/dtypes2enums' );
41+
```
42+
43+
#### dtypes2enums( dtypes )
44+
45+
Resolves a list of [data type][@stdlib/ndarray/dtypes] enumeration constants.
46+
47+
```javascript
48+
var out = dtypes2enums( [ 'float32', 'float64' ] );
49+
// returns [...]
50+
```
51+
52+
The function accepts the following arguments:
53+
54+
- **dtypes**: an array of [data types][@stdlib/ndarray/dtypes].
55+
56+
If the function is unable to resolve an enumeration constant for a provided [data type][@stdlib/ndarray/dtypes], the corresponding element in the returned array will be `null`.
57+
58+
```javascript
59+
var out = dtypes2enums( [ 'foo', 'bar' ] );
60+
// returns [ null, null ]
61+
```
62+
63+
</section>
64+
65+
<!-- /.usage -->
66+
67+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
68+
69+
<section class="notes">
70+
71+
</section>
72+
73+
<!-- /.notes -->
74+
75+
<!-- Package usage examples. -->
76+
77+
<section class="examples">
78+
79+
## Examples
80+
81+
<!-- eslint no-undef: "error" -->
82+
83+
```javascript
84+
var dtypes = require( '@stdlib/ndarray/dtypes' );
85+
var logEach = require( '@stdlib/console/log-each' );
86+
var dtypes2enums = require( '@stdlib/ndarray/base/dtypes2enums' );
87+
88+
// Get the list of supported data types:
89+
var dt = dtypes();
90+
91+
// Resolve enumeration constants:
92+
var enums = dtypes2enums( dt );
93+
94+
// Print the results:
95+
logEach( '%s => %d', dt, enums );
96+
```
97+
98+
</section>
99+
100+
<!-- /.examples -->
101+
102+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
103+
104+
<section class="references">
105+
106+
</section>
107+
108+
<!-- /.references -->
109+
110+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
111+
112+
<section class="related">
113+
114+
</section>
115+
116+
<!-- /.related -->
117+
118+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
119+
120+
<section class="links">
121+
122+
[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray/tree/main/dtypes
123+
124+
</section>
125+
126+
<!-- /.links -->
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var isIntegerArray = require( '@stdlib/assert/is-integer-array' ).primitives;
25+
var nCartesianProduct = require( '@stdlib/array/base/n-cartesian-product' );
26+
var dtypes = require( './../../../dtypes' );
27+
var pkg = require( './../package.json' ).name;
28+
var dtypes2enums = require( './../lib' );
29+
30+
31+
// VARIABLES //
32+
33+
var DTYPES = dtypes();
34+
35+
36+
// MAIN //
37+
38+
bench( pkg+'::one_dtype', function benchmark( b ) {
39+
var v;
40+
var i;
41+
42+
b.tic();
43+
for ( i = 0; i < b.iterations; i++ ) {
44+
v = dtypes2enums( [ DTYPES[ i%DTYPES.length ] ] );
45+
if ( typeof v !== 'object' ) {
46+
b.fail( 'should return an array' );
47+
}
48+
}
49+
b.toc();
50+
if ( !isIntegerArray( v ) ) {
51+
b.fail( 'should return an array' );
52+
}
53+
b.pass( 'benchmark finished' );
54+
b.end();
55+
});
56+
57+
bench( pkg+'::two_dtypes', function benchmark( b ) {
58+
var values;
59+
var v;
60+
var i;
61+
62+
values = nCartesianProduct( DTYPES, DTYPES );
63+
64+
b.tic();
65+
for ( i = 0; i < b.iterations; i++ ) {
66+
v = dtypes2enums( values[ i%values.length ] );
67+
if ( typeof v !== 'object' ) {
68+
b.fail( 'should return an array' );
69+
}
70+
}
71+
b.toc();
72+
if ( !isIntegerArray( v ) ) {
73+
b.fail( 'should return an array' );
74+
}
75+
b.pass( 'benchmark finished' );
76+
b.end();
77+
});
78+
79+
bench( pkg+'::three_dtypes', function benchmark( b ) {
80+
var values;
81+
var v;
82+
var i;
83+
84+
values = nCartesianProduct( DTYPES, DTYPES, DTYPES );
85+
86+
b.tic();
87+
for ( i = 0; i < b.iterations; i++ ) {
88+
v = dtypes2enums( values[ i%values.length ] );
89+
if ( typeof v !== 'object' ) {
90+
b.fail( 'should return an array' );
91+
}
92+
}
93+
b.toc();
94+
if ( !isIntegerArray( v ) ) {
95+
b.fail( 'should return an array' );
96+
}
97+
b.pass( 'benchmark finished' );
98+
b.end();
99+
});
100+
101+
bench( pkg+'::four_dtypes', function benchmark( b ) {
102+
var values;
103+
var v;
104+
var i;
105+
106+
values = nCartesianProduct( DTYPES, DTYPES, DTYPES, DTYPES );
107+
108+
b.tic();
109+
for ( i = 0; i < b.iterations; i++ ) {
110+
v = dtypes2enums( values[ i%values.length ] );
111+
if ( typeof v !== 'object' ) {
112+
b.fail( 'should return an array' );
113+
}
114+
}
115+
b.toc();
116+
if ( !isIntegerArray( v ) ) {
117+
b.fail( 'should return an array' );
118+
}
119+
b.pass( 'benchmark finished' );
120+
b.end();
121+
});

base/dtypes2enums/docs/repl.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
{{alias}}( dtypes )
3+
Resolves a list of data type enumeration constants.
4+
5+
If the function is unable to resolve an enumeration constant for a provided
6+
data type, the corresponding element in the returned array will be `null`.
7+
8+
Parameters
9+
----------
10+
dtypes: Array<string>
11+
List of data types.
12+
13+
Returns
14+
-------
15+
out: Array<integer>
16+
Results.
17+
18+
Examples
19+
--------
20+
> var out = {{alias}}( [ 'float32', 'float64' ] )
21+
[...]
22+
> out = {{alias}}( [ 'foo', 'bar' ] )
23+
[ null, null ]
24+
25+
See Also
26+
--------
27+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 4.1
20+
21+
/// <reference types="@stdlib/types"/>
22+
23+
import { DataType } from '@stdlib/types/ndarray';
24+
25+
/**
26+
* Resolves a list of data type enumeration constants.
27+
*
28+
* ## Notes
29+
*
30+
* - If the function is unable to resolve an enumeration constant for a provided data type, the corresponding element in the returned array will be `null`.
31+
*
32+
* @param dtypes - list of data types
33+
* @returns results
34+
*
35+
* @example
36+
* var out = dtypes2enums( [ 'float32', 'float64' ] );
37+
* // returns [...]
38+
*
39+
* @example
40+
* var out = dtypes2enums( [ 'foo', 'bar' ] );
41+
* // returns [ null, null ]
42+
*/
43+
declare function dtypes2enums( dtypes: ArrayLike<DataType> ): Array<number>;
44+
45+
46+
// EXPORTS //
47+
48+
export = dtypes2enums;

0 commit comments

Comments
 (0)