Skip to content

Commit b8c50f8

Browse files
committed
feat: add ndarray/base/assert/is-complex-floating-point-data-type-char
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent ef3f025 commit b8c50f8

File tree

10 files changed

+799
-0
lines changed

10 files changed

+799
-0
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 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+
# isComplexFloatingPointDataTypeChar
22+
23+
> Test if an input value is a supported ndarray complex-valued floating-point data type single letter character abbreviation.
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+
<!-- eslint-disable id-length -->
40+
41+
```javascript
42+
var isComplexFloatingPointDataTypeChar = require( '@stdlib/ndarray/base/assert/is-complex-floating-point-data-type-char' );
43+
```
44+
45+
#### isComplexFloatingPointDataTypeChar( value )
46+
47+
Tests if an input value is a supported ndarray complex-valued floating-point data type single letter character abbreviation.
48+
49+
<!-- eslint-disable id-length -->
50+
51+
```javascript
52+
var bool = isComplexFloatingPointDataTypeChar( 'z' );
53+
// returns true
54+
55+
bool = isComplexFloatingPointDataTypeChar( 'u' );
56+
// returns false
57+
```
58+
59+
</section>
60+
61+
<!-- /.usage -->
62+
63+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
64+
65+
<section class="notes">
66+
67+
</section>
68+
69+
<!-- /.notes -->
70+
71+
<!-- Package usage examples. -->
72+
73+
<section class="examples">
74+
75+
## Examples
76+
77+
<!-- eslint-disable id-length -->
78+
79+
<!-- eslint no-undef: "error" -->
80+
81+
```javascript
82+
var isComplexFloatingPointDataTypeChar = require( '@stdlib/ndarray/base/assert/is-complex-floating-point-data-type-char' );
83+
84+
var bool = isComplexFloatingPointDataTypeChar( 'r' );
85+
// returns false
86+
87+
bool = isComplexFloatingPointDataTypeChar( 'z' );
88+
// returns true
89+
90+
bool = isComplexFloatingPointDataTypeChar( 'c' );
91+
// returns true
92+
93+
bool = isComplexFloatingPointDataTypeChar( 'f' );
94+
// returns false
95+
96+
bool = isComplexFloatingPointDataTypeChar( 'd' );
97+
// returns false
98+
99+
bool = isComplexFloatingPointDataTypeChar( 'o' );
100+
// returns false
101+
102+
bool = isComplexFloatingPointDataTypeChar( 'k' );
103+
// returns false
104+
105+
bool = isComplexFloatingPointDataTypeChar( 'i' );
106+
// returns false
107+
108+
bool = isComplexFloatingPointDataTypeChar( 's' );
109+
// returns false
110+
111+
bool = isComplexFloatingPointDataTypeChar( 't' );
112+
// returns false
113+
114+
bool = isComplexFloatingPointDataTypeChar( 'u' );
115+
// returns false
116+
117+
bool = isComplexFloatingPointDataTypeChar( 'b' );
118+
// returns false
119+
120+
bool = isComplexFloatingPointDataTypeChar( 'a' );
121+
// returns false
122+
123+
bool = isComplexFloatingPointDataTypeChar( '' );
124+
// returns false
125+
126+
bool = isComplexFloatingPointDataTypeChar( 'foo' );
127+
// returns false
128+
```
129+
130+
</section>
131+
132+
<!-- /.examples -->
133+
134+
<!-- 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. -->
135+
136+
<section class="references">
137+
138+
</section>
139+
140+
<!-- /.references -->
141+
142+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
143+
144+
<section class="related">
145+
146+
</section>
147+
148+
<!-- /.related -->
149+
150+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
151+
152+
<section class="links">
153+
154+
</section>
155+
156+
<!-- /.links -->
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
25+
var pkg = require( './../package.json' ).name;
26+
var isComplexFloatingPointDataTypeChar = require( './../lib' ); // eslint-disable-line id-length
27+
28+
29+
// MAIN //
30+
31+
bench( pkg, function benchmark( b ) {
32+
var values;
33+
var out;
34+
var v;
35+
var i;
36+
37+
values = [
38+
'r',
39+
'z',
40+
'c',
41+
'f',
42+
'd',
43+
'o',
44+
'k',
45+
'i',
46+
's',
47+
't',
48+
'u',
49+
'b',
50+
'a',
51+
'~',
52+
'=',
53+
'',
54+
'beep',
55+
'boop'
56+
];
57+
58+
b.tic();
59+
for ( i = 0; i < b.iterations; i++ ) {
60+
v = values[ i%values.length ];
61+
out = isComplexFloatingPointDataTypeChar( v );
62+
if ( typeof out !== 'boolean' ) {
63+
b.fail( 'should return a boolean' );
64+
}
65+
}
66+
b.toc();
67+
if ( !isBoolean( out ) ) {
68+
b.fail( 'should return a boolean' );
69+
}
70+
b.pass( 'benchmark finished' );
71+
b.end();
72+
});
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
{{alias}}( value )
3+
Tests if an input value is a supported ndarray complex-valued floating-point
4+
data type single letter character abbreviation.
5+
6+
Parameters
7+
----------
8+
value: any
9+
Value to test.
10+
11+
Returns
12+
-------
13+
bool: boolean
14+
Boolean indicating if an input value is a supported ndarray complex-
15+
valued floating-point data type single letter character abbreviation.
16+
17+
Examples
18+
--------
19+
> var bool = {{alias}}( 'r' )
20+
false
21+
> bool = {{alias}}( 'c' )
22+
true
23+
> bool = {{alias}}( 'd' )
24+
false
25+
> bool = {{alias}}( 'k' )
26+
false
27+
> bool = {{alias}}( 'i' )
28+
false
29+
> bool = {{alias}}( 's' )
30+
false
31+
> bool = {{alias}}( 't' )
32+
false
33+
> bool = {{alias}}( 'u' )
34+
false
35+
> bool = {{alias}}( 'b' )
36+
false
37+
> bool = {{alias}}( 'a' )
38+
false
39+
> bool = {{alias}}( '' )
40+
false
41+
> bool = {{alias}}( 'beep' )
42+
false
43+
44+
See Also
45+
--------
46+
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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+
// TypeScript Version: 4.1
20+
21+
/**
22+
* Tests whether an input value is a supported ndarray complex-valued floating-point data type single letter character abbreviation.
23+
*
24+
* @param v - value to test
25+
* @returns boolean indicating whether an input value is a supported ndarray complex-valued floating-point data type single letter character abbreviation
26+
*
27+
* @example
28+
* var bool = isComplexFloatingPointDataTypeChar( 'r' );
29+
* // returns false
30+
*
31+
* bool = isComplexFloatingPointDataTypeChar( 'c' );
32+
* // returns true
33+
*
34+
* bool = isComplexFloatingPointDataTypeChar( 'z' );
35+
* // returns true
36+
*
37+
* bool = isComplexFloatingPointDataTypeChar( 'f' );
38+
* // returns false
39+
*
40+
* bool = isComplexFloatingPointDataTypeChar( 'd' );
41+
* // returns false
42+
*
43+
* bool = isComplexFloatingPointDataTypeChar( 'o' );
44+
* // returns false
45+
*
46+
* bool = isComplexFloatingPointDataTypeChar( 'k' );
47+
* // returns false
48+
*
49+
* bool = isComplexFloatingPointDataTypeChar( 'i' );
50+
* // returns false
51+
*
52+
* bool = isComplexFloatingPointDataTypeChar( 's' );
53+
* // returns false
54+
*
55+
* bool = isComplexFloatingPointDataTypeChar( 't' );
56+
* // returns false
57+
*
58+
* bool = isComplexFloatingPointDataTypeChar( 'u' );
59+
* // returns false
60+
*
61+
* bool = isComplexFloatingPointDataTypeChar( 'b' );
62+
* // returns false
63+
*
64+
* bool = isComplexFloatingPointDataTypeChar( 'a' );
65+
* // returns false
66+
*
67+
* bool = isComplexFloatingPointDataTypeChar( 'foo' );
68+
* // returns false
69+
*/
70+
declare function isComplexFloatingPointDataTypeChar( v: any ): boolean;
71+
72+
73+
// EXPORTS //
74+
75+
export = isComplexFloatingPointDataTypeChar;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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+
import isComplexFloatingPointDataTypeChar = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
isComplexFloatingPointDataTypeChar( 'r' ); // $ExpectType boolean
27+
isComplexFloatingPointDataTypeChar( 'foo' ); // $ExpectType boolean
28+
}
29+
30+
// The compiler throws an error if the function is provided an unsupported number of arguments...
31+
{
32+
isComplexFloatingPointDataTypeChar(); // $ExpectError
33+
isComplexFloatingPointDataTypeChar( undefined, 123 ); // $ExpectError
34+
}

0 commit comments

Comments
 (0)