[Numpy-discussion] numpy.log does not raise exceptions

Dominique Orban dominique.orban@gmail....
Sat Aug 27 15:09:11 CDT 2011


I'm wondering why numpy.log doesn't raise a ValueError exception the
way math.log does:

1< import numpy as np
2< np.log([-1])
Warning: invalid value encountered in log
2> array([ nan])

3< import math
4< math.log(-1)
ValueError                                Traceback (most recent call last)

It would make it a lot easier to trap domain errors than using isnan().



More information about the NumPy-Discussion mailing list