tianshou: Batch: don't create new objects on getitem
Currently Batch.__getitem__ will always create a new object. This is counterintuitive and destroys equality checks. E.g.,
b = Batch(...)
id1 = id(b[0])
id2 = id(b[0])
will result in id1 != id2, which leads to b[0] == b[0] being False
Related to #922
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (7 by maintainers)
As I found out just now, python’s own list actually cannot do this, so
Since
Batchis more of a python object than an array, it’s fine if we don’t do better thanlist😃. Let’s just implement__eq__properly and resolve this issueIn the last months I implemented a lot of helper things that also could help with this issue. Gonna open a PR tomorrow and assign you two as reviewers