1
I’m having a problem using NUMPY. It has an array testeSolucao
, of that kind <class 'numpy.matrixlib.defmatrix.matrix'>
, And I need to get the least amount of it, but I can’t. At first I thought it was a vector, but it’s generating this matrix because of the operations I’m doing. And since it’s a matrix with only one line I’m trying to pick up her line 0 and get the indexes, but every return from menor
i always get [[ 7.5 3. 0.25]]
.
def verificaSolucao(testeSolucao):
indice = 0
menor = testeSolucao[0][indice]
for i in range(1, 3, 1):
if testeSolucao[0][indice] < menor:
menor = testeSolucao[0][indice]
indice = i
if menor<0.0:
return (indice)
else:
return (-1)
I found a solution
testeSolucao.item(i)
works by picking up each item– Guilherme Ferreira
You can post your answer as a reply, not as a comment! After a few days you can accept it as an answer and so the question is settled. If anyone has another answer, no problem, let alone better.
– Guto
Thanks, I’ll do it!
– Guilherme Ferreira