Skip to content

Commit db22a17

Browse files
committed
feat: add typescript types and tests for airy
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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 b604a44 commit db22a17

File tree

2 files changed

+216
-23
lines changed

2 files changed

+216
-23
lines changed

lib/node_modules/@stdlib/math/base/special/airy/docs/types/index.d.ts

Lines changed: 106 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,120 @@
1818

1919
// TypeScript Version: 4.1
2020

21+
/// <reference types="@stdlib/types"/>
22+
23+
import { Collection } from '@stdlib/types/array';
24+
25+
/**
26+
* Interface describing `airy`.
27+
*/
28+
interface Airy {
29+
/**
30+
* Computes Airy functions of the first and second kind, Ai(x) and Bi(x), and their first derivatives, Ai'(x) and Bi'(x).
31+
*
32+
* @param x - input value
33+
* @returns Ai(x), Ai'(x), Bi(x), and Bi'(x)
34+
*
35+
* @example
36+
* var v = airy( 0.0 );
37+
* // returns [ ~0.355, ~-0.259, ~0.615, ~0.448 ]
38+
*
39+
* @example
40+
* var v = airy( 1.0 );
41+
* // returns [ ~0.135, ~-0.159, ~1.207, ~0.932 ]
42+
*
43+
* @example
44+
* var v = airy( -1.0 );
45+
* // returns [ ~0.536, ~-0.01, ~0.104, ~0.592 ]
46+
*
47+
* @example
48+
* var v = airy( Infinity );
49+
* // returns [ 0, 0, Infinity, Infinity ]
50+
*
51+
* @example
52+
* var v = airy( -Infinity );
53+
* // returns [ NaN, NaN, NaN, NaN ]
54+
*
55+
* @example
56+
* var v = airy( NaN );
57+
* // returns [ NaN, NaN, NaN, NaN ]
58+
*/
59+
( x: number ): Array<number>;
60+
61+
/**
62+
* Computes Airy functions of the first and second kind, Ai(x) and Bi(x), and their first derivatives, Ai'(x) and Bi'(x), and assigns results to a provided output array.
63+
*
64+
* @param x - input value
65+
* @param out - output array
66+
* @returns Ai(x), Ai'(x), Bi(x), and Bi'(x)
67+
*
68+
* @example
69+
* var out = [ 0.0, 0.0, 0.0, 0.0 ];
70+
* var v = airy( 0.0, out );
71+
* // returns [ ~0.355, ~-0.259, ~0.615, ~0.448 ]
72+
*/
73+
assign<T = unknown>( x: number, out: Array<T>, stride: number, offset: number ): Collection<T | number>;
74+
75+
/**
76+
* Compute the Airy function of the fist kind, Ai(x).
77+
*
78+
* @param x - input value
79+
* @returns Ai(x)
80+
*
81+
* @example
82+
* var v = airy.Ai( 0.0 );
83+
* // returns ~0.355
84+
*/
85+
ai( x: number ): number;
86+
87+
/**
88+
* Compute the first derivative of the Airy function of the first kind, Ai'(x).
89+
*
90+
* @param x - input value
91+
* @returns Ai'(x)
92+
*
93+
* @example
94+
* var v = airy.Ai( 0.0 );
95+
* // returns ~-0.259
96+
*/
97+
aip( x: number ): number;
98+
99+
/**
100+
* Compute the Airy function of the second kind, Bi(x).
101+
*
102+
* @param x - input value
103+
* @returns Bi(x)
104+
*
105+
* @example
106+
* var v = airy.Bi( 0.0 );
107+
* // returns ~0.615
108+
*/
109+
bi( x: number ): number;
110+
111+
/**
112+
* Compute the first derivative of the Airy function of the second kind, Bi'(x).
113+
*
114+
* @param x - input value
115+
* @returns Bi'(x)
116+
*
117+
* @example
118+
* var v = airy.Bi( 0.0 );
119+
* // returns ~0.448
120+
*/
121+
bip( x: number ): number;
122+
}
123+
21124
/**
22-
* Computes Airy functions of the first and second kind, Ai(x) and Bi(x), and their first derivatives, Ai'(x) and Bi'(x).
125+
* Computers the Airy functions of the first and second kind, Ai(x) and Bi(x), and their first derivatives, Ai'(x) and Bi'(x).
23126
*
24127
* @param x - input value
25-
* @returns Ai(x), Ai'(x), Bi(x), and Bi'(x)
128+
* @param out - output array
26129
*
27130
* @example
28131
* var v = airy( 0.0 );
29132
* // returns [ ~0.355, ~-0.259, ~0.615, ~0.448 ]
30-
*
31-
* @example
32-
* var v = airy( 1.0 );
33-
* // returns [ ~0.135, ~-0.159, ~1.207, ~0.932 ]
34-
*
35-
* @example
36-
* var v = airy( -1.0 );
37-
* // returns [ ~0.536, ~-0.01, ~0.104, ~0.592 ]
38-
*
39-
* @example
40-
* var v = airy( Infinity );
41-
* // returns [ 0, 0, Infinity, Infinity ]
42-
*
43-
* @example
44-
* var v = airy( -Infinity );
45-
* // returns [ NaN, NaN, NaN, NaN ]
46-
*
47-
* @example
48-
* var v = airy( NaN );
49-
* // returns [ NaN, NaN, NaN, NaN ]
50133
*/
51-
declare function airy( x: number ): Array<number>;
134+
declare var airy: Airy;
52135

53136

54137
// EXPORTS //

