Repository: DCC-Lab/RayTracing

Issue:
ImagingPath: chiefRay not working with no aperture stop
When we create an `ImagingPath` without any aperture stop, `chiefRay` raises a `TypeError`, because there is no aperture stop. For example:

```python
path = ImagingPath(System2f(10)) # A 2f system with f = 10 and infinite diameter
path.chiefRay() # Fails with TypeError, even with a specified y
```
I think we should return `None`, because no aperture stop means no specific chief ray.

Discussion:

Patch:
diff --git a/raytracing/imagingpath.py b/raytracing/imagingpath.py
index 82765ea..6a7e46b 100644
--- a/raytracing/imagingpath.py
+++ b/raytracing/imagingpath.py
@@ -151,8 +151,12 @@ class ImagingPath(MatrixGroup):
         If the element B in the transfer matrix for the imaging path
         is zero, there is no value for the height and angle that makes
         a proper chief ray. So the function will return None.
+        If there is no aperture stop, there is no chief ray either. None is also returned.
         """
         (stopPosition, stopDiameter) = self.apertureStop()
+        if stopPosition is None:
+            return None
+
         transferMatrixToApertureStop = self.transferMatrix(upTo=stopPosition)
         A = transferMatrixToApertureStop.A
         B = transferMatrixToApertureStop.B


Test patch:
diff --git a/raytracing/tests/testsImagingPath.py b/raytracing/tests/testsImagingPath.py
index 4e9ed76..b543b8b 100644
--- a/raytracing/tests/testsImagingPath.py
+++ b/raytracing/tests/testsImagingPath.py
@@ -56,6 +56,10 @@ class TestImagingPath(unittest.TestCase):
         path = ImagingPath(elements)
         self.assertIsNotNone(path.entrancePupil())
 
+    def testChiefRayNoApertureStop(self):
+        path = ImagingPath(System2f(10))
+        chiefRay = path.chiefRay()
+        self.assertIsNone(chiefRay)
 
 if __name__ == '__main__':
     unittest.main()