Skip to content

Commit fd86c99

Browse files
committed
reformatting some files manually. afraid to use "black"
1 parent 8e2c89a commit fd86c99

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

tests/test_components/test_geometry.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -766,27 +766,25 @@ def test_geometry_touching_intersections_plane(x0):
766766

767767

768768
def test_pop_axis():
769-
b = td.Box(size=(1, 1, 1))
770769
for axis in range(3):
771770
coords = (1, 2, 3)
772-
Lz, (Lx, Ly) = b.pop_axis(coords, axis=axis)
773-
_coords = b.unpop_axis(Lz, (Lx, Ly), axis=axis)
771+
Lz, (Lx, Ly) = td.Box.pop_axis(coords, axis=axis)
772+
_coords = td.Box.unpop_axis(Lz, (Lx, Ly), axis=axis)
774773
assert all(c == _c for (c, _c) in zip(coords, _coords))
775-
_Lz, (_Lx, _Ly) = b.pop_axis(_coords, axis=axis)
774+
_Lz, (_Lx, _Ly) = td.Box.pop_axis(_coords, axis=axis)
776775
assert Lz == _Lz
777776
assert Lx == _Lx
778777
assert Ly == _Ly
779778

780779

781780
@pytest.mark.parametrize("transpose", [True, False])
782781
def test_pop_axis_and_swap(transpose):
783-
b = td.Box(size=(1, 1, 1))
784782
for axis in range(3):
785783
coords = (1, 2, 3)
786-
Lz, (Lx, Ly) = b.pop_axis_and_swap(coords, axis=axis, transpose=transpose)
787-
_coords = b.unpop_axis_and_swap(Lz, (Lx, Ly), axis=axis, transpose=transpose)
784+
Lz, (Lx, Ly) = td.Box.pop_axis_and_swap(coords, axis=axis, transpose=transpose)
785+
_coords = td.Box.unpop_axis_and_swap(Lz, (Lx, Ly), axis=axis, transpose=transpose)
788786
assert all(c == _c for (c, _c) in zip(coords, _coords))
789-
_Lz, (_Lx, _Ly) = b.pop_axis_and_swap(_coords, axis=axis, transpose=transpose)
787+
_Lz, (_Lx, _Ly) = td.Box.pop_axis_and_swap(_coords, axis=axis, transpose=transpose)
790788
assert Lz == _Lz
791789
assert Lx == _Lx
792790
assert Ly == _Ly

