Skip to content

Commit 5b1419d

Browse files
committed
Auto-generated commit
1 parent 59851e1 commit 5b1419d

File tree

22 files changed

+1278
-0
lines changed

22 files changed

+1278
-0
lines changed

CHANGELOG.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757

5858
##### Features
5959

60+
- [`14427c7`](https://github.com/stdlib-js/stdlib/commit/14427c79bc62f82b16cbadc9d34749901e48d105) - add `fill`, `map`, and `toReversed` to namespace
61+
- [`a0d6619`](https://github.com/stdlib-js/stdlib/commit/a0d66193409576538d0f16aa89cbaeedec7898be) - add `minSignedIntegerDataType` and `minUnsignedIntegerDataType` to namespace
6062
- [`8b1548f`](https://github.com/stdlib-js/stdlib/commit/8b1548fb45c1ff131f5edac20cb984344a2d28ec) - update namespace TypeScript declarations [(#3190)](https://github.com/stdlib-js/stdlib/pull/3190)
6163

6264
</section>
@@ -137,6 +139,50 @@
137139

138140
<!-- /.package -->
139141

142+
<section class="package" id="ndarray-base-min-signed-integer-dtype-unreleased">
143+
144+
#### [@stdlib/ndarray/base/min-signed-integer-dtype](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/min-signed-integer-dtype)
145+
146+
<details>
147+
148+
<section class="features">
149+
150+
##### Features
151+
152+
- [`c3bffe5`](https://github.com/stdlib-js/stdlib/commit/c3bffe513318480e2ce4645bb05895df8148ee1e) - add `ndarray/base/min-signed-integer-dtype`
153+
154+
</section>
155+
156+
<!-- /.features -->
157+
158+
</details>
159+
160+
</section>
161+
162+
<!-- /.package -->
163+
164+
<section class="package" id="ndarray-base-min-unsigned-integer-dtype-unreleased">
165+
166+
#### [@stdlib/ndarray/base/min-unsigned-integer-dtype](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/min-unsigned-integer-dtype)
167+
168+
<details>
169+
170+
<section class="features">
171+
172+
##### Features
173+
174+
- [`97e8c1a`](https://github.com/stdlib-js/stdlib/commit/97e8c1aff4f7c1a3b0946d15354a926d82e2120a) - add `ndarray/base/min-unsigned-integer-dtype`
175+
176+
</section>
177+
178+
<!-- /.features -->
179+
180+
</details>
181+
182+
</section>
183+
184+
<!-- /.package -->
185+
140186
<section class="package" id="ndarray-filter-unreleased">
141187

142188
#### [@stdlib/ndarray/filter](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/filter)
@@ -317,6 +363,10 @@ A total of 3 people contributed to this release. Thank you to the following cont
317363

318364
<details>
319365

366+
- [`14427c7`](https://github.com/stdlib-js/stdlib/commit/14427c79bc62f82b16cbadc9d34749901e48d105) - **feat:** add `fill`, `map`, and `toReversed` to namespace _(by Athan Reines)_
367+
- [`a0d6619`](https://github.com/stdlib-js/stdlib/commit/a0d66193409576538d0f16aa89cbaeedec7898be) - **feat:** add `minSignedIntegerDataType` and `minUnsignedIntegerDataType` to namespace _(by Athan Reines)_
368+
- [`97e8c1a`](https://github.com/stdlib-js/stdlib/commit/97e8c1aff4f7c1a3b0946d15354a926d82e2120a) - **feat:** add `ndarray/base/min-unsigned-integer-dtype` _(by Athan Reines)_
369+
- [`c3bffe5`](https://github.com/stdlib-js/stdlib/commit/c3bffe513318480e2ce4645bb05895df8148ee1e) - **feat:** add `ndarray/base/min-signed-integer-dtype` _(by Athan Reines)_
320370
- [`0d6bf75`](https://github.com/stdlib-js/stdlib/commit/0d6bf755cd3fcefbdf4751bc1f8e011bedefc057) - **refactor:** resolve error constructor and add todos _(by Athan Reines)_
321371
- [`dbfd8f5`](https://github.com/stdlib-js/stdlib/commit/dbfd8f5c81d11be2142ebfc4f2f0bb0316ba7478) - **feat:** add `filterMap` to namespace _(by Athan Reines)_
322372
- [`6ff153f`](https://github.com/stdlib-js/stdlib/commit/6ff153f9023cffac527b3243489e6413e989e940) - **feat:** add `ndarray/filter-map` _(by Athan Reines)_

base/lib/index.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,15 @@ setReadOnly( ns, 'emptyLike', require( './../../base/empty-like' ) );
310310
*/
311311
setReadOnly( ns, 'expandDimensions', require( './../../base/expand-dimensions' ) );
312312

313+
/**
314+
* @name fill
315+
* @memberof ns
316+
* @readonly
317+
* @type {Function}
318+
* @see {@link module:@stdlib/ndarray/base/fill}
319+
*/
320+
setReadOnly( ns, 'fill', require( './../../base/fill' ) );
321+
313322
/**
314323
* @name flag
315324
* @memberof ns
@@ -391,6 +400,15 @@ setReadOnly( ns, 'ind2sub', require( './../../base/ind2sub' ) );
391400
*/
392401
setReadOnly( ns, 'iterationOrder', require( './../../base/iteration-order' ) );
393402

403+
/**
404+
* @name map
405+
* @memberof ns
406+
* @readonly
407+
* @type {Function}
408+
* @see {@link module:@stdlib/ndarray/base/map}
409+
*/
410+
setReadOnly( ns, 'map', require( './../../base/map' ) );
411+
394412
/**
395413
* @name maxViewBufferIndex
396414
* @memberof ns
@@ -427,6 +445,24 @@ setReadOnly( ns, 'maybeBroadcastArrays', require( './../../base/maybe-broadcast-
427445
*/
428446
setReadOnly( ns, 'metaDataProps', require( './../../base/meta-data-props' ) );
429447

448+
/**
449+
* @name minSignedIntegerDataType
450+
* @memberof ns
451+
* @readonly
452+
* @type {Function}
453+
* @see {@link module:@stdlib/ndarray/base/min-signed-integer-dtype}
454+
*/
455+
setReadOnly( ns, 'minSignedIntegerDataType', require( './../../base/min-signed-integer-dtype' ) );
456+
457+
/**
458+
* @name minUnsignedIntegerDataType
459+
* @memberof ns
460+
* @readonly
461+
* @type {Function}
462+
* @see {@link module:@stdlib/ndarray/base/min-unsigned-integer-dtype}
463+
*/
464+
setReadOnly( ns, 'minUnsignedIntegerDataType', require( './../../base/min-unsigned-integer-dtype' ) );
465+
430466
/**
431467
* @name minViewBufferIndex
432468
* @memberof ns
@@ -787,6 +823,15 @@ setReadOnly( ns, 'sub2ind', require( './../../base/sub2ind' ) );
787823
*/
788824
setReadOnly( ns, 'ndarray2array', require( './../../base/to-array' ) );
789825

826+
/**
827+
* @name toReversed
828+
* @memberof ns
829+
* @readonly
830+
* @type {Function}
831+
* @see {@link module:@stdlib/ndarray/base/to-reversed}
832+
*/
833+
setReadOnly( ns, 'toReversed', require( './../../base/to-reversed' ) );
834+
790835
/**
791836
* @name transpose
792837
* @memberof ns
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2024 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+
# Minimum Data Type
22+
23+
> Determine the minimum ndarray [data type][@stdlib/ndarray/dtypes] for storing a provided signed integer value.
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 minSignedIntegerDataType = require( '@stdlib/ndarray/base/min-signed-integer-dtype' );
41+
```
42+
43+
#### minSignedIntegerDataType( value )
44+
45+
Returns the minimum ndarray [data type][@stdlib/ndarray/dtypes] for storing a provided signed integer value.
46+
47+
```javascript
48+
var dt = minSignedIntegerDataType( 9999 );
49+
// returns 'int16'
50+
51+
dt = minSignedIntegerDataType( -3 );
52+
// returns 'int8'
53+
54+
dt = minSignedIntegerDataType( 3 );
55+
// returns 'int8'
56+
57+
dt = minSignedIntegerDataType( 1e100 );
58+
// returns 'float64'
59+
```
60+
61+
</section>
62+
63+
<!-- /.usage -->
64+
65+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
66+
67+
<section class="notes">
68+
69+
## Notes
70+
71+
- Once a provided integer value exceeds the maximum values of all supported signed integer [data types][@stdlib/ndarray/dtypes], the function defaults to returning `'float64'`.
72+
73+
</section>
74+
75+
<!-- /.notes -->
76+
77+
<!-- Package usage examples. -->
78+
79+
<section class="examples">
80+
81+
## Examples
82+
83+
<!-- eslint no-undef: "error" -->
84+
85+
```javascript
86+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
87+
var exp2 = require( '@stdlib/math/base/special/exp2' );
88+
var minSignedIntegerDataType = require( '@stdlib/ndarray/base/min-signed-integer-dtype' );
89+
90+
// Generate random powers:
91+
var exp = discreteUniform( 100, 0, 40, {
92+
'dtype': 'generic'
93+
});
94+
95+
// Determine the minimum data type for each generated value...
96+
var v;
97+
var i;
98+
for ( i = 0; i < exp.length; i++ ) {
99+
v = exp2( exp[ i ] );
100+
console.log( 'min(%d) => %s', v, minSignedIntegerDataType( v ) );
101+
}
102+
```
103+
104+
</section>
105+
106+
<!-- /.examples -->
107+
108+
<!-- 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. -->
109+
110+
<section class="references">
111+
112+
</section>
113+
114+
<!-- /.references -->
115+
116+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
117+
118+
<section class="related">
119+
120+
</section>
121+
122+
<!-- /.related -->
123+
124+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
125+
126+
<section class="links">
127+
128+
[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray/tree/main/dtypes
129+
130+
</section>
131+
132+
<!-- /.links -->
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive;
25+
var pkg = require( './../package.json' ).name;
26+
var minSignedIntegerDataType = require( './../lib' );
27+
28+
29+
// MAIN //
30+
31+
bench( pkg, function benchmark( b ) {
32+
var values;
33+
var out;
34+
var N;
35+
var i;
36+
37+
values = [
38+
0,
39+
1,
40+
-128,
41+
128,
42+
99999,
43+
-99999,
44+
1.0e100,
45+
-1.0e100,
46+
-1234567890,
47+
1234567890
48+
];
49+
N = values.length;
50+
51+
b.tic();
52+
for ( i = 0; i < b.iterations; i++ ) {
53+
out = minSignedIntegerDataType( values[ i%N ] );
54+
if ( typeof out !== 'string' ) {
55+
b.fail( 'should return a string' );
56+
}
57+
}
58+
b.toc();
59+
if ( !isString( out ) ) {
60+
b.fail( 'should return a string' );
61+
}
62+
b.pass( 'benchmark finished' );
63+
b.end();
64+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
{{alias}}( value )
3+
Returns the minimum ndarray data type for storing a provided signed integer
4+
value.
5+
6+
Parameters
7+
----------
8+
value: number
9+
Signed integer value.
10+
11+
Returns
12+
-------
13+
dt: string
14+
ndarray data type.
15+
16+
Examples
17+
--------
18+
> var dt = {{alias}}( 3 )
19+
'int8'
20+
> dt = {{alias}}( -3 )
21+
'int8'
22+
> dt = {{alias}}( 1280 )
23+
'int16'
24+
25+
See Also
26+
--------
27+

0 commit comments

Comments
 (0)