Message402966
We used get/set attribute accessors with private data, and suspect the beaviour we see with the += operator contains a bug. Below is our original implementation, followed by our fix. But, we feel the original implementation should have worked. Please advise. Thank you.
@property
def position(self) -> np.ndarray:
return self._position
@position.setter
def position(self, val: np.ndarray):
self._position = val
def update(self, *, delta_t: float):
# Nope! Bug! (?)
# Tried to combine the getter and setter for self.position
# with the += operator, which will not work.
# self.position += self.velocity * delta_t
#
# This fixes the behaviour.
self._position = self.velocity * delta_t + self.position |
|
Date |
User |
Action |
Args |
2021-09-30 15:54:52 | chovey | set | recipients:
+ chovey |
2021-09-30 15:54:52 | chovey | set | messageid: <1633017292.67.0.488480039709.issue45333@roundup.psfhosted.org> |
2021-09-30 15:54:52 | chovey | link | issue45333 messages |
2021-09-30 15:54:52 | chovey | create | |
|