Skip to content

Commit 41fc5ad

Browse files
committed
better comment + getattr
1 parent e3c51a9 commit 41fc5ad

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

quaddtype/numpy_quaddtype/src/casts.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,9 @@ template <>
502502
inline npy_byte
503503
from_quad<npy_byte>(quad_value x, QuadBackendType backend)
504504
{
505-
// reduction ops often give warning, we can handle the NAN casting
506-
// this behaviour might apply to all casting
505+
// runtime warnings often comes from/to casting of NaN, inf
506+
// casting is used by ops at several positions leading to warnings
507+
// fix can be catching the cases and returning corresponding type value without casting
507508
if (backend == BACKEND_SLEEF) {
508509
return (npy_byte)Sleef_cast_to_int64q1(x.sleef_value);
509510
}

quaddtype/tests/test_quaddtype.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,9 @@ def test_reduction_ops(self, op, input_array):
411411
"""Test all and any reduction operations."""
412412
quad_array = np.array([QuadPrecision(x) for x in input_array])
413413
float_array = np.array([float(x) for x in input_array])
414-
if op == "all":
415-
result = np.all(quad_array)
416-
expected = np.all(float_array)
417-
else: # op == "any"
418-
result = np.any(quad_array)
419-
expected = np.any(float_array)
414+
op = getattr(np, op)
415+
result = op(quad_array)
416+
expected = op(float_array)
420417

421418
assert result == expected, (
422419
f"Reduction op '{op}' failed for input {input_array}: "

0 commit comments

Comments
 (0)