tidy3d/components/geometry/base.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def intersections_tilted_plane(
236236
"""
237237

238238
def intersections_plane(
239-
self,
239+
self,
240240
x: Optional[float] = None,
241241
y: Optional[float] = None,
242242
z: Optional[float] = None,
@@ -453,9 +453,7 @@ def zero_dims(self) -> list[Axis]:
453453
return zero_dims
454454

455455
def _pop_bounds(
456-
self,
457-
axis: Axis,
458-
transpose: bool = False
456+
self, axis: Axis, transpose: bool = False
459457
) -> tuple[Coordinate2D, tuple[Coordinate2D, Coordinate2D]]:
460458
"""Returns min and max bounds in plane normal to and tangential to ``axis``.
461459
@@ -563,7 +561,9 @@ def plot(
563561
ax = self.add_ax_lims(axis=axis, ax=ax, transpose=transpose)
564562
ax.set_aspect("equal")
565563
# Add the default axis labels, tick labels, and title
566-
ax = Box.add_ax_labels_and_title(ax=ax, x=x, y=y, z=z, plot_length_units=plot_length_units, transpose=transpose)
564+
ax = Box.add_ax_labels_and_title(
565+
ax=ax, x=x, y=y, z=z, plot_length_units=plot_length_units, transpose=transpose
566+
)
567567
return ax
568568

569569
def plot_shape(self, shape: Shapely, plot_params: PlotParams, ax: Ax) -> Ax:
@@ -649,7 +649,9 @@ def _get_plot_limits(
649649
_, ((xmin, ymin), (xmax, ymax)) = self._pop_bounds(axis=axis, transpose=transpose)
650650
return (xmin - buffer, xmax + buffer), (ymin - buffer, ymax + buffer)
651651

652-
def add_ax_lims(self, axis: Axis, ax: Ax, buffer: float = PLOT_BUFFER, transpose: bool = False) -> Ax:
652+
def add_ax_lims(
653+
self, axis: Axis, ax: Ax, buffer: float = PLOT_BUFFER, transpose: bool = False
654+
) -> Ax:
653655
"""Sets the horizontal and vertical axis limits based on ``self.bounds``.
654656
655657
Parameters
@@ -668,7 +670,9 @@ def add_ax_lims(self, axis: Axis, ax: Ax, buffer: float = PLOT_BUFFER, transpose
668670
matplotlib.axes._subplots.Axes
669671
The supplied or created matplotlib axes.
670672
"""
671-
(xmin, xmax), (ymin, ymax) = self._get_plot_limits(axis=axis, buffer=buffer, transpose=transpose)
673+
(xmin, xmax), (ymin, ymax) = self._get_plot_limits(
674+
axis=axis, buffer=buffer, transpose=transpose
675+
)
672676

673677
# note: axes limits dont like inf values, so we need to evaluate them first if present
674678
xmin, xmax, ymin, ymax = self._evaluate_inf((xmin, xmax, ymin, ymax))
@@ -763,7 +767,6 @@ def pop_axis(
763767
axis : int
764768
Integer index into 'xyz' (0,1,2).
765769
766-
767770
Returns
768771
-------
769772
Any, Tuple[Any, Any]
@@ -794,8 +797,8 @@ def pop_axis_and_swap(
794797
Tuple of three values in original coordinate system.
795798
axis : int
796799
Integer index into 'xyz' (0,1,2).
797-
transpose: bool = False
798-
Optional: Swap the order of the data from the two remaining axes in the output tuple?
800+
transpose : bool = False
801+
Optional: Swap the order of the data from the two remaining axes in the output tuple.
799802
800803
Returns
801804
-------
@@ -862,7 +865,7 @@ def unpop_axis_and_swap(
862865
axis : int
863866
Integer index into 'xyz' (0,1,2).
864867
transpose: bool = False
865-
Optional: Swap the order of the entries in plane_coords[]?
868+
Optional: Swap the order of the entries in plane_coords[].
866869
867870
Returns
868871
-------
@@ -1679,7 +1682,7 @@ def intersections_tilted_plane(
16791682
axis = np.argmax(np.abs(normal)).item()
16801683
coord = "xyz"[axis]
16811684
kwargs = {coord: origin[axis]}
1682-
section = self.intersections_plane(**kwargs) # <-- BUG?: X,Y axis order ignores normal axis direction +/-
1685+
section = self.intersections_plane(**kwargs)
16831686
# Apply transformation in the plane by removing row and column
16841687
to_2D_in_plane = np.delete(np.delete(to_2D, 2, 0), axis, 1)
16851688

@@ -1866,11 +1869,7 @@ def _order_axis(self, axis: int) -> int:
18661869
return axis_index[axis]
18671870

18681871
def _order_by_axis(
1869-
self,
1870-
plane_val: Any,
1871-
axis_val: Any,
1872-
axis: int,
1873-
transpose: bool = False
1872+
self, plane_val: Any, axis_val: Any, axis: int, transpose: bool = False
18741873
) -> tuple[Any, Any]:
18751874
"""Orders a value in the plane and value along axis in correct (x,y) order for plotting.
18761875
Note: sometimes if axis=1 and we compute cross section values orthogonal to axis,
@@ -2160,9 +2159,9 @@ def _do_intersections_tilted_plane(
21602159
return path.polygons_full
21612160

21622161
def intersections_plane(
2163-
self,
2164-
x: Optional[float] = None,
2165-
y: Optional[float] = None,
2162+
self,
2163+
x: Optional[float] = None,
2164+
y: Optional[float] = None,
21662165
z: Optional[float] = None,
21672166
transpose: bool = False,
21682167
):
@@ -2265,7 +2264,10 @@ def intersections_with(self, other, transpose: bool = False):
22652264
shapes_plane = other.intersections_plane(**xyz_kwargs, transpose=transpose)
22662265

22672266
# intersect all shapes with the input self
2268-
bs_min, bs_max = (self.pop_axis_and_swap(bounds, axis=normal_ind, transpose=transpose)[1] for bounds in self.bounds)
2267+
bs_min, bs_max = (
2268+
self.pop_axis_and_swap(bounds, axis=normal_ind, transpose=transpose)[1]
2269+
for bounds in self.bounds
2270+
)
22692271

22702272
shapely_box = self.make_shapely_box(bs_min[0], bs_min[1], bs_max[0], bs_max[1])
22712273
shapely_box = Geometry.evaluate_inf_shape(shapely_box)
@@ -2360,7 +2362,8 @@ def _plot_arrow(
23602362
arrow_base : :class:`.Coordinate` = None
23612363
Custom base of the arrow. Uses the geometry's center if not provided.
23622364
transpose : bool = False
2363-
Swap horizontal and vertical axes. (This overrides the default lexicographic axis order.)
2365+
Swap horizontal and vertical axes. (This overrides the default
2366+
lexicographic axis order.)
23642367
23652368
Returns
23662369
-------
@@ -2373,7 +2376,9 @@ def _plot_arrow(
23732376

23742377
# conditions to check to determine whether to plot arrow, taking into account the
23752378
# possibility of a custom arrow base
2376-
arrow_intersecting_plane = len(self.intersections_plane(x=x, y=y, z=z, transpose=transpose)) > 0
2379+
arrow_intersecting_plane = (
2380+
len(self.intersections_plane(x=x, y=y, z=z, transpose=transpose)) > 0
2381+
)
23772382
center = self.center
23782383
if arrow_base:
23792384
arrow_intersecting_plane = arrow_intersecting_plane and any(

0 commit comments

Comments
 (0)