Skip to content

Commit 4000c03

Browse files
Feature/remove distribution dx dy (#112)
* refactor: remove dx and dy properties from BaseDistribution class * docs: update explanation of pupil grids in Tutorial 2a * refactor: remove dx and dy assertions from line_x and line_y tests
1 parent 21d38b4 commit 4000c03

File tree

3 files changed

+3
-33
lines changed

3 files changed

+3
-33
lines changed

docs/examples/Tutorial_2a_Tracing_&_Analyzing_Rays.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"cell_type": "markdown",
7171
"metadata": {},
7272
"source": [
73-
"First, we'll take a look at a few different pupil grids that we can trace through the system."
73+
"First, we'll take a look at a few different pupil grids that we can trace through the system. Note that each distribution has `x` and `y` attributes, which are NumPy arrays containing the points of the distribution."
7474
]
7575
},
7676
{

optiland/distribution.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ class BaseDistribution(ABC):
1818
visualizing the distribution.
1919
2020
Attributes:
21-
dx (float): The step size in x calculated as the difference between
22-
two adjacent x points.
23-
dy (float): The step size in y calculated as the difference between
24-
two adjacent y points.
21+
x (ndarray): The x-coordinates of the generated points.
22+
y (ndarray): The y-coordinates of the generated points.
2523
2624
"""
2725

@@ -35,26 +33,6 @@ def generate_points(self, num_points: int):
3533
"""
3634
# pragma: no cover
3735

38-
@property
39-
def dx(self):
40-
"""The difference between the x-coordinates of two adjacent points.
41-
42-
Returns:
43-
float: The step size in x.
44-
45-
"""
46-
return self.x[1] - self.x[0]
47-
48-
@property
49-
def dy(self):
50-
"""The difference between the y-coordinates of two adjacent points.
51-
52-
Returns:
53-
float: The step size in y.
54-
55-
"""
56-
return self.y[1] - self.y[0]
57-
5836
def view(self):
5937
"""Visualize the distribution.
6038

tests/test_distribution.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@ def test_line_x(num_points):
1111
d = distribution.create_distribution("line_x")
1212
d.generate_points(num_points=num_points)
1313

14-
assert np.allclose(d.dx, 2.0 / (num_points - 1))
15-
assert np.allclose(d.dy, 0.0)
1614
assert np.allclose(d.x, np.linspace(-1, 1, num_points))
1715
assert np.allclose(d.y, np.zeros(num_points))
1816

1917
d = distribution.create_distribution("positive_line_x")
2018
d.generate_points(num_points=num_points)
2119

22-
assert np.allclose(d.dx, 1.0 / (num_points - 1))
23-
assert np.allclose(d.dy, 0.0)
2420
assert np.allclose(d.x, np.linspace(0, 1, num_points))
2521
assert np.allclose(d.y, np.zeros(num_points))
2622

@@ -30,16 +26,12 @@ def test_line_y(num_points):
3026
d = distribution.create_distribution("line_y")
3127
d.generate_points(num_points=num_points)
3228

33-
assert np.allclose(d.dx, 0.0)
34-
assert np.allclose(d.dy, 2.0 / (num_points - 1))
3529
assert np.allclose(d.x, np.zeros(num_points))
3630
assert np.allclose(d.y, np.linspace(-1, 1, num_points))
3731

3832
d = distribution.create_distribution("positive_line_y")
3933
d.generate_points(num_points=num_points)
4034

41-
assert np.allclose(d.dx, 0.0)
42-
assert np.allclose(d.dy, 1.0 / (num_points - 1))
4335
assert np.allclose(d.x, np.zeros(num_points))
4436
assert np.allclose(d.y, np.linspace(0, 1, num_points))
4537

0 commit comments

Comments
 (0)