Skip to content

Commit adfde1f

Browse files
committed
Revert "reformatting some files manually. afraid to use "black""
This reverts commit fd86c99.
1 parent 7a15671 commit adfde1f

File tree

2 files changed

+31
-34
lines changed

2 files changed

+31
-34
lines changed

tests/test_components/test_geometry.py

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

768768

769769
def test_pop_axis():
770+
b = td.Box(size=(1, 1, 1))
770771
for axis in range(3):
771772
coords = (1, 2, 3)
772-
Lz, (Lx, Ly) = td.Box.pop_axis(coords, axis=axis)
773-
_coords = td.Box.unpop_axis(Lz, (Lx, Ly), axis=axis)
773+
Lz, (Lx, Ly) = b.pop_axis(coords, axis=axis)
774+
_coords = b.unpop_axis(Lz, (Lx, Ly), axis=axis)
774775
assert all(c == _c for (c, _c) in zip(coords, _coords))
775-
_Lz, (_Lx, _Ly) = td.Box.pop_axis(_coords, axis=axis)
776+
_Lz, (_Lx, _Ly) = b.pop_axis(_coords, axis=axis)
776777
assert Lz == _Lz
777778
assert Lx == _Lx
778779
assert Ly == _Ly
779780

780781

781782
@pytest.mark.parametrize("transpose", [True, False])
782783
def test_pop_axis_and_swap(transpose):
784+
b = td.Box(size=(1, 1, 1))
783785
for axis in range(3):
784786
coords = (1, 2, 3)
785-
Lz, (Lx, Ly) = td.Box.pop_axis_and_swap(coords, axis=axis, transpose=transpose)
786-
_coords = td.Box.unpop_axis_and_swap(Lz, (Lx, Ly), axis=axis, transpose=transpose)
787+
Lz, (Lx, Ly) = b.pop_axis_and_swap(coords, axis=axis, transpose=transpose)
788+
_coords = b.unpop_axis_and_swap(Lz, (Lx, Ly), axis=axis, transpose=transpose)
787789
assert all(c == _c for (c, _c) in zip(coords, _coords))
788-
_Lz, (_Lx, _Ly) = td.Box.pop_axis_and_swap(_coords, axis=axis, transpose=transpose)
790+
_Lz, (_Lx, _Ly) = b.pop_axis_and_swap(_coords, axis=axis, transpose=transpose)
789791
assert Lz == _Lz
790792
assert Lx == _Lx
791793
assert Ly == _Ly

tidy3d/components/geometry/base.py

Lines changed: 23 additions & 28 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,7 +453,9 @@ def zero_dims(self) -> list[Axis]:
453453
return zero_dims
454454

