You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Raise warnings when operations go wrong but don't fail completely #3971
NumPy flags a number of problems in array operations such as overflow, underflow and division by zero. It would be helpful if Scipp did the same to help users diagnose problems more easily.
There are two main challenges here:
Flagging problems
This would require a change to the core transform logic so that kernels can flag problems without stopping the transformation. NumPy uses global flags for this purpose and we probably need to do the same.
However, we need to make sure that this works with multi threading in Python. E.g., given
deffoo(a, b): a/bdefbar(a): a/0
if each function runs in its own thread, a global flag in C++ might flag a division by zero in foo if the threads line up poorly.
Detecting problems
Division by zero is easy to detect. But overflow and underflow are trickier. We need to do this without too many operations as that would slow down the core loop in Scipp.
For floating point operations, we can use the tools provided by fenv.
For integers, we would ideally use the functions in stdckdint.h. But they were only added in C++26. Going by how long it took to get access to C++20/23, this might still be a while in the future. We could maybe use the C version of that header in the meantime. But that would require using a C compiler mixed in with C+.
Activity