# Path: batoid/medium.py
# class ConstMedium(Medium):
#     """A `Medium` with wavelength-independent refractive index.
# 
#     Parameters
#     ----------
#     n : float
#         The refractive index.
#     """
#     def __init__(self, n):
#         self.n = n
#         self._medium = _batoid.CPPConstMedium(n)
# 
#     def __eq__(self, rhs):
#         if type(rhs) == type(self):
#             return self.n == rhs.n
#         return False
# 
#     def __getstate__(self):
#         return self.n
# 
#     def __setstate__(self, n):
#         self.n = n
#         self._medium = _batoid.CPPConstMedium(n)
# 
#     def __hash__(self):
#         return hash(("batoid.ConstMedium", self.n))
# 
#     def __repr__(self):
#         return f"ConstMedium({self.n})"
# 
# Path: batoid/optic.py
# class RefractiveInterface(Interface):
#     """Specialization for refractive interfaces.
# 
#     Rays will interact with this surface by refracting through it.
#     """
#     def __init__(self, *args, **kwargs):
#         Interface.__init__(self, *args, **kwargs)
#         self.forwardCoating = SimpleCoating(
#             reflectivity=0.0, transmissivity=1.0
#         )
#         self.reverseCoating = SimpleCoating(
#             reflectivity=0.0, transmissivity=1.0
#         )
# 
#     def interact(self, rv, reverse=False):
#         if reverse:
#             m1, m2 = self.outMedium, self.inMedium
#         else:
#             m1, m2 = self.inMedium, self.outMedium
#         return self.surface.refract(rv, m1, m2, coordSys=self.coordSys)
# 
#     def rSplit(self, rv, reverse=False):
#         # always return in order: refracted, reflected
#         if reverse:
#             m1 = self.outMedium
#             m2 = self.inMedium
#             coating = self.forwardCoating
#         else:
#             m1 = self.inMedium
#             m2 = self.outMedium
#             coating = self.reverseCoating
# 
#         return self.surface.rSplit(rv, m1, m2, coating, coordSys=self.coordSys)


from batoid.medium import ConstMedium
from batoid.optic import RefractiveInterface
from test_helpers import timer, rays_allclose
import batoid
import numpy as np
        m1 = batoid.Air()
        m2 = batoid.ConstMedium(1.1)
        refractedRays = asphere.refract(rays.copy(), m1, m2, coating=coating)
        refractedRays2, reflectedRays2 = asphere.rSplit(rays, m1, m2, coating)

        rays_allclose(reflectedRays, reflectedRays2)
        rays_allclose(refractedRays, refractedRays2)


@timer
def test_traceSplit_simple():
    telescope = batoid.CompoundOptic(
        name = "simple",
        stopSurface=batoid.Interface(batoid.Plane()),
        items = [
            batoid.Lens(
                name = "L1",
                items = [
                    batoid.RefractiveInterface(
                        batoid.Plane(),
                        name = "L1_entrance",
                        coordSys=batoid.CoordSys(origin=[0,0,0.3]),
                        inMedium=batoid.ConstMedium(1.0),
                        outMedium=batoid.ConstMedium(1.1)
                    ),
                    batoid.RefractiveInterface(
                        batoid.Plane(),
                        name = "L1_exit",
                        coordSys=batoid.CoordSys(origin=[0,0,0.2]),
                        inMedium=batoid.ConstMedium(1.1),

# Path: batoid/medium.py
# class ConstMedium(Medium):
#     """A `Medium` with wavelength-independent refractive index.
# 
#     Parameters
#     ----------
#     n : float
#         The refractive index.
#     """
#     def __init__(self, n):
#         self.n = n
#         self._medium = _batoid.CPPConstMedium(n)
# 
#     def __eq__(self, rhs):
#         if type(rhs) == type(self):
#             return self.n == rhs.n
#         return False
# 
#     def __getstate__(self):
#         return self.n
# 
#     def __setstate__(self, n):
#         self.n = n
#         self._medium = _batoid.CPPConstMedium(n)
# 
#     def __hash__(self):
#         return hash(("batoid.ConstMedium", self.n))
# 
#     def __repr__(self):
#         return f"ConstMedium({self.n})"
# 
# Path: batoid/optic.py
# class RefractiveInterface(Interface):
#     """Specialization for refractive interfaces.
# 
#     Rays will interact with this surface by refracting through it.
#     """
#     def __init__(self, *args, **kwargs):
#         Interface.__init__(self, *args, **kwargs)
#         self.forwardCoating = SimpleCoating(
#             reflectivity=0.0, transmissivity=1.0
#         )
#         self.reverseCoating = SimpleCoating(
#             reflectivity=0.0, transmissivity=1.0
#         )
# 
#     def interact(self, rv, reverse=False):
#         if reverse:
#             m1, m2 = self.outMedium, self.inMedium
#         else:
#             m1, m2 = self.inMedium, self.outMedium
#         return self.surface.refract(rv, m1, m2, coordSys=self.coordSys)
# 
#     def rSplit(self, rv, reverse=False):
#         # always return in order: refracted, reflected
#         if reverse:
#             m1 = self.outMedium
#             m2 = self.inMedium
#             coating = self.forwardCoating
#         else:
#             m1 = self.inMedium
#             m2 = self.outMedium
#             coating = self.reverseCoating
# 
#         return self.surface.rSplit(rv, m1, m2, coating, coordSys=self.coordSys)


# Path: tests/test_rsplit.py
from batoid.medium import ConstMedium
from batoid.optic import RefractiveInterface
from test_helpers import timer, rays_allclose
import batoid
import numpy as np

        m1 = batoid.Air()
        m2 = batoid.ConstMedium(1.1)
        refractedRays = asphere.refract(rays.copy(), m1, m2, coating=coating)
        refractedRays2, reflectedRays2 = asphere.rSplit(rays, m1, m2, coating)

        rays_allclose(reflectedRays, reflectedRays2)
        rays_allclose(refractedRays, refractedRays2)


@timer
def test_traceSplit_simple():
    telescope = batoid.CompoundOptic(
        name = "simple",
        stopSurface=batoid.Interface(batoid.Plane()),
        items = [
            batoid.Lens(
                name = "L1",
                items = [
                    batoid.RefractiveInterface(
                        batoid.Plane(),
                        name = "L1_entrance",
                        coordSys=batoid.CoordSys(origin=[0,0,0.3]),
                        inMedium=batoid.ConstMedium(1.0),
                        outMedium=batoid.ConstMedium(1.1)
                    ),
                    batoid.RefractiveInterface(
                        batoid.Plane(),
                        name = "L1_exit",
                        coordSys=batoid.CoordSys(origin=[0,0,0.2]),
                        inMedium=batoid.ConstMedium(1.1),

                        outMedium=batoid.ConstMedium(1.0)