Skip to content

Commit e7af755

Browse files
committed
updated manually, following Tyler's suggestions. I also corrected the docstring for , as suggested by the "greptile-apps" bot.
1 parent 1f86cc8 commit e7af755

File tree

2 files changed

+71
-50
lines changed

2 files changed

+71
-50
lines changed

tidy3d/components/base_sim/simulation.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ def plot_structures_heat_conductivity(
692692
transpose: bool = False,
693693
) -> Ax:
694694
"""Plot each of simulation's structures on a plane defined by one nonzero x,y,z coordinate.
695-
The permittivity is plotted in grayscale based on its value at the specified frequency.
695+
The conductivity is plotted in grayscale based on its value.
696696
697697
Parameters
698698
----------
@@ -702,14 +702,11 @@ def plot_structures_heat_conductivity(
702702
position of plane in y direction, only one of x, y, z must be specified to define plane.
703703
z : float = None
704704
position of plane in z direction, only one of x, y, z must be specified to define plane.
705-
freq : float = None
706-
Frequency to evaluate the relative permittivity of all mediums.
707-
If not specified, evaluates at infinite frequency.
708705
reverse : bool = False
709-
If ``False``, the highest permittivity is plotted in black.
706+
If ``False``, the highest conductivity is plotted in black.
710707
If ``True``, it is plotteed in white (suitable for black backgrounds).
711708
cbar : bool = True
712-
Whether to plot a colorbar for the relative permittivity.
709+
Whether to plot a colorbar for the relative conductivity.
713710
alpha : float = None
714711
Opacity of the structures being plotted.
715712
Defaults to the structure default alpha.
@@ -720,7 +717,8 @@ def plot_structures_heat_conductivity(
720717
vlim : Tuple[float, float] = None
721718
The z range if plotting on xz or yz planes, y plane if plotting on xy plane.
722719
transpose : bool = False
723-
Swap horizontal and vertical axes. (This overrides the default lexicographic axis order.)
720+
Swap horizontal and vertical axes. (This overrides the default
721+
lexicographic axis order.)
724722
725723
Returns
726724
-------

tidy3d/components/geometry/base.py

Lines changed: 66 additions & 43 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,
@@ -253,7 +253,8 @@ def intersections_plane(
253253
z : float = None
254254
Position of plane in z direction, only one of x,y,z can be specified to define plane.
255255
transpose : bool = False
256-
Optional: Swap the coordinates in the plane. (This overrides the default lexicographic axis order.)
256+
Optional: Swap the coordinates in the plane. (This overrides the
257+
default lexicographic axis order.)
257258
258259
Returns
259260
-------
@@ -280,7 +281,8 @@ def intersections_2dbox(self, plane: Box, transpose: bool = False) -> list[Shape
280281
plane : Box
281282
Plane specification.
282283
transpose : bool = False
283-
Optional: Swap the coordinates in the plane. (This overrides the default lexicographic axis order.)
284+
Optional: Swap the coordinates in the plane. (This overrides the
285+
default lexicographic axis order.)
284286
285287
Returns
286288
-------
@@ -453,9 +455,7 @@ def zero_dims(self) -> list[Axis]:
453455
return zero_dims
454456

455457
def _pop_bounds(
456-
self,
457-
axis: Axis,
458-
transpose: bool = False
458+
self, axis: Axis, transpose: bool = False
459459
) -> tuple[Coordinate2D, tuple[Coordinate2D, Coordinate2D]]:
460460
"""Returns min and max bounds in plane normal to and tangential to ``axis``.
461461
@@ -464,7 +464,8 @@ def _pop_bounds(
464464
axis : int
465465
Integer index into 'xyz' (0,1,2).
466466
transpose : bool = False
467-
Optional: Swap the coordinates in the plane. (This overrides the default lexicographic axis order.)
467+
Optional: Swap the coordinates in the plane. (This overrides the
468+
default lexicographic axis order.)
468469
469470
Returns
470471
-------
@@ -535,7 +536,8 @@ def plot(
535536
viz_spec : VisualizationSpec = None
536537
Plotting parameters associated with a medium to use instead of defaults.
537538
transpose : bool = False
538-
Swap horizontal and vertical axes. (This overrides the default lexicographic axis order.)
539+
Swap horizontal and vertical axes. (This overrides the default
540+
lexicographic axis order.)
539541
**patch_kwargs
540542
Optional keyword arguments passed to the matplotlib patch plotting of structure.
541543
For details on accepted values, refer to
@@ -563,7 +565,9 @@ def plot(
563565
ax = self.add_ax_lims(axis=axis, ax=ax, transpose=transpose)
564566
ax.set_aspect("equal")
565567
# 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)
568+
ax = Box.add_ax_labels_and_title(
569+
ax=ax, x=x, y=y, z=z, plot_length_units=plot_length_units, transpose=transpose
570+
)
567571
return ax
568572

569573
def plot_shape(self, shape: Shapely, plot_params: PlotParams, ax: Ax) -> Ax:
@@ -619,7 +623,8 @@ def _get_plot_labels(axis: Axis, transpose: bool = False) -> tuple[str, str]:
619623
axis : int
620624
Integer index into 'xyz' (0,1,2).
621625
transpose : bool = False
622-
Optional: Swap horizontal and vertical plot labels. (This overrides the default lexicographic axis order.)
626+
Optional: Swap horizontal and vertical plot labels.
627+
(This overrides the default lexicographic axis order.)
623628
624629
Returns
625630
-------
@@ -640,6 +645,9 @@ def _get_plot_limits(
640645
Integer index into 'xyz' (0,1,2).
641646
buffer : float = 0.3
642647
Amount of space to add around the limits on the + and - sides.
648+
transpose : bool = False
649+
Optional: Swap horizontal and vertical axis limits.
650+
(This overrides the default lexicographic axis order.)
643651
644652
Returns
645653
-------
@@ -649,7 +657,9 @@ def _get_plot_limits(
649657
_, ((xmin, ymin), (xmax, ymax)) = self._pop_bounds(axis=axis, transpose=transpose)
650658
return (xmin - buffer, xmax + buffer), (ymin - buffer, ymax + buffer)
651659

652-
def add_ax_lims(self, axis: Axis, ax: Ax, buffer: float = PLOT_BUFFER, transpose: bool = False) -> Ax:
660+
def add_ax_lims(
661+
self, axis: Axis, ax: Ax, buffer: float = PLOT_BUFFER, transpose: bool = False
662+
) -> Ax:
653663
"""Sets the horizontal and vertical axis limits based on ``self.bounds``.
654664
655665
Parameters
@@ -661,14 +671,17 @@ def add_ax_lims(self, axis: Axis, ax: Ax, buffer: float = PLOT_BUFFER, transpose
661671
buffer : float = 0.3
662672
Amount of space to place around the limits on the + and - sides.
663673
transpose : bool = False
664-
Optional: Swap horizontal and vertical axis limits. (This overrides the default lexicographic axis order.)
674+
Optional: Swap horizontal and vertical axis limits.
675+
(This overrides the default lexicographic axis order.)
665676
666677
Returns
667678
-------
668679
matplotlib.axes._subplots.Axes
669680
The supplied or created matplotlib axes.
670681
"""
671-
(xmin, xmax), (ymin, ymax) = self._get_plot_limits(axis=axis, buffer=buffer, transpose=transpose)
682+
(xmin, xmax), (ymin, ymax) = self._get_plot_limits(
683+
axis=axis, buffer=buffer, transpose=transpose
684+
)
672685

673686
# note: axes limits dont like inf values, so we need to evaluate them first if present
674687
xmin, xmax, ymin, ymax = self._evaluate_inf((xmin, xmax, ymin, ymax))
@@ -703,7 +716,8 @@ def add_ax_labels_and_title(
703716
When set to a supported ``LengthUnit``, plots will be produced with annotated axes
704717
and title with the proper units.
705718
transpose : bool = False
706-
Optional: Swap horizontal and vertical axis labels. (This overrides the default lexicographic axis order.)
719+
Optional: Swap horizontal and vertical axis labels.
720+
(This overrides the default lexicographic axis order.)
707721
708722
Returns
709723
-------
@@ -782,20 +796,20 @@ def pop_axis_and_swap(
782796
transpose: bool = False,
783797
) -> tuple[Any, tuple[Any, Any]]:
784798
"""
785-
pop_axis_and_swap() is identical to pop_axis(), except that accepts an
786-
additional "transpose" argument which reverses the output order. Examples:
799+
``pop_axis_and_swap()`` is identical to ``pop_axis()``, except that it accepts an
800+
additional ``transpose`` argument which reverses the output order. Examples:
787801
788-
pop_axis_and_swap(("x", "y", "z"), 1, transpose=False) -> "y", ("x", "z")
789-
pop_axis_and_swap(("x", "y", "z"), 1, transpose=True) -> "y", ("z", "x")
802+
``pop_axis_and_swap(("x", "y", "z"), 1, transpose=False)`` -> ``("y", ("x", "z"))``
803+
``pop_axis_and_swap(("x", "y", "z"), 1, transpose=True)`` -> ``("y", ("z", "x"))``
790804
791805
Parameters
792806
----------
793807
coord : Tuple[Any, Any, Any]
794808
Tuple of three values in original coordinate system.
795809
axis : int
796810
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?
811+
transpose : bool = False
812+
Optional: Swap the order of the data from the two remaining axes in the output tuple.
799813
800814
Returns
801815
-------
@@ -843,15 +857,15 @@ def unpop_axis_and_swap(
843857
transpose: bool = False,
844858
) -> tuple[Any, Any, Any]:
845859
"""
846-
unpop_axis_and_swap() is identical to unpop_axis(), except that accepts
847-
an additional "transpose" argument which reverses the order of
848-
plane_coords before sending them to unpop_axis(). For example:
860+
``unpop_axis_and_swap()`` is identical to ``unpop_axis()``, except that
861+
it accepts an additional ``transpose`` argument which reverses the order of
862+
``plane_coords`` before sending them to ``unpop_axis()``. For example:
849863
850-
unpop_axis_and_swap("y", ("x", "z"), 1, transpose=False) --> ("x", "y", "z")
851-
unpop_axis_and_swap("y", ("x", "z"), 1, transpose=True) --> ("z", "y", "x")
864+
``unpop_axis_and_swap("y", ("x", "z"), 1, transpose=False)`` --> ``("x", "y", "z")``
865+
``unpop_axis_and_swap("y", ("x", "z"), 1, transpose=True)`` --> ``("z", "y", "x")``
852866
853-
This function is the inverse of pop_axis_and_swap(). For example:
854-
unpop_axis_and_swap("y", ("z", "x"), 1, transpose=True) --> ("x", "y", "z")
867+
This function is the inverse of ``pop_axis_and_swap()``. For example:
868+
``unpop_axis_and_swap("y", ("z", "x"), 1, transpose=True)`` --> ``("x", "y", "z")``
855869
856870
Parameters
857871
----------
@@ -861,8 +875,9 @@ def unpop_axis_and_swap(
861875
Values along ordered planar directions.
862876
axis : int
863877
Integer index into 'xyz' (0,1,2).
864-
transpose: bool = False
865-
Optional: Swap the order of the entries in plane_coords[]?
878+
transpose : bool = False
879+
Optional: Swap the order of the entries in plane_coords[].
880+
(This overrides the default lexicographic axis order.)
866881
867882
Returns
868883
-------
@@ -1679,7 +1694,7 @@ def intersections_tilted_plane(
16791694
axis = np.argmax(np.abs(normal)).item()
16801695
coord = "xyz"[axis]
16811696
kwargs = {coord: origin[axis]}
1682-
section = self.intersections_plane(**kwargs) # <-- BUG?: X,Y axis order ignores normal axis direction +/-
1697+
section = self.intersections_plane(**kwargs)
16831698
# Apply transformation in the plane by removing row and column
16841699
to_2D_in_plane = np.delete(np.delete(to_2D, 2, 0), axis, 1)
16851700

@@ -1793,6 +1808,7 @@ def intersections_plane(
17931808
Position of plane in z direction, only one of x,y,z can be specified to define plane.
17941809
transpose : bool = False
17951810
Optional: Swap the coordinates in the plane before calculating intersections.
1811+
(This overrides the default lexicographic axis order.)
17961812
17971813
Returns
17981814
-------
@@ -1818,6 +1834,7 @@ def _intersections_normal(self, z: float, transpose: bool = False) -> list:
18181834
Position along the axis normal to slab
18191835
transpose : bool = False
18201836
Optional: Swap the coordinates in the plane before calculating intersections.
1837+
(This overrides the default lexicographic axis order.)
18211838
18221839
Returns
18231840
-------
@@ -1838,7 +1855,8 @@ def _intersections_side(self, position: float, axis: Axis, transpose: bool = Fal
18381855
axis : int
18391856
Integer index into 'xyz' (0,1,2).
18401857
transpose : bool = False
1841-
Optional: Swap the coordinates in the perpendicular plane before calculating intersections.
1858+
Optional: Swap the coordinates in the perpendicular plane before calculating
1859+
intersections. (This overrides the default lexicographic axis order.)
18421860
18431861
Returns
18441862
-------
@@ -1866,11 +1884,7 @@ def _order_axis(self, axis: int) -> int:
18661884
return axis_index[axis]
18671885

18681886
def _order_by_axis(
1869-
self,
1870-
plane_val: Any,
1871-
axis_val: Any,
1872-
axis: int,
1873-
transpose: bool = False
1887+
self, plane_val: Any, axis_val: Any, axis: int, transpose: bool = False
18741888
) -> tuple[Any, Any]:
18751889
"""Orders a value in the plane and value along axis in correct (x,y) order for plotting.
18761890
Note: sometimes if axis=1 and we compute cross section values orthogonal to axis,
@@ -1886,7 +1900,7 @@ def _order_by_axis(
18861900
axis : int
18871901
Integer index into the structure's planar axis.
18881902
transpose : bool
1889-
Optional: Swap the order of the remaining two axes (the ones not equal to axis)
1903+
Optional: Swap the order for the remaining two axes (the axes not equal to axis).
18901904
18911905
Returns
18921906
-------
@@ -2160,9 +2174,9 @@ def _do_intersections_tilted_plane(
21602174
return path.polygons_full
21612175

21622176
def intersections_plane(
2163-
self,
2164-
x: Optional[float] = None,
2165-
y: Optional[float] = None,
2177+
self,
2178+
x: Optional[float] = None,
2179+
y: Optional[float] = None,
21662180
z: Optional[float] = None,
21672181
transpose: bool = False,
21682182
):
@@ -2178,6 +2192,7 @@ def intersections_plane(
21782192
Position of plane in z direction, only one of x,y,z can be specified to define plane.
21792193
transpose : bool = False
21802194
Optional: Swap the coordinates in the plane before calculating intersections.
2195+
(This overrides the default lexicographic axis order.)
21812196
21822197
Returns
21832198
-------
@@ -2265,7 +2280,10 @@ def intersections_with(self, other, transpose: bool = False):
22652280
shapes_plane = other.intersections_plane(**xyz_kwargs, transpose=transpose)
22662281

22672282
# 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)
2283+
bs_min, bs_max = (
2284+
self.pop_axis_and_swap(bounds, axis=normal_ind, transpose=transpose)[1]
2285+
for bounds in self.bounds
2286+
)
22692287

22702288
shapely_box = self.make_shapely_box(bs_min[0], bs_min[1], bs_max[0], bs_max[1])
22712289
shapely_box = Geometry.evaluate_inf_shape(shapely_box)
@@ -2360,7 +2378,8 @@ def _plot_arrow(
23602378
arrow_base : :class:`.Coordinate` = None
23612379
Custom base of the arrow. Uses the geometry's center if not provided.
23622380
transpose : bool = False
2363-
Swap horizontal and vertical axes. (This overrides the default lexicographic axis order.)
2381+
Swap horizontal and vertical axes.
2382+
(This overrides the default lexicographic axis order.)
23642383
23652384
Returns
23662385
-------
@@ -2373,7 +2392,9 @@ def _plot_arrow(
23732392

23742393
# conditions to check to determine whether to plot arrow, taking into account the
23752394
# possibility of a custom arrow base
2376-
arrow_intersecting_plane = len(self.intersections_plane(x=x, y=y, z=z, transpose=transpose)) > 0
2395+
arrow_intersecting_plane = (
2396+
len(self.intersections_plane(x=x, y=y, z=z, transpose=transpose)) > 0
2397+
)
23772398
center = self.center
23782399
if arrow_base:
23792400
arrow_intersecting_plane = arrow_intersecting_plane and any(
@@ -3086,6 +3107,7 @@ def intersections_plane(
30863107
Position of plane in z direction, only one of x,y,z can be specified to define plane.
30873108
transpose : bool = False
30883109
Optional: Swap the coordinates in the plane before calculating intersections.
3110+
(This overrides the default lexicographic axis order.)
30893111
30903112
Returns
30913113
-------
@@ -3300,6 +3322,7 @@ def intersections_plane(
33003322
Position of plane in z direction, only one of x,y,z can be specified to define plane.
33013323
transpose : bool = False
33023324
Optional: Swap the coordinates in the plane before calculating intersections.
3325+
(This overrides the default lexicographic axis order.)
33033326
33043327
Returns
33053328
-------

0 commit comments

Comments
 (0)