Skip to content

Commit 1b87b9d

Browse files
committed
Auto-generated commit
1 parent 41a68ad commit 1b87b9d

File tree

10 files changed

+272
-15
lines changed

10 files changed

+272
-15
lines changed

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

.gitignore

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,12 @@ jsconfig.json
188188
# Other editor files #
189189
######################
190190
.idea/
191-
192-
# Cursor #
193-
##########
191+
.cursor
194192
.cursorignore
193+
.windsurfrules
194+
.clinerules
195+
196+
# AI coding agents #
197+
####################
198+
CLAUDE.md
199+
GEMINI.md

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,50 @@
22

33
> Package changelog.
44
5+
<section class="release" id="unreleased">
6+
7+
## Unreleased (2025-09-19)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`f660e38`](https://github.com/stdlib-js/stdlib/commit/f660e38225095ed8c07324924ff37098d6f96851) - add support for `struct` and `DataType` dtype values
14+
15+
</section>
16+
17+
<!-- /.features -->
18+
19+
<section class="commits">
20+
21+
### Commits
22+
23+
<details>
24+
25+
- [`f660e38`](https://github.com/stdlib-js/stdlib/commit/f660e38225095ed8c07324924ff37098d6f96851) - **feat:** add support for `struct` and `DataType` dtype values _(by Athan Reines)_
26+
27+
</details>
28+
29+
</section>
30+
31+
<!-- /.commits -->
32+
33+
<section class="contributors">
34+
35+
### Contributors
36+
37+
A total of 1 person contributed to this release. Thank you to this contributor:
38+
39+
- Athan Reines
40+
41+
</section>
42+
43+
<!-- /.contributors -->
44+
45+
</section>
46+
47+
<!-- /.release -->
48+
549
<section class="release" id="v0.2.2">
650

751
## 0.2.2 (2024-07-28)

CONTRIBUTORS

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Ahmed Khaled <[email protected]>
2020
Aksshay Balasubramanian <[email protected]>
2121
Aleksandr <[email protected]>
2222
Ali Salesi <[email protected]>
23-
AlyAbdelmoneim <[email protected]>
23+
Aly Abdelmoneim <[email protected]>
2424
Aman Bhansali <[email protected]>
2525
AmanBhadkariya <[email protected]>
2626
Amisha Chhajed <[email protected]>
@@ -29,6 +29,7 @@ Anmol Sah <[email protected]>
2929
Annamalai Prabu <[email protected]>
3030
Anshu Kumar <[email protected]>
3131
Anshu Kumar <[email protected]>
32+
Anshuman Singh <[email protected]>
3233
Anudeep Sanapala <[email protected]>
3334
Arihant Pal <[email protected]>
3435
Aryan Bhirud <[email protected]>
@@ -42,6 +43,7 @@ Bruno Fenzl <[email protected]>
4243
Bryan Elee <[email protected]>
4344
Chinmay Joshi <[email protected]>
4445
Christopher Dambamuromo <[email protected]>
46+
DUDHAT HEMIL PRAVINKUMAR <[email protected]>
4547
4648
Daniel Hernandez Gomez <[email protected]>
4749
Daniel Killenberger <[email protected]>
@@ -65,6 +67,7 @@ Frank Kovacs <[email protected]>
6567
GK Bishnoi <[email protected]>
6668
GURU PRASAD SHARMA <[email protected]>
6769
70+
Gaurav Kaushik <[email protected]>
6871
Gautam Kaushik <[email protected]>
6972
Gautam sharma <[email protected]>
7073
@@ -135,6 +138,7 @@ Nourhan Hasan <[email protected]>
135138
Ognjen Jevremović <[email protected]>
136139
Oneday12323 <[email protected]>
137140
Ori Miles <[email protected]>
141+
Payal Goswami <[email protected]>
138142
Philipp Burckhardt <[email protected]>
139143
Pierre Forstmann <[email protected]>
140144
Pradyumn Prasad <[email protected]>
@@ -176,9 +180,11 @@ Sanchay Ketan Sinha <[email protected]>
176180
Sarthak Paandey <[email protected]>
177181
Satyajeet Chavan <[email protected]>
178182
Saurabh Singh <[email protected]>
183+
Seth-Banker <[email protected]>
179184
Seyyed Parsa Neshaei <[email protected]>
180185
Shabareesh Shetty <[email protected]>
181186
Shashank Shekhar Singh <[email protected]>
187+
Shaswata Panda <[email protected]>
182188
Shivam Ahir <[email protected]>
183189
184190
Shraddheya Shendre <[email protected]>
@@ -189,6 +195,7 @@ Sivam Das <[email protected]>
189195
Snehil Shah <[email protected]>
190196
Soumajit Chatterjee <[email protected]>
191197
Spandan Barve <[email protected]>
198+
Srinivas Batthula <[email protected]>
192199
Stephannie Jiménez Gacha <[email protected]>
193200
Suhaib Ilahi <[email protected]>
194201
Suraj Kumar <[email protected]>
@@ -198,6 +205,7 @@ Tirtadwipa Manunggal <[email protected]>
198205
Tudor Pagu <[email protected]>
199206
Tufailahmed Bargir <[email protected]>
200207
Tushar Bhardwaj <[email protected]>
208+
Tyson Cung <[email protected]>
201209
Uday Kakade <[email protected]>
202210
Ujjwal Kirti <[email protected]>
203211
Utkarsh <http://[email protected]>

benchmark/benchmark.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
var bench = require( '@stdlib/bench-harness' );
2424
var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;
2525
var str2enum = require( '@stdlib/ndarray-base-dtype-str2enum' );
26+
var DataType = require( '@stdlib/ndarray-dtype-ctor' );
27+
var structFactory = require( '@stdlib/dstructs-struct' );
2628
var pkg = require( './../package.json' ).name;
2729
var resolve = require( './../lib' );
2830

@@ -82,3 +84,112 @@ bench( pkg+'::integer', function benchmark( b ) {
8284
b.pass( 'benchmark finished' );
8385
b.end();
8486
});
87+
88+
bench( pkg+'::data_type_instance,string', function benchmark( b ) {
89+
var values;
90+
var out;
91+
var i;
92+
93+
values = [
94+
new DataType( 'float64' ),
95+
new DataType( 'float32' ),
96+
new DataType( 'int32' ),
97+
new DataType( 'int8' )
98+
];
99+
100+
b.tic();
101+
for ( i = 0; i < b.iterations; i++ ) {
102+
out = resolve( values[ i%values.length ] );
103+
if ( typeof out !== 'number' ) {
104+
b.fail( 'should return a number' );
105+
}
106+
}
107+
b.toc();
108+
if ( !isInteger( out ) ) {
109+
b.fail( 'should return an integer' );
110+
}
111+
b.pass( 'benchmark finished' );
112+
b.end();
113+
});
114+
115+
bench( pkg+'::struct', function benchmark( b ) {
116+
var schemas;
117+
var values;
118+
var out;
119+
var i;
120+
121+
schemas = [
122+
[
123+
{
124+
'name': 'foo',
125+
'type': 'float64'
126+
}
127+
],
128+
[
129+
{
130+
'name': 'foo',
131+
'type': 'float32'
132+
}
133+
]
134+
];
135+
136+
values = [
137+
structFactory( schemas[ 0 ] ),
138+
structFactory( schemas[ 1 ] )
139+
];
140+
141+
b.tic();
142+
for ( i = 0; i < b.iterations; i++ ) {
143+
out = resolve( values[ i%values.length ] );
144+
if ( typeof out !== 'number' ) {
145+
b.fail( 'should return a number' );
146+
}
147+
}
148+
b.toc();
149+
if ( !isInteger( out ) ) {
150+
b.fail( 'should return an integer' );
151+
}
152+
b.pass( 'benchmark finished' );
153+
b.end();
154+
});
155+
156+
bench( pkg+'::data_type_instance,struct', function benchmark( b ) {
157+
var schemas;
158+
var values;
159+
var out;
160+
var i;
161+
162+
schemas = [
163+
[
164+
{
165+
'name': 'foo',
166+
'type': 'float64'
167+
}
168+
],
169+
[
170+
{
171+
'name': 'foo',
172+
'type': 'float32'
173+
}
174+
]
175+
];
176+
177+
values = [
178+
new DataType( structFactory( schemas[ 0 ] ) ),
179+
new DataType( structFactory( schemas[ 1 ] ) )
180+
];
181+
182+
b.tic();
183+
for ( i = 0; i < b.iterations; i++ ) {
184+
out = resolve( values[ i%values.length ] );
185+
if ( typeof out !== 'number' ) {
186+
b.fail( 'should return a number' );
187+
}
188+
}
189+
b.toc();
190+
if ( !isInteger( out ) ) {
191+
b.fail( 'should return an integer' );
192+
}
193+
b.pass( 'benchmark finished' );
194+
b.end();
195+
});

dist/index.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
// MODULES //
2222

23+
var isStructConstructorLike = require( '@stdlib/assert-is-struct-constructor-like' );
24+
var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;
2325
var enum2str = require( '@stdlib/ndarray-base-dtype-enum2str' );
2426
var str2enum = require( '@stdlib/ndarray-base-dtype-str2enum' );
2527

@@ -48,6 +50,12 @@ function resolve( dtype ) {
4850
if ( t === 'string' ) {
4951
return str2enum( dtype );
5052
}
53+
if ( t === 'object' && isInteger( dtype.enum ) ) {
54+
return dtype.enum;
55+
}
56+
if ( isStructConstructorLike( dtype ) ) {
57+
return str2enum( 'userdefined_type' );
58+
}
5159
return null;
5260
}
5361

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@
3737
"url": "https://github.com/stdlib-js/stdlib/issues"
3838
},
3939
"dependencies": {
40+
"@stdlib/assert-is-integer": "^0.2.2",
41+
"@stdlib/assert-is-struct-constructor-like": "github:stdlib-js/assert-is-struct-constructor-like#main",
4042
"@stdlib/ndarray-base-dtype-enum2str": "^0.2.2",
4143
"@stdlib/ndarray-base-dtype-str2enum": "^0.2.2"
4244
},
4345
"devDependencies": {
44-
"@stdlib/assert-is-integer": "^0.2.2",
46+
"@stdlib/dstructs-struct": "github:stdlib-js/dstructs-struct#main",
47+
"@stdlib/ndarray-dtype-ctor": "github:stdlib-js/ndarray-dtype-ctor#main",
4548
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
4649
"istanbul": "^0.4.1",
4750
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",

0 commit comments

Comments
 (0)