user5538206
user5538206

Reputation:

Not true values plus unsupported operand type error

I have the following code written in python:

def FindDeviation(block, v, win):
    h, w = block.shape
    dist = 0
    Dist = 0
    for i in range(0,h-1):
        for j in range(0,w-1):
            print v 
            print block[i,j]
            dist = (v-block[i,j])
            print dist
            dist2 = int(dist)^2
            print dist2
            Dist = Dist + dist2
            print Dist
    DeviationOfBlock = math.sqrt((1/win^2)*Dist)
    return DeviationOfBlock

and the result is for example for one block:

v = 82.0 
block[i,j] = 1
dist = 81.0
dist2 = 83
Dist = 83

However, considering v, block[i,j], dist having true values, dist2 is not powered by 2!!!!! why? what is the reason? And finally after some steps I have an error:

"TypeError: unsupported operand type(s) for ^: 'numpy.float64' and 'int'"

Can you please help me?

thanks and regards.

Upvotes: 0

Views: 62

Answers (1)

KIDJourney
KIDJourney

Reputation: 1220

In python , power operator is ** , ^ means bitwise xor .

In [12]: np.array([1,2,3])**2
Out[12]: array([1, 4, 9])

Upvotes: 3

Related Questions