Skip to content

Commit 82c5939

Browse files
committed
refactor: update scripts and templates
1 parent ef93d50 commit 82c5939

File tree

10 files changed

+474
-247
lines changed

10 files changed

+474
-247
lines changed

dtype_configurations.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
UNIQUE INPUT_DTYPES CONFIGURATIONS:
2+
=====================================
3+
4+
- numeric_and_generic: realcomplexndarray
5+
- real_and_generic: realndarray
6+
7+
8+
UNIQUE OUTPUT_DTYPES CONFIGURATIONS:
9+
====================================
10+
11+
- floating_point_and_generic: floatcomplexndarray
12+
- numeric_and_generic: realcomplexndarray
13+
- real_and_generic: realndarray
14+
- real_floating_point_and_generic: floatndarray
15+
16+
17+
SUMMARY:
18+
========
19+
Total unique input_dtypes configurations: 2
20+
Total unique output_dtypes configurations: 4
21+
Total functions analyzed: 132

extract_dtype_configs.js

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* @license Apache-2.0
5+
*
6+
* Copyright (c) 2025 The Stdlib Authors.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var fs = require( 'fs' );
26+
var db = require( './lib/node_modules/@stdlib/math/special/data/unary_function_database.json' );
27+
28+
29+
// MAIN //
30+
31+
/**
32+
* Extracts unique dtype configurations from the unary function database.
33+
*
34+
* @returns {void}
35+
*/
36+
function main() {
37+
var inputDtypesSet;
38+
var outputDtypesSet;
39+
var inputDtypes;
40+
var outputDtypes;
41+
var functions;
42+
var results;
43+
var func;
44+
var obj;
45+
var i;
46+
47+
// Initialize sets to store unique values:
48+
inputDtypesSet = new Set();
49+
outputDtypesSet = new Set();
50+
51+
// Get all function names:
52+
functions = Object.keys( db );
53+
54+
// Iterate through each function:
55+
for ( i = 0; i < functions.length; i++ ) {
56+
func = functions[ i ];
57+
obj = db[ func ];
58+
59+
// Add input_dtypes if it exists:
60+
if ( obj.input_dtypes ) {
61+
inputDtypesSet.add( obj.input_dtypes );
62+
}
63+
64+
// Add output_dtypes if it exists:
65+
if ( obj.output_dtypes ) {
66+
outputDtypesSet.add( obj.output_dtypes );
67+
}
68+
}
69+
70+
// Convert sets to sorted arrays:
71+
inputDtypes = Array.from( inputDtypesSet ).sort();
72+
outputDtypes = Array.from( outputDtypesSet ).sort();
73+
74+
// Create results string:
75+
results = 'UNIQUE INPUT_DTYPES CONFIGURATIONS:\n';
76+
results += '=====================================\n\n';
77+
for ( i = 0; i < inputDtypes.length; i++ ) {
78+
results += '- ' + inputDtypes[ i ] + '\n';
79+
}
80+
81+
results += '\n\nUNIQUE OUTPUT_DTYPES CONFIGURATIONS:\n';
82+
results += '====================================\n\n';
83+
for ( i = 0; i < outputDtypes.length; i++ ) {
84+
results += '- ' + outputDtypes[ i ] + '\n';
85+
}
86+
87+
results += '\n\nSUMMARY:\n';
88+
results += '========\n';
89+
results += 'Total unique input_dtypes configurations: ' + inputDtypes.length + '\n';
90+
results += 'Total unique output_dtypes configurations: ' + outputDtypes.length + '\n';
91+
results += 'Total functions analyzed: ' + functions.length + '\n';
92+
93+
// Write results to file:
94+
fs.writeFileSync( 'dtype_configurations.txt', results, 'utf8' );
95+
96+
console.log( 'Dtype configurations extracted to dtype_configurations.txt' );
97+
console.log( 'Found ' + inputDtypes.length + ' unique input_dtypes and ' + outputDtypes.length + ' unique output_dtypes configurations' );
98+
}
99+
100+
101+
// EXPORTS //
102+
103+
module.exports = main;
104+
105+
// If called directly from command line, execute the function
106+
if ( require.main === module ) {
107+
main();
108+
}

lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/README__md.txt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# {{ALIAS}}
2222

23-
> {{PKG_DESC}}
23+
> {{README_PKG_DESC}}
2424

2525
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
2626

@@ -42,18 +42,18 @@ var {{ALIAS}} = require( '@{{PKG}}' );
4242

4343
#### {{ALIAS}}( x\[, options] )
4444

45-
{{MAIN_DESC}}
45+
{{README_MAIN_DESC}}
4646

4747
```javascript
4848
var ndarray2array = require( '@stdlib/ndarray/to-array' );
4949
var array = require( '@stdlib/ndarray/array' );
5050

51-
var x = array( {{EXAMPLE_VALUES_2X2}} );
51+
var x = array( {{JS_EXAMPLE_VALUES_2X2}} );
5252
var y = {{ALIAS}}( x );
5353
// returns <ndarray>
5454

5555
var arr = ndarray2array( y );
56-
// returns {{EXAMPLE_RESULTS_2X2}}
56+
// returns {{JS_EXAMPLE_RESULTS_2X2}}
5757
```
5858

5959
The function accepts the following arguments:
@@ -73,7 +73,7 @@ var ndarray2array = require( '@stdlib/ndarray/to-array' );
7373
var array = require( '@stdlib/ndarray/array' );
7474
var getDType = require( '@stdlib/ndarray/dtype' );
7575

76-
var x = array( {{EXAMPLE_VALUES_2X2}} );
76+
var x = array( {{JS_EXAMPLE_VALUES_2X2}} );
7777
var y = {{ALIAS}}( x, {
7878
'dtype': 'generic'
7979
});
@@ -83,7 +83,7 @@ var dt = getDType( y );
8383
// returns 'generic'
8484

8585
var arr = ndarray2array( y );
86-
// returns {{EXAMPLE_RESULTS_2X2}}
86+
// returns {{JS_EXAMPLE_RESULTS_2X2}}
8787
```
8888

8989
By default, the function returns an [ndarray][@stdlib/ndarray/ctor] having the same [order][@stdlib/ndarray/orders] as the input [ndarray][@stdlib/ndarray/ctor]. To return an [ndarray][@stdlib/ndarray/ctor] having a specific memory layout irrespective of the memory layout of the input [ndarray][@stdlib/ndarray/ctor], set the `order` option.
@@ -93,7 +93,7 @@ var ndarray2array = require( '@stdlib/ndarray/to-array' );
9393
var array = require( '@stdlib/ndarray/array' );
9494
var getOrder = require( '@stdlib/ndarray/order' );
9595

96-
var x = array( {{EXAMPLE_VALUES_2X2}} );
96+
var x = array( {{JS_EXAMPLE_VALUES_2X2}} );
9797
var y = {{ALIAS}}( x, {
9898
'order': 'column-major'
9999
});
@@ -103,18 +103,18 @@ var ord = getOrder( y );
103103
// returns 'column-major'
104104

105105
var arr = ndarray2array( y );
106-
// returns {{EXAMPLE_RESULTS_2X2}}
106+
// returns {{JS_EXAMPLE_RESULTS_2X2}}
107107
```
108108

109109
#### {{ALIAS}}.assign( x, y )
110110

111-
{{ASSIGN_DESC}}
111+
{{README_ASSIGN_DESC}}
112112

113113
```javascript
114114
var ndarray2array = require( '@stdlib/ndarray/to-array' );
115115
var array = require( '@stdlib/ndarray/array' );
116116

117-
var x = array( {{EXAMPLE_VALUES_2X2}} );
117+
var x = array( {{JS_EXAMPLE_VALUES_2X2}} );
118118
var y = array( [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] );
119119

120120
var out = {{ALIAS}}.assign( x, y );
@@ -124,7 +124,7 @@ var bool = ( out === y );
124124
// returns true
125125

126126
var arr = ndarray2array( out );
127-
// returns {{EXAMPLE_RESULTS_2X2}}
127+
// returns {{JS_EXAMPLE_RESULTS_2X2}}
128128
```
129129

130130
The function accepts the following arguments:
@@ -140,7 +140,7 @@ var zeros = require( '@stdlib/ndarray/zeros' );
140140
var array = require( '@stdlib/ndarray/array' );
141141

142142
// Create a 2x2 input ndarray:
143-
var x = array( {{EXAMPLE_VALUES_2X2}} );
143+
var x = array( {{JS_EXAMPLE_VALUES_2X2}} );
144144

145145
// Create a 2x2x2 output ndarray:
146146
var y = zeros( [ 2, 2, 2 ] );
@@ -149,7 +149,7 @@ var out = {{ALIAS}}.assign( x, y );
149149
// returns <ndarray>
150150

151151
var arr = ndarray2array( out );
152-
// returns [ {{EXAMPLE_RESULTS_2X2}}, {{EXAMPLE_RESULTS_2X2}} ]
152+
// returns [ {{JS_EXAMPLE_RESULTS_2X2}}, {{JS_EXAMPLE_RESULTS_2X2}} ]
153153
```
154154

155155
</section>
@@ -212,6 +212,8 @@ console.log( ndarray2array( y ) );
212212

213213
<section class="links">
214214

215+
[{{PKG}}]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40{{PKG_LINK_SUFFIX}}
216+
215217
[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/ctor
216218

217219
[@stdlib/ndarray/orders]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/orders

lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/docs/repl__txt.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727

2828
Examples
2929
--------
30-
> var arr = {{EXAMPLE_VALUES_2X2}};
30+
> var arr = {{JS_EXAMPLE_VALUES_2X2}};
3131
> var x = {{alias:@stdlib/ndarray/array}}( arr );
3232
> var y = {{alias}}( x );
3333
> {{alias:@stdlib/ndarray/to-array}}( y )
34-
{{EXAMPLE_RESULTS_2X2}}
34+
{{JS_EXAMPLE_RESULTS_2X2}}
3535

3636

3737
{{alias}}.assign( x, y )
@@ -52,15 +52,15 @@
5252

5353
Examples
5454
--------
55-
> var arr = {{EXAMPLE_VALUES_2X2}};
55+
> var arr = {{JS_EXAMPLE_VALUES_2X2}};
5656
> var x = {{alias:@stdlib/ndarray/array}}( arr );
5757
> var sh = {{alias:@stdlib/ndarray/shape}}( x );
5858
> var y = {{alias:@stdlib/ndarray/zeros}}( sh );
5959
> var out = {{alias}}.assign( x, y );
6060
> var bool = ( out === y )
6161
true
6262
> {{alias:@stdlib/ndarray/to-array}}( y )
63-
{{EXAMPLE_RESULTS_2X2}}
63+
{{JS_EXAMPLE_RESULTS_2X2}}
6464

6565
See Also
6666
--------

lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/package__json.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
"math",
6060
"ndarray",
6161
"elementwise",
62-
"element-wise",
63-
{{KEYWORDS}}
62+
"element-wise",{{KEYWORDS}}
6463
],
6564
"__stdlib__": {}
6665
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"input_dtypes": {
3+
"numeric_and_generic": "realcomplexndarray",
4+
"real_and_generic": "realndarray"
5+
},
6+
"output_dtypes": {
7+
"floating_point_and_generic": "floatcomplexndarray",
8+
"numeric_and_generic": "realcomplexndarray",
9+
"real_and_generic": "realndarray",
10+
"real_floating_point_and_generic": "floatndarray"
11+
}
12+
}

0 commit comments

Comments
 (0)