Skip to content

Commit 9b3ff9f

Browse files
committed
Auto-generated commit
1 parent e57309c commit 9b3ff9f

File tree

7 files changed

+28
-3
lines changed

7 files changed

+28
-3
lines changed

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616

1717
<!-- /.features -->
1818

19+
<section class="bug-fixes">
20+
21+
### Bug Fixes
22+
23+
- [`f0d49c1`](https://github.com/stdlib-js/stdlib/commit/f0d49c177b252ac1182ebc831fec6c90e862d56d) - handle infinity case and increase tolerances for passing tests
24+
25+
</section>
26+
27+
<!-- /.bug-fixes -->
28+
1929
<section class="issues">
2030

2131
### Closed Issues
@@ -34,6 +44,7 @@ A total of 2 issues were closed in this release:
3444

3545
<details>
3646

47+
- [`f0d49c1`](https://github.com/stdlib-js/stdlib/commit/f0d49c177b252ac1182ebc831fec6c90e862d56d) - **fix:** handle infinity case and increase tolerances for passing tests _(by Philipp Burckhardt)_
3748
- [`6af184d`](https://github.com/stdlib-js/stdlib/commit/6af184d8a8ed89c7be0fe08dd5d87125b60c5e01) - **bench:** update random value generation [(#6953)](https://github.com/stdlib-js/stdlib/pull/6953) _(by Harsh)_
3849
- [`28f64ec`](https://github.com/stdlib-js/stdlib/commit/28f64ec05e56db3e8836cfcdfd45e27a53eda4bf) - **docs:** replace manual `for` loop in examples [(#6918)](https://github.com/stdlib-js/stdlib/pull/6918) _(by Harsh)_
3950
- [`a1e230f`](https://github.com/stdlib-js/stdlib/commit/a1e230f29297caa89880e9c194c615a0400fb7bc) - **chore:** clean up cppcheck-suppress comments _(by Karan Anand)_

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com>
198198
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
199199
Yugal Kaushik <yugalkaushik14@gmail.com>
200200
Yuvi Mittal <128018763+yuvi-mittal@users.noreply.github.com>
201+
deepak427 <62477872+deepak427@users.noreply.github.com>
201202
devshree-bhati <147095250+devshree-bhati@users.noreply.github.com>
202203
ditsu <170345142+ditsus@users.noreply.github.com>
203204
ekambains <bainsinbusiness@gmail.com>

manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"dependencies": [
4141
"@stdlib/math-base-napi-ternary",
4242
"@stdlib/math-base-assert-is-nan",
43+
"@stdlib/math-base-assert-is-infinite",
4344
"@stdlib/math-base-special-atan2"
4445
]
4546
},
@@ -57,6 +58,7 @@
5758
"dependencies": [
5859
"@stdlib/constants-float64-eps",
5960
"@stdlib/math-base-assert-is-nan",
61+
"@stdlib/math-base-assert-is-infinite",
6062
"@stdlib/math-base-special-atan2"
6163
]
6264
},
@@ -73,6 +75,7 @@
7375
"libpath": [],
7476
"dependencies": [
7577
"@stdlib/math-base-assert-is-nan",
78+
"@stdlib/math-base-assert-is-infinite",
7679
"@stdlib/math-base-special-atan2"
7780
]
7881
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"url": "https://github.com/stdlib-js/stdlib/issues"
4141
},
4242
"dependencies": {
43+
"@stdlib/math-base-assert-is-infinite": "^0.2.2",
4344
"@stdlib/math-base-assert-is-nan": "^0.2.2",
4445
"@stdlib/math-base-napi-ternary": "^0.3.0",
4546
"@stdlib/math-base-special-atan2": "^0.3.0",

src/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "stdlib/stats/base/dists/cauchy/cdf.h"
2020
#include "stdlib/math/base/assert/is_nan.h"
21+
#include "stdlib/math/base/assert/is_infinite.h"
2122
#include "stdlib/math/base/special/atan2.h"
2223

2324
static const double ONE_OVER_PI = 0.3183098861837907;
@@ -43,5 +44,8 @@ double stdlib_base_dists_cauchy_cdf( const double x, const double x0, const doub
4344
) {
4445
return 0.0/0.0; // NaN
4546
}
47+
if ( stdlib_base_is_infinite( x ) ) {
48+
return ( x < 0.0 ) ? 0.0 : 1.0;
49+
}
4650
return ( ONE_OVER_PI * stdlib_base_atan2( x-x0, gamma ) ) + 0.5;
4751
}

test/test.native.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ tape( 'the function evaluates the cdf for `x` given `x0` and `gamma` (`x0 < 0`)'
149149
t.equal( y, expected[i], 'x: '+x[i]+', x0:'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
150150
} else {
151151
delta = abs( y - expected[ i ] );
152-
tol = 20.0 * EPS * abs( expected[ i ] );
152+
tol = 750.0 * EPS * abs( expected[ i ] );
153153
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
154154
}
155155
}
@@ -176,7 +176,13 @@ tape( 'the function evaluates the cdf for `x` given `x0` and `gamma` (`x0 > 0`)'
176176
t.equal( y, expected[i], 'x: '+x[i]+', x0:'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
177177
} else {
178178
delta = abs( y - expected[ i ] );
179-
tol = 150.0 * EPS * abs( expected[ i ] );
179+
/*
180+
* Large tolerance needed to accommodate a single test case (x: -157.97952978936485, x0: 11.935806197690301, gamma: 0.006888823412234402), for which
181+
* - the expected value is 0.00001290513644541802
182+
* - but the function returns 0.000012905136445441337
183+
* which is a difference of 2.3317e-17.
184+
*/
185+
tol = 8200.0 * EPS * abs( expected[ i ] );
180186
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
181187
}
182188
}

0 commit comments

Comments
 (0)