Skip to content

Resolve "CI: invalid value encountered in cast"

Wout De Nolf requested to merge 48-ci-invalid-value-encountered-in-cast into main

Closes #48

IEEE-754 representation of NaN: all exponent bits are 1 and fraction is not zero (fraction zero is inf).

image

The most significant bit of the fraction is called the "quiet" bit

import numpy
qnan = int("1" + "11111111" + "10000000000000000000001", 2).to_bytes(4, "little")
numpy.frombuffer(qnan, dtype=numpy.float32).astype(numpy.float64)

When casting floats, a warning occurs when the "quiet" bit is not set (called a signaling NaN)

import numpy
snan = int("1" + "11111111" + "00000000000000000000001", 2).to_bytes(4, "little")
numpy.frombuffer(snan, dtype=numpy.float32).astype(numpy.float64) # RuntimeWarning: invalid value encountered in cast

It seems that pyFAI has signaling NaNs in Integrate1dResult from IntegrationMethod(1d int, no split, CSR, cython). This MR sets dummy=float("nan") to replace all NaNs (most importantly the signaling ones) with a quiet NaN.

Edited by Wout De Nolf

Merge request reports

Loading