-1

Why does this error occur:

root = optimize.newton(func=fa,x0=del_dsoil_trys[i])

Traceback (most recent call last):  ....

.....

File "<ipython-input-7-0d3c27cb2dad>", line 3, in v_can 

v_cans[i+1] = np.sqrt(2*Eks[i]/(yf*m_d*1000))

IndexError: arrays used as indices must be of integer (or boolean) type

Initially the array v_cans = np.zeros((rows,1)). This is distinct from the function v_can above.

My indices [i+1] and [i] are both single value integers, so what can be the problem?

henrybish
  • 3
  • 3

1 Answers1

0

You don't provide enough information.

But I can reproduce the error with:

In [199]: x
Out[199]: array([1, 2, 3])
In [200]: x[np.array([1.0])]
Traceback (most recent call last):
  Input In [200] in <module>
    x[np.array([1.0])]
IndexError: arrays used as indices must be of integer (or boolean) type

But an integer dtype array is fine:

In [201]: x[np.array([1])]
Out[201]: array([2])

You have to use your debugging skills to complete the task.

hpaulj
  • 221,503
  • 14
  • 230
  • 353