mirror of
				https://github.com/facebookresearch/pytorch3d.git
				synced 2025-11-04 18:02:14 +08:00 
			
		
		
		
	camera iteration #1408
Summary: Use IndexError so that a camera object is an iterable Reviewed By: shapovalov Differential Revision: D42312021 fbshipit-source-id: 67c417d5f1398e8b30a6944468eda057b4ceb444
This commit is contained in:
		
							parent
							
								
									b7e3b7b16c
								
							
						
					
					
						commit
						84851c8312
					
				@ -432,7 +432,7 @@ class CamerasBase(TensorProperties):
 | 
			
		||||
                    f"Boolean index of shape {index.shape} does not match cameras"
 | 
			
		||||
                )
 | 
			
		||||
        elif max(index) >= len(self):
 | 
			
		||||
            raise ValueError(f"Index {max(index)} is out of bounds for select cameras")
 | 
			
		||||
            raise IndexError(f"Index {max(index)} is out of bounds for select cameras")
 | 
			
		||||
 | 
			
		||||
        for field in self._FIELDS:
 | 
			
		||||
            val = getattr(self, field, None)
 | 
			
		||||
 | 
			
		||||
@ -866,6 +866,11 @@ class TestCamerasCommon(TestCaseMixin, unittest.TestCase):
 | 
			
		||||
        self.join_cameras_as_batch_fov(FoVOrthographicCameras)
 | 
			
		||||
        self.join_cameras_as_batch(OrthographicCameras)
 | 
			
		||||
 | 
			
		||||
    def test_iterable(self):
 | 
			
		||||
        for camera_type in [PerspectiveCameras, OrthographicCameras]:
 | 
			
		||||
            a_list = list(camera_type())
 | 
			
		||||
            self.assertEqual(len(a_list), 1)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
############################################################
 | 
			
		||||
#                FoVPerspective Camera                     #
 | 
			
		||||
@ -1009,7 +1014,7 @@ class TestFoVPerspectiveProjection(TestCaseMixin, unittest.TestCase):
 | 
			
		||||
        self.assertClose(c135.R, R_matrix[SLICE, ...])
 | 
			
		||||
 | 
			
		||||
        # Check errors with get item
 | 
			
		||||
        with self.assertRaisesRegex(ValueError, "out of bounds"):
 | 
			
		||||
        with self.assertRaisesRegex(IndexError, "out of bounds"):
 | 
			
		||||
            cam[N_CAMERAS]
 | 
			
		||||
 | 
			
		||||
        with self.assertRaisesRegex(ValueError, "does not match cameras"):
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user