diff --git a/raytracing/imagingpath.py b/raytracing/imagingpath.py
index 6c89bff..b9ee7de 100644
--- a/raytracing/imagingpath.py
+++ b/raytracing/imagingpath.py
@@ -260,6 +260,9 @@ class ImagingPath(MatrixGroup):
         A = transferMatrixToApertureStop.A
         B = transferMatrixToApertureStop.B
 
+        if transferMatrixToApertureStop.isImaging:
+            return None
+
         thetaUp  = (stopDiameter / 2.0 - A * y) / B
         thetaDown = (-stopDiameter / 2.0 - A * y) / B
 

ImagingPath: division by 0 in marginalRays
When we have an `ImagingPath` that has a transfer matrix to the aperture stop with `B == 0`, there is a division by 0 in the calculations of theta + and -. We should check when it's the case and return `None`.
diff --git a/raytracing/tests/testsImagingPath.py b/raytracing/tests/testsImagingPath.py
index 2e24ab7..be8f0e1 100644
--- a/raytracing/tests/testsImagingPath.py
+++ b/raytracing/tests/testsImagingPath.py
@@ -61,6 +61,11 @@ class TestImagingPath(unittest.TestCase):
         chiefRay = path.chiefRay()
         self.assertIsNone(chiefRay)
 
+    def testMarginalRaysIsImaging(self):
+        path = ImagingPath(System4f(10, 10))
+        path.append(Aperture(10))
+        self.assertIsNone(path.marginalRays())
+
     def testImageSizeDIs0(self):
         path = ImagingPath(System2f(f=10, diameter=10))
         path.append(Aperture(20))

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.6
docs/requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
attrs==22.2.0
Babel==2.11.0
certifi==2021.5.30
charset-normalizer==2.0.12
cycler==0.11.0
docutils==0.18.1
idna==3.10
imagesize==1.4.1
importlib-metadata==4.8.3
iniconfig==1.1.1
Jinja2==3.0.3
kiwisolver==1.3.1
MarkupSafe==2.0.1
matplotlib==3.3.4
numpy==1.19.5
packaging==21.3
Pillow==8.4.0
pluggy==1.0.0
py==1.11.0
Pygments==2.14.0
pyparsing==3.1.4
pytest==7.0.1
python-dateutil==2.9.0.post0
pytz==2025.2
-e git+https://github.com/DCC-Lab/RayTracing.git@4e999c92bde9e68c018859054193bf4a00d560a3#egg=raytracing
requests==2.27.1
six==1.17.0
snowballstemmer==2.2.0
Sphinx==5.3.0
sphinx-rtd-theme==0.4.3
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
zipp==3.6.0

name: RayTracing
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - attrs==22.2.0
      - babel==2.11.0
      - charset-normalizer==2.0.12
      - cycler==0.11.0
      - docutils==0.18.1
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - jinja2==3.0.3
      - kiwisolver==1.3.1
      - markupsafe==2.0.1
      - matplotlib==3.3.4
      - numpy==1.19.5
      - packaging==21.3
      - pillow==8.4.0
      - pluggy==1.0.0
      - py==1.11.0
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - requests==2.27.1
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==5.3.0
      - sphinx-rtd-theme==0.4.3
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - zipp==3.6.0
prefix: /opt/conda/envs/RayTracing

raytracing/tests/testsImagingPath.py::TestImagingPath::testMarginalRaysIsImaging
raytracing/tests/testsImagingPath.py::TestImagingPath::testChiefRayNoApertureStop raytracing/tests/testsImagingPath.py::TestImagingPath::testDisplayRangeWithEmptyPath raytracing/tests/testsImagingPath.py::TestImagingPath::testDisplayRangeWithFiniteLens raytracing/tests/testsImagingPath.py::TestImagingPath::testDisplayRangeWithObjectHigherThanLens raytracing/tests/testsImagingPath.py::TestImagingPath::testEntrancePupilAIs0 raytracing/tests/testsImagingPath.py::TestImagingPath::testImageSizeDIs0 raytracing/tests/testsImagingPath.py::TestImagingPath::testImagingPathInfiniteFieldOfView raytracing/tests/testsImagingPath.py::TestImagingPath::testImagingPathInfiniteFieldOfView2 raytracing/tests/testsImagingPath.py::TestImagingPath::testImagingPathInfiniteFieldOfView3
raytracing/imagingpath.py
raytracing/imagingpath.py