Repository: DCC-Lab/RayTracing

Issue:
MatrixGroup: intermediateConjugates gives duplicates
When we want the intermediate conjugates of some matrix groups, we have a list with duplicates. Is it normal?

Example:
```python
path = ImagingPath(System4f(10, 5))
print(path.intermediateConjugates())
```
the output is:
```python
[[30.0, -0.5], [30.0, -0.5]]
```
@dccote I feel like it is redundant information.

Discussion:

Patch:
diff --git a/raytracing/matrixgroup.py b/raytracing/matrixgroup.py
index e6d9e57..0270ed3 100644
--- a/raytracing/matrixgroup.py
+++ b/raytracing/matrixgroup.py
@@ -262,7 +262,10 @@ class MatrixGroup(Matrix):
                 planePosition = transferMatrix.L + distance
                 if planePosition != 0 and conjugate is not None:
                     magnification = conjugate.A
-                    planes.append([planePosition, magnification])
+                    if any([isclose(pos, planePosition) and isclose(mag, magnification) for pos, mag in planes]):
+                        continue
+                    else:
+                        planes.append([planePosition, magnification])
         return planes
 
     def trace(self, inputRay):


Test patch:
diff --git a/raytracing/tests/testsMatrixGroup.py b/raytracing/tests/testsMatrixGroup.py
index d6554e5..3f20888 100644
--- a/raytracing/tests/testsMatrixGroup.py
+++ b/raytracing/tests/testsMatrixGroup.py
@@ -275,6 +275,12 @@ class TestMatrixGroup(envtest.RaytracingTestCase):
         self.assertAlmostEqual(intermediateConjugates[0][0], results[0][0])
         self.assertAlmostEqual(intermediateConjugates[0][1], results[0][1])
 
+    def testIntermediateConjugatesDuplicates(self):
+        elements = [Space(10), Lens(10), Space(15), Lens(5), Space(5)]
+        mg = MatrixGroup(elements)
+        intermediateConj = mg.intermediateConjugates()
+        self.assertListEqual(intermediateConj, [[30.0, -0.5]])
+
     def testHasFiniteApertutreDiameter(self):
         space = Space(10, 1.2541255)
         mg = MatrixGroup([space])