-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
406 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
from . import materials | ||
from . import apertures | ||
from . import rulings | ||
from . import surfaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
import abc | ||
import numpy as np | ||
import optika.propagators | ||
import optika.rays._tests.test_ray_vectors | ||
|
||
|
||
class AbstractTestAbstractPropagator( | ||
abc.ABC, | ||
): | ||
pass | ||
|
||
|
||
class AbstractTestAbstractRayPropagator( | ||
AbstractTestAbstractPropagator, | ||
): | ||
@pytest.mark.parametrize("rays", optika.rays._tests.test_ray_vectors.rays) | ||
def test_propagate_rays( | ||
self, | ||
a: optika.propagators.AbstractRayPropagator, | ||
rays: optika.rays.AbstractRayVectorArray, | ||
): | ||
result = a.propagate_rays(rays) | ||
|
||
assert isinstance(result, optika.rays.AbstractRayVectorArray) | ||
assert not np.all(result == rays) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import pytest | ||
import astropy.units as u | ||
import named_arrays as na | ||
import optika | ||
from . import test_mixins | ||
from . import test_plotting | ||
from . import test_propagators | ||
|
||
|
||
surfaces = [ | ||
optika.surfaces.Surface(), | ||
optika.surfaces.Surface( | ||
name="test_surface", | ||
sag=optika.sags.SphericalSag(radius=1000 * u.mm), | ||
material=optika.materials.Mirror(), | ||
aperture=optika.apertures.RectangularAperture(half_width=10 * u.mm), | ||
transformation=na.transformations.Cartesian3dTranslation(z=100 * u.mm), | ||
), | ||
] | ||
|
||
|
||
class AbstractTestAbstractSurface( | ||
test_plotting.AbstractTestPlottable, | ||
test_mixins.AbstractTestTransformable, | ||
test_propagators.AbstractTestAbstractRayPropagator, | ||
): | ||
def test_name(self, a: optika.surfaces.AbstractSurface): | ||
if a.name is not None: | ||
assert isinstance(a.name, str) | ||
|
||
def test_sag(self, a: optika.surfaces.AbstractSurface): | ||
assert isinstance(a.sag, optika.sags.AbstractSag) | ||
|
||
def test_material(self, a: optika.surfaces.AbstractSurface): | ||
assert isinstance(a.material, optika.materials.AbstractMaterial) | ||
|
||
def test_aperture(self, a: optika.surfaces.AbstractSurface): | ||
if a.aperture is not None: | ||
assert isinstance(a.aperture, optika.apertures.AbstractAperture) | ||
|
||
def test_aperture_mechanical(self, a: optika.surfaces.AbstractSurface): | ||
if a.aperture_mechanical is not None: | ||
assert isinstance(a.aperture_mechanical, optika.apertures.AbstractAperture) | ||
|
||
def test_rulings(self, a: optika.surfaces.AbstractSurface): | ||
if a.rulings is not None: | ||
assert isinstance(a.rulings, optika.rulings.AbstractRulings) | ||
|
||
def test_is_field_stop(self, a: optika.surfaces.AbstractSurface): | ||
assert isinstance(a.is_field_stop, bool) | ||
|
||
def test_is_pupil_stop(self, a: optika.surfaces.AbstractSurface): | ||
assert isinstance(a.is_pupil_stop, bool) | ||
|
||
def test_is_spectral_stop(self, a: optika.surfaces.AbstractSurface): | ||
assert isinstance(a.is_spectral_stop, bool) | ||
|
||
|
||
@pytest.mark.parametrize("a", surfaces) | ||
class TestSurface( | ||
AbstractTestAbstractSurface, | ||
): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import abc | ||
import dataclasses | ||
import optika | ||
|
||
__all__ = [ | ||
"AbstractPropagator", | ||
"AbstractRayPropagator", | ||
] | ||
|
||
|
||
@dataclasses.dataclass(eq=False, repr=False) | ||
class AbstractPropagator( | ||
abc.ABC, | ||
): | ||
pass | ||
|
||
|
||
@dataclasses.dataclass(eq=False, repr=False) | ||
class AbstractRayPropagator( | ||
AbstractPropagator, | ||
): | ||
@abc.abstractmethod | ||
def propagate_rays( | ||
self, | ||
rays: optika.rays.AbstractRayVectorArray, | ||
) -> optika.rays.AbstractRayVectorArray: | ||
""" | ||
for the given input rays, calculate new rays based off of their | ||
interation with this object | ||
Parameters | ||
---------- | ||
rays | ||
a set of input rays that will interact with this object | ||
""" |
Oops, something went wrong.