Problem with numpy matrix

Asked

Viewed 75 times

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

  • 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.

  • 1

    Thanks, I’ll do it!

1 answer

0

I found a solution testeSolucao.item(i) works by picking up each item

Browser other questions tagged

You are not signed in. Login or sign up in order to post.