Python function return none but it shouldn't

I have a Python function (in a Kalman filter found somewhere) that I debugged with tons of print and it seems to works well.

The print before the return statement shows that the value is OK:

def step(self, z):
    print("self.x that I'm returning:", self.x) # The printed value is [-163.53868766 -160.27005497] so it is OK
    return self.x
    print("UNREACHED CODE") # OK, it is not printed

The function that called this is:

print("I call step with", tvec[0][0], tvec[1][0]) # Values are OK
estimate = self.kalfilt_trasl_x_y.step((tvec[0][0], tvec[1][0])) # The returned value is none
print("returned value: ", estimate) # Is none

1 answer

  • answered 2018-10-09 19:12 Lorenzo

    finally found the problem. You're right the problem was in another part of the code. This problem was born since i reused a code intended for other without touching. it was useful ipdb for debugging line by line.