kp_tools.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:KerbalPie 作者: Vivero 项目源码 文件源码
def has_changed(self, to_value=None):
        if len(self._shift_register) > 1:
            if to_value is not None:
                # if we are comparing to a given value (that matches the data class)...
                if to_value.__class__ != self._data_class:
                    return None

                if self._data_class == float:
                    # compare with isclose, for floats
                    return math.isclose(self._shift_register[-1], to_value, rel_tol=1.0e-6) and self.has_changed()
                else:
                    # compare with equality, otherwise
                    return (self._shift_register[-1] == to_value) and self.has_changed()

            else:
                # if we are just checking if the latest value changed at all
                if self._data_class == float:
                    # compare with isclose, for floats
                    return not math.isclose(self._shift_register[-1], self._shift_register[-2])
                else:
                    # compare with equality, otherwise
                    return (self._shift_register[-1] != self._shift_register[-2])

        else:
            return False





#--- Basic PID controller class
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号