-
Notifications
You must be signed in to change notification settings - Fork 857
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the double ellipsis issue when resolving indices (#196)
# Description Earlier in the code, we were using the `Ellipsis` object to index the dimensions of the tensor. This led to situations where we indexed multi-dimension tensors as: `x[..., ..., 0]`. This now leads to errors with Python 3.10. The MR replaces `Ellipsis` with the `slice(None)` object, which results in indexing as: `x[:, :, 0]`. ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Checklist - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./orbit.sh --format` - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file --------- Co-authored-by: Farbod Farshidian <ffarshidian@theaiinstitute.com>
- Loading branch information
1 parent
0396cf0
commit c6af307
Showing
18 changed files
with
93 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
source/extensions/omni.isaac.orbit/test/isaacsim/test_torch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto | ||
# All rights reserved. | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
from __future__ import annotations | ||
|
||
import torch | ||
import unittest | ||
|
||
|
||
class TestTorchOperations(unittest.TestCase): | ||
"""Tests for assuring torch related operations used in Orbit.""" | ||
|
||
def test_array_slicing(self): | ||
"""Check that using ellipsis and slices work for torch tensors.""" | ||
|
||
size = (400, 300, 5) | ||
my_tensor = torch.rand(size, device="cuda:0") | ||
|
||
self.assertEqual(my_tensor[..., 0].shape, (400, 300)) | ||
self.assertEqual(my_tensor[:, :, 0].shape, (400, 300)) | ||
self.assertEqual(my_tensor[slice(None), slice(None), 0].shape, (400, 300)) | ||
with self.assertRaises(IndexError): | ||
my_tensor[..., ..., 0] | ||
|
||
self.assertEqual(my_tensor[0, ...].shape, (300, 5)) | ||
self.assertEqual(my_tensor[0, :, :].shape, (300, 5)) | ||
self.assertEqual(my_tensor[0, slice(None), slice(None)].shape, (300, 5)) | ||
self.assertEqual(my_tensor[0, ..., ...].shape, (300, 5)) | ||
|
||
self.assertEqual(my_tensor[..., 0, 0].shape, (400,)) | ||
self.assertEqual(my_tensor[slice(None), 0, 0].shape, (400,)) | ||
self.assertEqual(my_tensor[:, 0, 0].shape, (400,)) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters