pythonruntimewarnings

what may be the reason of RuntimeWarning: invalid value encountered in scalar multiply?


I am usign a large library feeding it with the measured data. Logs show that in some cases there is some error/warning message and shows the line in which this warning occurs.

Warning:

.../MLE_funcs.py:4682: RuntimeWarning: invalid value encountered in scalar multiply

Here it is:

y = (np.pi/2) * x * np.exp(-np.pi*(x**2)/4)

Why this warning can appear if x is always given and it's numeric (sometimes it's a numpy array but it should work in any case.. Any suggestions?

Or maybe you can suggest how to catch that warning to log the issue in more details?


Solution

  • This particular function performs scalar multiplication, not matrix or vector multiplication. This means your input cannot be arrays or other iterables but should be scalar values.