Skip to content

Commit 84f99f1

Browse files
authored
numpy/vector.c: remove usage of fpclassify (#636)
Fixes #635 Verified by re-compiling circuitpython with this change.
1 parent d025aa3 commit 84f99f1

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

code/numpy/vector.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(vector_sin_obj, vector_sin);
827827
//|
828828

829829
static mp_float_t vector_sinc1(mp_float_t x) {
830-
if (fpclassify(x) == FP_ZERO) {
830+
if (x == MICROPY_FLOAT_CONST(0.)) {
831831
return MICROPY_FLOAT_CONST(1.);
832832
}
833833
x *= MP_PI;

tests/1d/numpy/universal_functions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@
112112
cmp_result.append(math.isclose(result[i], ref_result[i], rel_tol=1E-9, abs_tol=1E-9))
113113
print(cmp_result)
114114

115+
result = np.sinc(x)
116+
ref_result = np.array([0.03935584386392389, -0.04359862862918773, 1.0, -0.04359862862918773, 0.03935584386392389])
117+
cmp_result = []
118+
for i in range(len(x)):
119+
cmp_result.append(math.isclose(result[i], ref_result[i], rel_tol=1E-9, abs_tol=1E-9))
120+
print(cmp_result)
121+
115122
result = (spy.special.erf(np.linspace(-3, 3, num=5)))
116123
ref_result = np.array([-0.9999779095030014, -0.9661051464753108, 0.0, 0.9661051464753108, 0.9999779095030014], dtype=np.float)
117124
cmp_result = []

tests/1d/numpy/universal_functions.py.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ True
2828
[True, True, True, True, True]
2929
[True, True, True, True, True]
3030
[True, True, True, True, True]
31+
[True, True, True, True, True]
3132
[True, True, True, True]
3233
[True, True, True]

0 commit comments

Comments
 (0)