#๐Ÿ”’ RuntimeWarning: overflow encountered in scalar multiply

17 messages ยท Page 1 of 1 (latest)

eternal bridge
#

complete newbie when it comes to python, no idea how to fix it

fervent roostBOT
#

@eternal bridge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

eternal bridge
#
  alpha=0.67
  beta=67*10^(-5)
  gamma=-1
  delta=-5*10^(-4) 
  def LV(t,MT:np.ndarray):
   x=MT[0]
   y=MT[1]
   dx=x*(alpha-beta*y)
   dy=y*(gamma-delta*x)
   R=[dx,dy]
   return (R)```
#

the relevant code

#
  dx=x*(alpha-beta*y)
<ipython-input-61-d661bbf27121>:13: RuntimeWarning: overflow encountered in scalar multiply
  dy=y*(gamma-delta*x)```
#

and the warning

indigo lintel
eternal bridge
#

AttributeError: 'list' object has no attribute 'dtype'

#
  import scipy
  alpha=0.67
  beta=67*10^(-5)
  gamma=-1
  delta=-5*10^(-4) 
  t=np.arange(0.,10.+dt,dt)
  def LV(t,MT:np.ndarray):
   x=MT[0]
   y=MT[1]
   dx=x*(alpha-beta*y)
   dy=y*(gamma-delta*x)
   R=[dx,dy]
   alpha=0.67
   beta=67*10^(-5)
   gamma=-1
   delta=-5*10^(-4) 
   print(MT.dtype)
   return (R)
  a=0
  b=1
  c=7
  No0=1000+100*a-50*b
  Ni0=300+30*a-15*c
  N0=np.array([No0,Ni0])
  RKT=scipy.integrate.solve_ivp(LV ,t_span=(0,10), y0=N0, method='RK45',t_eval=t)
  nomax=max(RKT.y[0])
  nomin=min(RKT.y[0])
  nimax=max(RKT.y[1])
  nimin=min(RKT.y[1])
  return np.array([nomax,nomin,nimax,nimin])``` also heres the full thing
indigo lintel
eternal bridge
#

ints

indigo lintel
#

Ok, but what int more specifically?

eternal bridge
#

AttributeError: 'int' object has no attribute 'dtype'

eternal bridge
#

!solved

fervent roostBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.