[英]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.我有一个 Python 函数(在某处找到的卡尔曼滤波器中),我用大量打印进行了调试,它似乎运行良好。
The print before the return statement shows that the value is OK: return语句前的打印显示值是OK的:
def step(self, z):
#----code----
#----alghoritm---
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
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.
用于逐行调试的 ipdb 很有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.