lib/node_modules/@stdlib/math/base/special/airy/docs/types/test.ts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19+
/// <reference types="@stdlib/types"/>
1920

2021
import airy = require( './index' );
2122

@@ -43,4 +44,113 @@ import airy = require( './index' );
4344
// The compiler throws an error if the function is provided insufficient arguments...
4445
{
4546
airy(); // $ExpectError
47+
airy( 8, 2 ); // $ExpectType number[]
48+
}
49+
50+
// The function returns an array of numbers...
51+
{
52+
const out = [ 0.0, 0.0 ];
53+
airy.assign( 8, out, 1, 0 ); // $ExpectType Collection<number>
54+
}
55+
56+
// The compiler throws an error if the `assign` method is provided a first argument which is not a number...
57+
{
58+
const out = [ 0.0, 0.0 ];
59+
60+
airy.assign( true, out, 1, 0 ); // $ExpectError
61+
airy.assign( false, out, 1, 0 ); // $ExpectError
62+
airy.assign( '5', out, 1, 0 ); // $ExpectError
63+
airy.assign( null, out, 1, 0 ); // $ExpectError
64+
airy.assign( [], out, 1, 0 ); // $ExpectError
65+
airy.assign( {}, out, 1, 0 ); // $ExpectError
66+
airy.assign( ( x: number ): number => x, out, 1, 0 ); // $ExpectError
67+
}
68+
69+
// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object...
70+
{
71+
airy.assign( 1.0, 1, 1, 0 ); // $ExpectError
72+
airy.assign( 1.0, true, 1, 0 ); // $ExpectError
73+
airy.assign( 1.0, false, 1, 0 ); // $ExpectError
74+
airy.assign( 1.0, null, 1, 0 ); // $ExpectError
75+
airy.assign( 1.0, {}, 1, 0 ); // $ExpectError
76+
}
77+
78+
// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number...
79+
{
80+
const out = [ 0.0, 0 ];
81+
82+
airy.assign( 1.0, out, 1, '5' ); // $ExpectError
83+
airy.assign( 1.0, out, 1, true ); // $ExpectError
84+
airy.assign( 1.0, out, 1, false ); // $ExpectError
85+
airy.assign( 1.0, out, 1, null ); // $ExpectError
86+
airy.assign( 1.0, out, 1, [] ); // $ExpectError
87+
airy.assign( 1.0, out, 1, {} ); // $ExpectError
88+
airy.assign( 1.0, out, 1, ( x: number ): number => x ); // $ExpectError
89+
}
90+
91+
// The compiler throws an error if the `assign` method is provided an unsupported number of arguments...
92+
{
93+
const out = [ 0.0, 0 ];
94+
95+
airy.assign(); // $ExpectError
96+
airy.assign( 1.0 ); // $ExpectError
97+
airy.assign( 1.0, out ); // $ExpectError
98+
airy.assign( 1.0, out, 1 ); // $ExpectError
99+
airy.assign( 1.0, out, 1, 0, 1 ); // $ExpectError
100+
}
101+
102+
// The functions ai, aip, bi, and bip return a number...
103+
{
104+
airy.ai( 8 ); // $ExpectType number
105+
airy.aip( 8 ); // $ExpectType number
106+
airy.bi( 8 ); // $ExpectType number
107+
airy.bip( 8 ); // $ExpectType number
108+
}
109+
110+
// The compiler throws an error if the `ai` method is provided a first argument which is not a number...
111+
{
112+
airy.ai( true ); // $ExpectError
113+
airy.ai( false ); // $ExpectError
114+
airy.ai( null ); // $ExpectError
115+
airy.ai( undefined ); // $ExpectError
116+
airy.ai( '5' ); // $ExpectError
117+
airy.ai( [] ); // $ExpectError
118+
airy.ai( {} ); // $ExpectError
119+
airy.ai( ( x: number ): number => x ); // $ExpectError
120+
}
121+
122+
// The compiler throws an error if the `aip` method is provided a first argument which is not a number...
123+
{
124+
airy.aip( true ); // $ExpectError
125+
airy.aip( false ); // $ExpectError
126+
airy.aip( null ); // $ExpectError
127+
airy.aip( undefined ); // $ExpectError
128+
airy.aip( '5' ); // $ExpectError
129+
airy.aip( [] ); // $ExpectError
130+
airy.aip( {} ); // $ExpectError
131+
airy.aip( ( x: number ): number => x ); // $ExpectError
132+
}
133+
134+
// The compiler throws an error if the `bi` method is provided a first argument which is not a number...
135+
{
136+
airy.bi( true ); // $ExpectError
137+
airy.bi( false ); // $ExpectError
138+
airy.bi( null ); // $ExpectError
139+
airy.bi( undefined ); // $ExpectError
140+
airy.bi( '5' ); // $ExpectError
141+
airy.bi( [] ); // $ExpectError
142+
airy.bi( {} ); // $ExpectError
143+
airy.bi( ( x: number ): number => x ); // $ExpectError
144+
}
145+
146+
// The compiler throws an error if the `bip` method is provided a first argument which is not a number...
147+
{
148+
airy.bip( true ); // $ExpectError
149+
airy.bip( false ); // $ExpectError
150+
airy.bip( null ); // $ExpectError
151+
airy.bip( undefined ); // $ExpectError
152+
airy.bip( '5' ); // $ExpectError
153+
airy.bip( [] ); // $ExpectError
154+
airy.bip( {} ); // $ExpectError
155+
airy.bip( ( x: number ): number => x ); // $ExpectError
46156
}

0 commit comments

Comments
 (0)