Skip to content

Commit 354c296

Browse files
committed
Auto-generated commit
1 parent 71b79f8 commit 354c296

4 files changed

Lines changed: 116 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-12-27)
7+
## Unreleased (2025-12-28)
88

99
<section class="features">
1010

@@ -667,6 +667,7 @@ A total of 37 issues were closed in this release:
667667

668668
<details>
669669

670+
- [`d3a0548`](https://github.com/stdlib-js/stdlib/commit/d3a05480e872e702db968bbe9f4d3610e8aed50d) - **test:** add tests for DataType instances _(by Athan Reines)_
670671
- [`d80dfe4`](https://github.com/stdlib-js/stdlib/commit/d80dfe41a1ef87da9fdf8c4cb88c3036134faa2f) - **docs:** improve doctests for ndarray instances in `ndarray/any-by` [(#9399)](https://github.com/stdlib-js/stdlib/pull/9399) _(by Rohit R Bhat, Athan Reines)_
671672
- [`45264d0`](https://github.com/stdlib-js/stdlib/commit/45264d0387509a18856c21c332349f16c8a81086) - **docs:** improve doctests for ndarray instances in `ndarray/some` [(#9388)](https://github.com/stdlib-js/stdlib/pull/9388) _(by kaushal-kumar-it, Athan Reines)_
672673
- [`626f31e`](https://github.com/stdlib-js/stdlib/commit/626f31e5f7aa40d0dc64f48fa3b9c4f87f9bf30c) - **feat:** update `ndarray/base` TypeScript declarations [(#9386)](https://github.com/stdlib-js/stdlib/pull/9386) _(by stdlib-bot)_

base/dtypes2enums/docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
Parameters
99
----------
10-
dtypes: Array<string>
10+
dtypes: Array<string|DataType>
1111
List of data types.
1212

1313
Returns

base/dtypes2enums/lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var resolveEnum = require( './../../../base/dtype-resolve-enum' );
3232
*
3333
* - 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`.
3434
*
35-
* @param {StringArray} dtypes - list of data types
35+
* @param {Array} dtypes - list of data types
3636
* @returns {Array} results
3737
*
3838
* @example

base/dtypes2enums/test/test.js

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

2323
var tape = require( 'tape' );
24+
var DataType = require( './../../../dtype-ctor' );
25+
var structFactory = require( '@stdlib/dstructs/struct' );
2426
var resolveEnum = require( './../../../base/dtype-resolve-enum' );
2527
var dtypes2enums = require( './../lib' );
2628

@@ -33,7 +35,7 @@ tape( 'main export is a function', function test( t ) {
3335
t.end();
3436
});
3537

36-
tape( 'the function converts a list of data types to a list of enumeration constants', function test( t ) {
38+
tape( 'the function converts a list of data types to a list of enumeration constants (strings)', function test( t ) {
3739
var expected;
3840
var actual;
3941
var values;
@@ -64,6 +66,115 @@ tape( 'the function converts a list of data types to a list of enumeration const
6466
t.end();
6567
});
6668

69+
tape( 'the function converts a list of data types to a list of enumeration constants (data type instances, strings)', function test( t ) {
70+
var expected;
71+
var actual;
72+
var values;
73+
var i;
74+
75+
values = [
76+
[ new DataType( 'float32' ), new DataType( 'float64' ) ],
77+
[ new DataType( 'float64' ), new DataType( 'generic' ) ],
78+
[ new DataType( 'int8' ), new DataType( 'uint16' ) ],
79+
[ new DataType( 'float32' ), new DataType( 'complex64' ), new DataType( 'float64' ) ],
80+
[ new DataType( 'generic' ), new DataType( 'complex128' ) ],
81+
[ new DataType( 'float64' ) ]
82+
];
83+
84+
expected = [
85+
[ resolveEnum( 'float32' ), resolveEnum( 'float64' ) ],
86+
[ resolveEnum( 'float64' ), resolveEnum( 'generic' ) ],
87+
[ resolveEnum( 'int8' ), resolveEnum( 'uint16' ) ],
88+
[ resolveEnum( 'float32' ), resolveEnum( 'complex64' ), resolveEnum( 'float64' ) ],
89+
[ resolveEnum( 'generic' ), resolveEnum( 'complex128' ) ],
90+
[ resolveEnum( 'float64' ) ]
91+
];
92+
93+
for ( i = 0; i < values.length; i++ ) {
94+
actual = dtypes2enums( values[ i ] );
95+
t.deepEqual( actual, expected[ i ], 'returns expected value' );
96+
}
97+
t.end();
98+
});
99+
100+
tape( 'the function converts a list of data types to a list of enumeration constants (structs)', function test( t ) {
101+
var expected;
102+
var schemas;
103+
var actual;
104+
var values;
105+
var i;
106+
107+
schemas = [
108+
[
109+
{
110+
'name': 'foo',
111+
'type': 'float64'
112+
}
113+
],
114+
[
115+
{
116+
'name': 'foo',
117+
'type': 'float32'
118+
}
119+
]
120+
];
121+
122+
values = [
123+
[ structFactory( schemas[ 0 ] ) ],
124+
[ structFactory( schemas[ 1 ] ) ]
125+
];
126+
127+
expected = [
128+
[ resolveEnum( 'userdefined_type' ) ],
129+
[ resolveEnum( 'userdefined_type' ) ]
130+
];
131+
132+
for ( i = 0; i < values.length; i++ ) {
133+
actual = dtypes2enums( values[ i ] );
134+
t.deepEqual( actual, expected[ i ], 'returns expected value' );
135+
}
136+
t.end();
137+
});
138+
139+
tape( 'the function converts a list of data types to a list of enumeration constants (data type instances, structs)', function test( t ) {
140+
var expected;
141+
var schemas;
142+
var actual;
143+
var values;
144+
var i;
145+
146+
schemas = [
147+
[
148+
{
149+
'name': 'foo',
150+
'type': 'float64'
151+
}
152+
],
153+
[
154+
{
155+
'name': 'foo',
156+
'type': 'float32'
157+
}
158+
]
159+
];
160+
161+
values = [
162+
[ new DataType( structFactory( schemas[ 0 ] ) ) ],
163+
[ new DataType( structFactory( schemas[ 1 ] ) ) ]
164+
];
165+
166+
expected = [
167+
[ resolveEnum( 'userdefined_type' ) ],
168+
[ resolveEnum( 'userdefined_type' ) ]
169+
];
170+
171+
for ( i = 0; i < values.length; i++ ) {
172+
actual = dtypes2enums( values[ i ] );
173+
t.deepEqual( actual, expected[ i ], 'returns expected value' );
174+
}
175+
t.end();
176+
});
177+
67178
tape( 'if unable to resolve an enumeration constant for a provided data type, the function returns `null` for the corresponding enumeration constant', function test( t ) {
68179
var expected;
69180
var actual;

0 commit comments

Comments
 (0)