Skip to content

Commit

Permalink
numpy/vector.c: remove usage of fpclassify (#636)
Browse files Browse the repository at this point in the history
Fixes #635

Verified by re-compiling circuitpython with this change.
  • Loading branch information
kbsriram authored Jul 17, 2023
1 parent d025aa3 commit 84f99f1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion code/numpy/vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(vector_sin_obj, vector_sin);
//|

static mp_float_t vector_sinc1(mp_float_t x) {
if (fpclassify(x) == FP_ZERO) {
if (x == MICROPY_FLOAT_CONST(0.)) {
return MICROPY_FLOAT_CONST(1.);
}
x *= MP_PI;
Expand Down
7 changes: 7 additions & 0 deletions tests/1d/numpy/universal_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@
cmp_result.append(math.isclose(result[i], ref_result[i], rel_tol=1E-9, abs_tol=1E-9))
print(cmp_result)

result = np.sinc(x)
ref_result = np.array([0.03935584386392389, -0.04359862862918773, 1.0, -0.04359862862918773, 0.03935584386392389])
cmp_result = []
for i in range(len(x)):
cmp_result.append(math.isclose(result[i], ref_result[i], rel_tol=1E-9, abs_tol=1E-9))
print(cmp_result)

result = (spy.special.erf(np.linspace(-3, 3, num=5)))
ref_result = np.array([-0.9999779095030014, -0.9661051464753108, 0.0, 0.9661051464753108, 0.9999779095030014], dtype=np.float)
cmp_result = []
Expand Down
1 change: 1 addition & 0 deletions tests/1d/numpy/universal_functions.py.exp
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ True
[True, True, True, True, True]
[True, True, True, True, True]
[True, True, True, True, True]
[True, True, True, True, True]
[True, True, True, True]
[True, True, True]

0 comments on commit 84f99f1

Please sign in to comment.