455455
def _pop_bounds(
456-
self, axis: Axis, transpose: bool = False
456+
self,
457+
axis: Axis,
458+
transpose: bool = False
457459
) -> tuple[Coordinate2D, tuple[Coordinate2D, Coordinate2D]]:
458460
"""Returns min and max bounds in plane normal to and tangential to ``axis``.
459461
@@ -561,9 +563,7 @@ def plot(
561563
ax = self.add_ax_lims(axis=axis, ax=ax, transpose=transpose)
562564
ax.set_aspect("equal")
563565
# Add the default axis labels, tick labels, and title
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-
)
566+
ax = Box.add_ax_labels_and_title(ax=ax, x=x, y=y, z=z, plot_length_units=plot_length_units, transpose=transpose)
567567
return ax
568568

569569
def plot_shape(self, shape: Shapely, plot_params: PlotParams, ax: Ax) -> Ax:
@@ -649,9 +649,7 @@ 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(
653-
self, axis: Axis, ax: Ax, buffer: float = PLOT_BUFFER, transpose: bool = False
654-
) -> Ax:
652+
def add_ax_lims(self, axis: Axis, ax: Ax, buffer: float = PLOT_BUFFER, transpose: bool = False) -> Ax:
655653
"""Sets the horizontal and vertical axis limits based on ``self.bounds``.
656654
657655
Parameters
@@ -670,9 +668,7 @@ def add_ax_lims(
670668
matplotlib.axes._subplots.Axes
671669
The supplied or created matplotlib axes.
672670
"""
673-
(xmin, xmax), (ymin, ymax) = self._get_plot_limits(
674-
axis=axis, buffer=buffer, transpose=transpose
675-
)
671+
(xmin, xmax), (ymin, ymax) = self._get_plot_limits(axis=axis, buffer=buffer, transpose=transpose)
676672

677673
# note: axes limits dont like inf values, so we need to evaluate them first if present
678674
xmin, xmax, ymin, ymax = self._evaluate_inf((xmin, xmax, ymin, ymax))
@@ -767,6 +763,7 @@ def pop_axis(
767763
axis : int
768764
Integer index into 'xyz' (0,1,2).
769765
766+
770767
Returns
771768
-------
772769
Any, Tuple[Any, Any]
@@ -797,8 +794,8 @@ def pop_axis_and_swap(
797794
Tuple of three values in original coordinate system.
798795
axis : int
799796
Integer index into 'xyz' (0,1,2).
800-
transpose : bool = False
801-
Optional: Swap the order of the data from the two remaining axes in the output tuple.
797+
transpose: bool = False
798+
Optional: Swap the order of the data from the two remaining axes in the output tuple?
802799
803800
Returns
804801
-------
@@ -865,7 +862,7 @@ def unpop_axis_and_swap(
865862
axis : int
866863
Integer index into 'xyz' (0,1,2).
867864
transpose: bool = False
868-
Optional: Swap the order of the entries in plane_coords[].
865+
Optional: Swap the order of the entries in plane_coords[]?
869866
870867
Returns
871868
-------
@@ -1682,7 +1679,7 @@ def intersections_tilted_plane(
16821679
axis = np.argmax(np.abs(normal)).item()
16831680
coord = "xyz"[axis]
16841681
kwargs = {coord: origin[axis]}
1685-
section = self.intersections_plane(**kwargs)
1682+
section = self.intersections_plane(**kwargs) # <-- BUG?: X,Y axis order ignores normal axis direction +/-
16861683
# Apply transformation in the plane by removing row and column
16871684
to_2D_in_plane = np.delete(np.delete(to_2D, 2, 0), axis, 1)
16881685

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

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

21612162
def intersections_plane(
2162-
self,
2163-
x: Optional[float] = None,
2164-
y: Optional[float] = None,
2163+
self,
2164+
x: Optional[float] = None,
2165+
y: Optional[float] = None,
21652166
z: Optional[float] = None,
21662167
transpose: bool = False,
21672168
):
@@ -2264,10 +2265,7 @@ def intersections_with(self, other, transpose: bool = False):
22642265
shapes_plane = other.intersections_plane(**xyz_kwargs, transpose=transpose)
22652266

22662267
# intersect all shapes with the input self
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-
)
2268+
bs_min, bs_max = (self.pop_axis_and_swap(bounds, axis=normal_ind, transpose=transpose)[1] for bounds in self.bounds)
22712269

22722270
shapely_box = self.make_shapely_box(bs_min[0], bs_min[1], bs_max[0], bs_max[1])
22732271
shapely_box = Geometry.evaluate_inf_shape(shapely_box)
@@ -2362,8 +2360,7 @@ def _plot_arrow(
23622360
arrow_base : :class:`.Coordinate` = None
23632361
Custom base of the arrow. Uses the geometry's center if not provided.
23642362
transpose : bool = False
2365-
Swap horizontal and vertical axes. (This overrides the default
2366-
lexicographic axis order.)
2363+
Swap horizontal and vertical axes. (This overrides the default lexicographic axis order.)
23672364
23682365
Returns
23692366
-------
@@ -2376,9 +2373,7 @@ def _plot_arrow(
23762373

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

0 commit comments

Comments
 (0)