The following code produces a runtime warning because 1.0 is outside the range of the arctanh function, but the code continues running and prints inf
for the result of the calculation, and then Not dead yet!
import numpy
from numpy import arctanh
print(arctanh(1.0))
print("Not dead yet!")
This behavior of numpy's arctanh function seems inconsistent with the way python normally handles arithmetic exceptions. E.g., if I change the arctanh to a 1.0/0.0
, I get ZeroDivisionError, which causes the program to terminate immediately.
Is there some way to change the behavior of numpy so that this type of warning becomes an error, or so that the warning causes the program to terminate, as an error would?