#๐ RuntimeWarning: overflow encountered in scalar multiply
17 messages ยท Page 1 of 1 (latest)
@eternal bridge
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.
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
What is the output of print(MT.dtype)?
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
That's not good, since that means while you have MT:np.ndarray, MT is actually a list, so your types are wrong. Aside from that, what is print(x.dtype, y.dtype)?
ints
Ok, but what int more specifically?
AttributeError: 'int' object has no attribute 'dtype'
actually nvm i got it, i think it was showing the warning cause of the "MT:np.ndarray". ran without it, all 3 are float64 + no warning
!solved
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.