This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author chovey
Recipients chovey
Date 2021-09-30.15:54:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1633017292.67.0.488480039709.issue45333@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-09-30 15:54:52choveysetrecipients: + chovey
2021-09-30 15:54:52choveysetmessageid: <1633017292.67.0.488480039709.issue45333@roundup.psfhosted.org>
2021-09-30 15:54:52choveylinkissue45333 messages
2021-09-30 15:54:52choveycreate