@stdlib/ndarray-base-unary-output-dtype 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/README.md +11 -5
- package/dist/index.js +4 -18
- package/dist/index.js.map +3 -3
- package/docs/types/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/main.js +6 -81
- package/package.json +2 -14
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -69,6 +69,8 @@ Resolves the output ndarray [data type][@stdlib/ndarray/dtypes] for a unary func
|
|
|
69
69
|
|
|
70
70
|
```javascript
|
|
71
71
|
var dt = unaryOutputDataType( 'int32', 'floating_point' );
|
|
72
|
+
|
|
73
|
+
var s = String( dt );
|
|
72
74
|
// returns 'float64'
|
|
73
75
|
```
|
|
74
76
|
|
|
@@ -76,9 +78,13 @@ If `policy` is a [data type][@stdlib/ndarray/dtypes], the function always return
|
|
|
76
78
|
|
|
77
79
|
```javascript
|
|
78
80
|
var dt = unaryOutputDataType( 'float32', 'float64' );
|
|
81
|
+
|
|
82
|
+
var s = String( dt );
|
|
79
83
|
// returns 'float64'
|
|
80
84
|
|
|
81
85
|
dt = unaryOutputDataType( 'int32', 'float64' );
|
|
86
|
+
|
|
87
|
+
s = String( dt );
|
|
82
88
|
// returns 'float64'
|
|
83
89
|
|
|
84
90
|
// ...
|
|
@@ -183,7 +189,7 @@ See [LICENSE][stdlib-license].
|
|
|
183
189
|
|
|
184
190
|
## Copyright
|
|
185
191
|
|
|
186
|
-
Copyright © 2016-
|
|
192
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
187
193
|
|
|
188
194
|
</section>
|
|
189
195
|
|
|
@@ -196,8 +202,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
196
202
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/ndarray-base-unary-output-dtype.svg
|
|
197
203
|
[npm-url]: https://npmjs.org/package/@stdlib/ndarray-base-unary-output-dtype
|
|
198
204
|
|
|
199
|
-
[test-image]: https://github.com/stdlib-js/ndarray-base-unary-output-dtype/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
200
|
-
[test-url]: https://github.com/stdlib-js/ndarray-base-unary-output-dtype/actions/workflows/test.yml?query=branch:v0.
|
|
205
|
+
[test-image]: https://github.com/stdlib-js/ndarray-base-unary-output-dtype/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
206
|
+
[test-url]: https://github.com/stdlib-js/ndarray-base-unary-output-dtype/actions/workflows/test.yml?query=branch:v0.3.0
|
|
201
207
|
|
|
202
208
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-base-unary-output-dtype/main.svg
|
|
203
209
|
[coverage-url]: https://codecov.io/github/stdlib-js/ndarray-base-unary-output-dtype?branch=main
|
|
@@ -209,8 +215,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
209
215
|
|
|
210
216
|
-->
|
|
211
217
|
|
|
212
|
-
[chat-image]: https://img.shields.io/
|
|
213
|
-
[chat-url]: https://
|
|
218
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
219
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
214
220
|
|
|
215
221
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
216
222
|
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Copyright (c) 2023 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
|
-
*/
|
|
1
|
+
"use strict";var s=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=s(function(p,t){
|
|
2
|
+
var i=require('@stdlib/ndarray-base-output-dtype/dist');function a(e,r){return i([e],r)}t.exports=a
|
|
3
|
+
});var o=u();module.exports=o;
|
|
4
|
+
/** @license Apache-2.0 */
|
|
19
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/main.js", "../lib/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar
|
|
5
|
-
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,
|
|
6
|
-
"names": ["require_main", "__commonJSMin", "exports", "module", "
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar outputDataType = require( '@stdlib/ndarray-base-output-dtype' );\n\n\n// MAIN //\n\n/**\n* Resolves the output ndarray data type for a unary function.\n*\n* @param {*} dtype - input ndarray data type\n* @param {(string|*)} policy - output ndarray data type policy\n* @throws {TypeError} second argument must be a recognized data type policy\n* @returns {DataType} output ndarray data type\n*\n* @example\n* var dt = resolve( 'float64', 'complex_floating_point' );\n* // returns <DataType>\n*/\nfunction resolve( dtype, policy ) {\n\treturn outputDataType( [ dtype ], policy );\n}\n\n\n// EXPORTS //\n\nmodule.exports = resolve;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Resolve the output ndarray data type for a unary function.\n*\n* @module @stdlib/ndarray-base-unary-output-dtype\n*\n* @example\n* var resolve = require( '@stdlib/ndarray-base-unary-output-dtype' );\n*\n* var dt = resolve( 'float64', 'complex_floating_point' );\n* // returns <DataType>\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,mCAAoC,EAiBlE,SAASC,EAASC,EAAOC,EAAS,CACjC,OAAOH,EAAgB,CAAEE,CAAM,EAAGC,CAAO,CAC1C,CAKAJ,EAAO,QAAUE,ICZjB,IAAIG,EAAO,IAKX,OAAO,QAAUA",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "outputDataType", "resolve", "dtype", "policy", "main"]
|
|
7
7
|
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ import { DataType, OutputPolicy } from '@stdlib/types/ndarray';
|
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* var dt = outputDataType( 'float64', 'complex_floating_point' );
|
|
34
|
-
* // returns <
|
|
34
|
+
* // returns <DataType>
|
|
35
35
|
*/
|
|
36
36
|
declare function outputDataType( dtype: DataType, policy: OutputPolicy | DataType ): DataType;
|
|
37
37
|
|
package/lib/index.js
CHANGED
package/lib/main.js
CHANGED
|
@@ -20,59 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
-
var
|
|
24
|
-
var isRealFloatingPointDataType = require( '@stdlib/ndarray-base-assert-is-real-floating-point-data-type' ); // eslint-disable-line id-length
|
|
25
|
-
var isComplexFloatingPointDataType = require( '@stdlib/ndarray-base-assert-is-complex-floating-point-data-type' ); // eslint-disable-line id-length
|
|
26
|
-
var isIntegerDataType = require( '@stdlib/ndarray-base-assert-is-integer-data-type' );
|
|
27
|
-
var isSignedIntegerDataType = require( '@stdlib/ndarray-base-assert-is-signed-integer-data-type' );
|
|
28
|
-
var isUnsignedIntegerDataType = require( '@stdlib/ndarray-base-assert-is-unsigned-integer-data-type' );
|
|
29
|
-
var isRealDataType = require( '@stdlib/ndarray-base-assert-is-real-data-type' );
|
|
30
|
-
var isNumericDataType = require( '@stdlib/ndarray-base-assert-is-numeric-data-type' );
|
|
31
|
-
var isDataType = require( '@stdlib/ndarray-base-assert-is-data-type' );
|
|
32
|
-
var defaults = require( '@stdlib/ndarray-defaults' );
|
|
33
|
-
var format = require( '@stdlib/string-format' );
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// VARIABLES //
|
|
37
|
-
|
|
38
|
-
var POLICY_TABLE = {
|
|
39
|
-
'floating_point': [
|
|
40
|
-
isFloatingPointDataType,
|
|
41
|
-
defaults.get( 'dtypes.floating_point' )
|
|
42
|
-
],
|
|
43
|
-
'real_floating_point': [
|
|
44
|
-
isRealFloatingPointDataType,
|
|
45
|
-
defaults.get( 'dtypes.real_floating_point' )
|
|
46
|
-
],
|
|
47
|
-
'complex_floating_point': [
|
|
48
|
-
isComplexFloatingPointDataType,
|
|
49
|
-
defaults.get( 'dtypes.complex_floating_point' )
|
|
50
|
-
],
|
|
51
|
-
|
|
52
|
-
'integer': [
|
|
53
|
-
isIntegerDataType,
|
|
54
|
-
defaults.get( 'dtypes.integer' )
|
|
55
|
-
],
|
|
56
|
-
'signed_integer': [
|
|
57
|
-
isSignedIntegerDataType,
|
|
58
|
-
defaults.get( 'dtypes.signed_integer' )
|
|
59
|
-
],
|
|
60
|
-
'unsigned_integer': [
|
|
61
|
-
isUnsignedIntegerDataType,
|
|
62
|
-
defaults.get( 'dtypes.unsigned_integer' )
|
|
63
|
-
],
|
|
64
|
-
|
|
65
|
-
'real': [
|
|
66
|
-
isRealDataType,
|
|
67
|
-
defaults.get( 'dtypes.real' )
|
|
68
|
-
],
|
|
69
|
-
|
|
70
|
-
'numeric': [
|
|
71
|
-
isNumericDataType,
|
|
72
|
-
defaults.get( 'dtypes.numeric' )
|
|
73
|
-
]
|
|
74
|
-
};
|
|
75
|
-
var DEFAULT_DTYPE = defaults.get( 'dtypes.default' );
|
|
23
|
+
var outputDataType = require( '@stdlib/ndarray-base-output-dtype' );
|
|
76
24
|
|
|
77
25
|
|
|
78
26
|
// MAIN //
|
|
@@ -80,40 +28,17 @@ var DEFAULT_DTYPE = defaults.get( 'dtypes.default' );
|
|
|
80
28
|
/**
|
|
81
29
|
* Resolves the output ndarray data type for a unary function.
|
|
82
30
|
*
|
|
83
|
-
* @param {
|
|
84
|
-
* @param {string} policy - output ndarray data type policy
|
|
31
|
+
* @param {*} dtype - input ndarray data type
|
|
32
|
+
* @param {(string|*)} policy - output ndarray data type policy
|
|
85
33
|
* @throws {TypeError} second argument must be a recognized data type policy
|
|
86
|
-
* @
|
|
87
|
-
* @returns {string} output ndarray data type
|
|
34
|
+
* @returns {DataType} output ndarray data type
|
|
88
35
|
*
|
|
89
36
|
* @example
|
|
90
37
|
* var dt = resolve( 'float64', 'complex_floating_point' );
|
|
91
|
-
* // returns <
|
|
38
|
+
* // returns <DataType>
|
|
92
39
|
*/
|
|
93
40
|
function resolve( dtype, policy ) {
|
|
94
|
-
|
|
95
|
-
if ( policy === 'default' ) {
|
|
96
|
-
// When the policy is "default", the output data type should always be the default data type without consideration for the input data type:
|
|
97
|
-
return DEFAULT_DTYPE;
|
|
98
|
-
}
|
|
99
|
-
if ( policy === 'same' || policy === 'promoted' ) { // note: for unary APIs, the "promoted" data type is the same as the input data type
|
|
100
|
-
return dtype;
|
|
101
|
-
}
|
|
102
|
-
if ( policy === 'bool' ) {
|
|
103
|
-
throw new Error( 'not implemented' ); // TODO: update once the `bool` dtype is supported
|
|
104
|
-
}
|
|
105
|
-
p = POLICY_TABLE[ policy ];
|
|
106
|
-
if ( p === void 0 ) {
|
|
107
|
-
// Check for an explicit data type...
|
|
108
|
-
if ( isDataType( policy ) ) {
|
|
109
|
-
return policy;
|
|
110
|
-
}
|
|
111
|
-
throw new TypeError( format( 'invalid argument. Second argument must be a supported data type policy. Value: `%s`.', policy ) );
|
|
112
|
-
}
|
|
113
|
-
if ( p[ 0 ]( dtype ) ) {
|
|
114
|
-
return dtype;
|
|
115
|
-
}
|
|
116
|
-
return p[ 1 ];
|
|
41
|
+
return outputDataType( [ dtype ], policy );
|
|
117
42
|
}
|
|
118
43
|
|
|
119
44
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/ndarray-base-unary-output-dtype",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Resolve the output ndarray data type for a unary function.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -30,18 +30,7 @@
|
|
|
30
30
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@stdlib/ndarray-base-
|
|
34
|
-
"@stdlib/ndarray-base-assert-is-data-type": "^0.2.1",
|
|
35
|
-
"@stdlib/ndarray-base-assert-is-floating-point-data-type": "^0.2.2",
|
|
36
|
-
"@stdlib/ndarray-base-assert-is-integer-data-type": "^0.2.2",
|
|
37
|
-
"@stdlib/ndarray-base-assert-is-numeric-data-type": "^0.2.2",
|
|
38
|
-
"@stdlib/ndarray-base-assert-is-real-data-type": "^0.2.2",
|
|
39
|
-
"@stdlib/ndarray-base-assert-is-real-floating-point-data-type": "^0.2.2",
|
|
40
|
-
"@stdlib/ndarray-base-assert-is-signed-integer-data-type": "^0.2.2",
|
|
41
|
-
"@stdlib/ndarray-base-assert-is-unsigned-integer-data-type": "^0.2.2",
|
|
42
|
-
"@stdlib/ndarray-defaults": "^0.3.0",
|
|
43
|
-
"@stdlib/string-format": "^0.2.2",
|
|
44
|
-
"@stdlib/error-tools-fmtprodmsg": "^0.2.2"
|
|
33
|
+
"@stdlib/ndarray-base-output-dtype": "github:stdlib-js/ndarray-base-output-dtype#main"
|
|
45
34
|
},
|
|
46
35
|
"devDependencies": {},
|
|
47
36
|
"engines": {
|
|
@@ -77,7 +66,6 @@
|
|
|
77
66
|
"return",
|
|
78
67
|
"output"
|
|
79
68
|
],
|
|
80
|
-
"__stdlib__": {},
|
|
81
69
|
"funding": {
|
|
82
70
|
"type": "opencollective",
|
|
83
71
|
"url": "https://opencollective.com/stdlib"
|