Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions escnn/nn/geometric_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,16 @@ def to(self, *args, **kwargs):
tensor = self.tensor.to(*args, **kwargs)
return GeometricTensor(tensor, self.type, self.coords)

def __iter__(self):
# The purpose of this method is to prevent an infinite loop from
# occurring if a user accidentally tries to iterate over a geometric
# tensor. The infinite loop occurs because of the way `__getitem__()`
# is implemented [1].
#
# [1] https://stackoverflow.com/questions/926574/why-does-defining-getitem-on-a-class-make-it-iterable-in-python

raise TypeError(f"{self.__class__.__name__!r} object is not iterable")

def __getitem__(self, slices) -> 'GeometricTensor':
r'''

Expand Down