Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__getitem__ with augmentedTensor #284

Merged
merged 1 commit into from
Jan 12, 2023
Merged
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
13 changes: 11 additions & 2 deletions aloscene/tensors/augmented_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,17 @@ def __getitem__(self, idx):
label, lambda l: self._getitem_child(l, name, idx), on_list=False
)

if isinstance(idx, torch.Tensor):
tensor = torch.Tensor.__getitem__(self.rename(None), idx).reset_names()
if isinstance(idx, AugmentedTensor):
tensor = torch.Tensor.__getitem__(self.rename(None), idx.as_tensor())

tensor = tensor.reset_names() if len(self.shape) == len(tensor.shape) else tensor.as_tensor()

elif isinstance(idx, torch.Tensor):
tensor = torch.Tensor.__getitem__(self.rename(None), idx)

tensor = tensor.reset_names() if len(self.shape) == len(tensor.shape) else tensor.as_tensor()


# if not idx.dtype == torch.bool:
# if not torch.equal(idx ** 3, idx):
# raise IndexError(f"Unvalid mask. Expected mask elements to be in [0, 1, True, False]")
Expand Down