I have several functions with multiple calculations that might return inf, like so:
In [10]: numpy.exp(5000)
Out[10]: inf
I’d rather it return the maximum float value:
In [11]: sys.float_info.max
Out[11]: 1.7976931348623157e+308
I could put in checks for every time an inf might pop up, or wrap each calculation in a function that rounds inf down to the desired float. However, I’d really like a simple hack at the beginning of every function, like:
inf = sys.float_info.max
Which obviously doesn’t work. Is there a smart way to do this?
Thanks!
You can use a decorator: