Skip to content

Commit e6c5ce7

Browse files
committed
refactor: apply suggestions from PR review
--- 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: passed - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent e438e2e commit e6c5ce7

File tree

8 files changed

+132
-66
lines changed

8 files changed

+132
-66
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"MACHEP": 1.11022302462515654042e-16,
3+
"EPS": 1.0e-13,
4+
"ETHRESH": 1.0e-12,
5+
"MAX_ITERATIONS": 10000
6+
}

lib/node_modules/@stdlib/math/base/special/hyp2f1/lib/hys2f1.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
17+
*
18+
*
19+
* ## Notice
20+
*
21+
* The original C code and copyright notice are from the [Cephes Mathematical Library]{@link https://www.netlib.org/cephes/}. The implementation has been modified for JavaScript.
22+
*
23+
* ```text
24+
* (C) Copyright Stephen L. Moshier 1984, 1987, 1992, 2000.
25+
*
26+
* Use, modification and distribution are subject to the
27+
* Cephes Mathematical Library License. (See accompanying file
28+
* LICENSE or copy at https://smath.com/en-US/view/CephesMathLibrary/license)
29+
* ```
1730
*/
1831

1932
'use strict';
@@ -23,14 +36,15 @@
2336
var PINF = require( '@stdlib/constants/float64/pinf' );
2437
var round = require( '@stdlib/math/base/special/round' );
2538
var abs = require( '@stdlib/math/base/special/abs' );
26-
var isNonPositiveInteger = require( './utils.js' ).isNonPositiveInteger;
39+
var isNonPositiveInteger = require( './isnonpositiveinteger.js' );
40+
var config = require( './config.json' );
2741

2842

2943
// VARIABLES //
3044

31-
var MACHEP = 1.11022302462515654042E-16;
32-
var EPS = 1.0e-13;
33-
var MAX_ITERATIONS = 10000;
45+
var MACHEP = config.MACHEP;
46+
var EPS = config.EPS;
47+
var MAX_ITERATIONS = config.MAX_ITERATIONS;
3448

3549

3650
// FUNCTIONS //
@@ -62,8 +76,7 @@ function hyp2f1ra( a, b, c, x, loss ) {
6276

6377
if ( ( c < 0.0 && a <= c ) || ( c >= 0.0 && a >= c ) ) {
6478
da = round( a - c );
65-
}
66-
else {
79+
} else {
6780
da = round( a );
6881
}
6982

@@ -86,26 +99,25 @@ function hyp2f1ra( a, b, c, x, loss ) {
8699
t -= 1.0;
87100
f1Val = f1.value;
88101
f0Val = f0.value;
89-
for ( n = 1; n < -da; ++n ) {
102+
for ( n = 1; n < -da; n++ ) {
90103
f2Val = f1Val;
91104
f1Val = f0Val;
92105

93106
// eslint-disable-next-line max-len
94107
f0Val = -(((((2.0 * t) - c) - (t * x) + (b * x)) * f1Val) + ((t * (x - 1.0)) * f2Val)) / (c - t);
95108
t -= 1.0;
96109
}
97-
}
98-
else {
110+
} else {
99111
f2Val = 0.0;
100112
f1 = hys2f1( t, b, c, x, err );
101113
loss += f1.error;
102114
err = f1.error;
103-
f0 = hys2f1( t + 1.0, b, c, x, err ); // CHECK IF err is THE SAME OR NEW ONE
115+
f0 = hys2f1( t + 1.0, b, c, x, err );
104116
loss += f0.error;
105117
t += 1.0;
106118
f1Val = f1.value;
107119
f0Val = f0.value;
108-
for ( n = 1; n < da; ++n ) {
120+
for ( n = 1; n < da; n++ ) {
109121
f2Val = f1Val;
110122
f1Val = f0Val;
111123

lib/node_modules/@stdlib/math/base/special/hyp2f1/lib/hyt2f1.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
17+
*
18+
*
19+
* ## Notice
20+
*
21+
* The original C code and copyright notice are from the [Cephes Mathematical Library]{@link https://www.netlib.org/cephes/}. The implementation has been modified for JavaScript.
22+
*
23+
* ```text
24+
* (C) Copyright Stephen L. Moshier 1984, 1987, 1992, 2000.
25+
*
26+
* Use, modification and distribution are subject to the
27+
* Cephes Mathematical Library License. (See accompanying file
28+
* LICENSE or copy at https://smath.com/en-US/view/CephesMathLibrary/license)
29+
* ```
1730
*/
1831

1932
'use strict';
@@ -30,17 +43,18 @@ var gamma = require( '@stdlib/math/base/special/gamma' );
3043
var gammaln = require( '@stdlib/math/base/special/gammaln' );
3144
var gammasgn = require( '@stdlib/math/base/special/gammasgn' );
3245
var digamma = require( '@stdlib/math/base/special/digamma' );
33-
var isNonPositiveInteger = require( './utils.js' ).isNonPositiveInteger;
34-
var isInteger = require( './utils.js' ).isInteger;
46+
var isNonPositiveInteger = require( './isnonpositiveinteger.js' );
47+
var isInteger = require( './isinteger.js' );
3548
var hys2f1 = require( './hys2f1.js' );
49+
var config = require( './config.json' );
3650

3751

3852
// VARIABLES //
3953

40-
var MACHEP = 1.11022302462515654042e-16;
41-
var EPS = 1.0e-13;
42-
var ETHRESH = 1.0e-12;
43-
var MAX_ITERATIONS = 10000;
54+
var MACHEP = config.MACHEP;
55+
var EPS = config.EPS;
56+
var ETHRESH = config.ETHRESH;
57+
var MAX_ITERATIONS = config.MAX_ITERATIONS;
4458

4559

4660
// MAIN //
@@ -92,8 +106,7 @@ function hyt2f1( a, b, c, x, loss ) {
92106
if ( b > a ) {
93107
y = hys2f1( a, c - b, c, -x / s, err );
94108
val = pow( s, -a ) * y.value;
95-
}
96-
else {
109+
} else {
97110
y = hys2f1( c - a, b, c, -x / s, err );
98111
val = pow( s, -b ) * y.value;
99112
}
@@ -141,15 +154,13 @@ function hyt2f1( a, b, c, x, loss ) {
141154
y = qVal + rVal;
142155
err += err1 + ( ( MACHEP * max( abs( qVal ), abs( rVal ) ) ) / y );
143156
y *= gamma( c );
144-
}
145-
else {
157+
} else {
146158
if ( id >= 0.0 ) {
147159
e = d;
148160
d1 = d;
149161
d2 = 0.0;
150162
aid = id;
151-
}
152-
else {
163+
} else {
153164
e = -d;
154165
d1 = 0.0;
155166
d2 = d;

lib/node_modules/@stdlib/math/base/special/hyp2f1/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* // returns ~27.699
4040
*
4141
* v = hyp2f1( 3.0, 4.0, 7.0, 1.0 );
42-
* // returns PINF
42+
* // returns +Infinity
4343
*
4444
* v = hyp2f1( NaN, 3.0, 2.0, 0.5 );
4545
* // returns NaN
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 round = require( '@stdlib/math/base/special/round' );
24+
var abs = require( '@stdlib/math/base/special/abs' );
25+
var config = require( './config.json' );
26+
27+
28+
// VARIABLES //
29+
30+
var EPS = config.EPS;
31+
32+
33+
// MAIN //
34+
35+
/**
36+
* Tests if a finite double-precision floating-point number is a "close enough" integer.
37+
*
38+
* @private
39+
* @param {number} x - input value
40+
* @returns {boolean} boolean indicating whether the value is a "close enough" integer
41+
*/
42+
function isInteger( x ) {
43+
var diff;
44+
var ix;
45+
46+
ix = round( x );
47+
diff = abs( x - ix );
48+
return ( diff < EPS );
49+
}
50+
51+
52+
// EXPORTS //
53+
54+
module.exports = isInteger;

lib/node_modules/@stdlib/math/base/special/hyp2f1/lib/utils.js renamed to lib/node_modules/@stdlib/math/base/special/hyp2f1/lib/isnonpositiveinteger.js

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222

2323
var round = require( '@stdlib/math/base/special/round' );
2424
var abs = require( '@stdlib/math/base/special/abs' );
25+
var config = require( './config.json' );
2526

2627

2728
// VARIABLES //
2829

29-
var EPS = 1.0e-13;
30+
var EPS = config.EPS;
3031

3132

32-
// FUNCTIONS //
33+
// MAIN //
3334

3435
/**
3536
* Tests if a finite double-precision floating-point number is a "close enough" nonpositive integer.
@@ -47,26 +48,7 @@ function isNonPositiveInteger( x ) {
4748
return ( ( ix <= 0.0 ) && ( diff < EPS ) );
4849
}
4950

50-
/**
51-
* Tests if a finite double-precision floating-point number is a "close enough" integer.
52-
*
53-
* @private
54-
* @param {number} x - input value
55-
* @returns {boolean} boolean indicating whether the value is a "close enough" integer
56-
*/
57-
function isInteger( x ) {
58-
var diff;
59-
var ix;
60-
61-
ix = round( x );
62-
diff = abs( x - ix );
63-
return ( diff < EPS );
64-
}
65-
6651

6752
// EXPORTS //
6853

69-
module.exports = {
70-
'isNonPositiveInteger': isNonPositiveInteger,
71-
'isInteger': isInteger
72-
};
54+
module.exports = isNonPositiveInteger;

lib/node_modules/@stdlib/math/base/special/hyp2f1/lib/main.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
*
1919
* ## Notice
2020
*
21-
* The original C++ code and copyright notice are from the [SciPy library]{@link https://github.com/scipy/xsf/blob/main/include/xsf/cephes/hyp2f1.h}. The implementation has been modified for JavaScript.
21+
* The original C code and copyright notice are from the [Cephes Mathematical Library]{@link https://www.netlib.org/cephes/}. The implementation has been modified for JavaScript.
2222
*
2323
* ```text
24-
* (C) Copyright SciPy Developers 2024.
24+
* (C) Copyright Stephen L. Moshier 1984, 1987, 1992, 2000.
2525
*
2626
* Use, modification and distribution are subject to the
27-
* SciPy Software License. (See accompanying file
28-
* LICENSE or copy at https://github.com/scipy/scipy/blob/main/LICENSE.txt)
27+
* Cephes Mathematical Library License. (See accompanying file
28+
* LICENSE or copy at https://smath.com/en-US/view/CephesMathLibrary/license)
2929
* ```
3030
*/
3131

@@ -39,15 +39,16 @@ var round = require( '@stdlib/math/base/special/round' );
3939
var gamma = require( '@stdlib/math/base/special/gamma' );
4040
var pow = require( '@stdlib/math/base/special/pow' );
4141
var abs = require( '@stdlib/math/base/special/abs' );
42-
var isNonPositiveInteger = require( './utils.js' ).isNonPositiveInteger;
43-
var isInteger = require( './utils.js' ).isInteger;
42+
var isNonPositiveInteger = require( './isnonpositiveinteger.js' );
43+
var isInteger = require( './isinteger.js' );
4444
var hys2f1 = require( './hys2f1.js' );
4545
var hyt2f1 = require( './hyt2f1.js' );
46+
var config = require( './config.json' );
4647

4748

4849
// VARIABLES //
4950

50-
var ETHRESH = 1.0e-12;
51+
var ETHRESH = config.ETHRESH;
5152

5253

5354
// MAIN //
@@ -79,7 +80,7 @@ var ETHRESH = 1.0e-12;
7980
*
8081
* @example
8182
* var v = hyp2f1( 3.0, 4.0, 7.0, 1.0 );
82-
* // returns Infinity
83+
* // returns +Infinity
8384
*
8485
* @example
8586
* var v = hyp2f1( NaN, 3.0, 2.0, 0.5 );

lib/node_modules/@stdlib/math/base/special/hyp2f1/test/test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
7979
t.end();
8080
});
8181

82-
tape( 'returns `1` if either `a` or `b` is 0 and `c` is not 0', function test( t ) {
82+
tape( 'the function returns `1` if either `a` or `b` is 0 and `c` is not 0', function test( t ) {
8383
var v;
8484

8585
v = hyp2f1( 0.0, 3.0, 2.0, 0.5 );
@@ -97,7 +97,7 @@ tape( 'returns `1` if either `a` or `b` is 0 and `c` is not 0', function test( t
9797
t.end();
9898
});
9999

100-
tape( 'returns `PINF` when `c <= a + b`, `x === 1`, and neither `a` nor `b` are non-positive integers', function test( t ) {
100+
tape( 'the function returns `PINF` when `c <= a + b`, `x === 1`, and neither `a` nor `b` are non-positive integers', function test( t ) {
101101
var v;
102102

103103
v = hyp2f1( 3.0, 4.0, 7.0, 1.0 );
@@ -131,8 +131,8 @@ tape( 'the function correctly evaluates the hypergeometric function', function t
131131

132132
for ( i = 0; i < x.length; i++ ) {
133133
v = hyp2f1( a[ i ], b[ i ], c[ i ], x[ i ] );
134-
if (expected[ i ] === 'PINF') {
135-
t.equal(v, PINF, 'returns expected value');
134+
if ( expected[ i ] === 'PINF' ) {
135+
t.equal( v, PINF, 'returns expected value' );
136136
continue;
137137
}
138138
delta = abs( v - expected[ i ] );
@@ -161,8 +161,8 @@ tape( 'the function correctly evaluates the hypergeometric function', function t
161161

162162
for ( i = 0; i < x.length; i++ ) {
163163
v = hyp2f1( a[ i ], b[ i ], c[ i ], x[ i ] );
164-
if (expected[ i ] === 'PINF') {
165-
t.equal(v, PINF, 'returns expected value');
164+
if ( expected[ i ] === 'PINF' ) {
165+
t.equal( v, PINF, 'returns expected value' );
166166
continue;
167167
}
168168
delta = abs( v - expected[ i ] );
@@ -191,8 +191,8 @@ tape( 'the function correctly evaluates the hypergeometric function', function t
191191

192192
for ( i = 0; i < x.length; i++ ) {
193193
v = hyp2f1( a[ i ], b[ i ], c[ i ], x[ i ] );
194-
if (expected[ i ] === 'PINF') {
195-
t.equal(v, PINF, 'returns expected value');
194+
if ( expected[ i ] === 'PINF' ) {
195+
t.equal( v, PINF, 'returns expected value' );
196196
continue;
197197
}
198198
delta = abs( v - expected[ i ] );
@@ -221,8 +221,8 @@ tape( 'the function correctly evaluates the hypergeometric function', function t
221221

222222
for ( i = 0; i < x.length; i++ ) {
223223
v = hyp2f1( a[ i ], b[ i ], c[ i ], x[ i ] );
224-
if (expected[ i ] === 'PINF') {
225-
t.equal(v, PINF, 'returns expected value');
224+
if ( expected[ i ] === 'PINF' ) {
225+
t.equal( v, PINF, 'returns expected value' );
226226
continue;
227227
}
228228
delta = abs( v - expected[ i ] );
@@ -251,8 +251,8 @@ tape( 'the function correctly evaluates the hypergeometric function', function t
251251

252252
for ( i = 0; i < x.length; i++ ) {
253253
v = hyp2f1( a[ i ], b[ i ], c[ i ], x[ i ] );
254-
if (expected[ i ] === 'PINF') {
255-
t.equal(v, PINF, 'returns expected value');
254+
if ( expected[ i ] === 'PINF' ) {
255+
t.equal( v, PINF, 'returns expected value' );
256256
continue;
257257
}
258258
delta = abs( v - expected[ i ] );

0 commit comments

Comments
 (0)