87
87
_ , AX = plt .subplots ()
88
88
89
89
90
- @pytest .mark .parametrize ("component" , GEO_TYPES )
91
- def test_plot (component ):
92
- _ = component .plot (z = 0 , ax = AX )
90
+ @pytest .mark .parametrize ("component, transpose " , zip ( GEO_TYPES , [ True , False ]) )
91
+ def test_plot (component , transpose ):
92
+ _ = component .plot (z = 0 , ax = AX , transpose = transpose )
93
93
plt .close ()
94
94
95
95
96
- def test_plot_with_units ():
97
- _ = BOX .plot (z = 0 , ax = AX , plot_length_units = "nm" )
96
+ @pytest .mark .parametrize ("transpose" , [True , False ])
97
+ def test_plot_with_units (transpose ):
98
+ _ = BOX .plot (z = 0 , ax = AX , plot_length_units = "nm" , transpose = transpose )
98
99
plt .close ()
99
100
100
101
@@ -206,11 +207,11 @@ def test_array_to_vertices():
206
207
assert np .all (np .array (vertices ) == np .array (vertices2 ))
207
208
208
209
209
- @pytest .mark .parametrize ("component" , GEO_TYPES )
210
- def test_intersections_plane (component ):
211
- assert len (component .intersections_plane (z = 0.2 )) > 0
212
- assert len (component .intersections_plane (x = 0.2 )) > 0
213
- assert len (component .intersections_plane (x = 10000 )) == 0
210
+ @pytest .mark .parametrize ("component, transpose " , zip ( GEO_TYPES , [ True , False ]) )
211
+ def test_intersections_plane (component , transpose ):
212
+ assert len (component .intersections_plane (z = 0.2 , transpose = transpose )) > 0
213
+ assert len (component .intersections_plane (x = 0.2 , transpose = transpose )) > 0
214
+ assert len (component .intersections_plane (x = 10000 , transpose = transpose )) == 0
214
215
215
216
216
217
def test_intersections_plane_inf ():
@@ -768,36 +769,36 @@ def test_geometry_touching_intersections_plane(x0):
768
769
769
770
770
771
def test_pop_axis ():
771
- b = td .Box (size = (1 , 1 , 1 ))
772
772
for axis in range (3 ):
773
773
coords = (1 , 2 , 3 )
774
- Lz , (Lx , Ly ) = b .pop_axis (coords , axis = axis )
775
- _coords = b .unpop_axis (Lz , (Lx , Ly ), axis = axis )
774
+ Lz , (Lx , Ly ) = td . Box .pop_axis (coords , axis = axis )
775
+ _coords = td . Box .unpop_axis (Lz , (Lx , Ly ), axis = axis )
776
776
assert all (c == _c for (c , _c ) in zip (coords , _coords ))
777
- _Lz , (_Lx , _Ly ) = b .pop_axis (_coords , axis = axis )
777
+ _Lz , (_Lx , _Ly ) = td . Box .pop_axis (_coords , axis = axis )
778
778
assert Lz == _Lz
779
779
assert Lx == _Lx
780
780
assert Ly == _Ly
781
781
782
782
783
- def test_2b_box_intersections ():
783
+ @pytest .mark .parametrize ("transpose" , [True , False ])
784
+ def test_2b_box_intersections (transpose ):
784
785
plane = td .Box (size = (1 , 4 , 0 ))
785
786
box1 = td .Box (size = (1 , 1 , 1 ))
786
787
box2 = td .Box (size = (1 , 1 , 1 ), center = (3 , 0 , 0 ))
787
788
788
- result = plane .intersections_with (box1 )
789
+ result = plane .intersections_with (box1 , transpose = transpose )
789
790
assert len (result ) == 1
790
791
assert result [0 ].geom_type == "Polygon"
791
- assert len (plane .intersections_with (box2 )) == 0
792
+ assert len (plane .intersections_with (box2 , transpose = transpose )) == 0
792
793
793
794
with pytest .raises (ValidationError ):
794
- _ = box1 .intersections_with (box2 )
795
+ _ = box1 .intersections_with (box2 , transpose = transpose )
795
796
796
- assert len (box1 .intersections_2dbox (plane )) == 1
797
- assert len (box2 .intersections_2dbox (plane )) == 0
797
+ assert len (box1 .intersections_2dbox (plane , transpose = transpose )) == 1
798
+ assert len (box2 .intersections_2dbox (plane , transpose = transpose )) == 0
798
799
799
800
with pytest .raises (ValidationError ):
800
- _ = box2 .intersections_2dbox (box1 )
801
+ _ = box2 .intersections_2dbox (box1 , transpose = transpose )
801
802
802
803
803
804
def test_polyslab_merge ():
@@ -939,7 +940,8 @@ def test_to_gds(geometry, tmp_path):
939
940
assert len (cell .polygons ) == 0
940
941
941
942
942
- def test_custom_surface_geometry (tmp_path ):
943
+ @pytest .mark .parametrize ("transpose" , [True , False ])
944
+ def test_custom_surface_geometry (transpose , tmp_path ):
943
945
# create tetrahedron STL
944
946
vertices = np .array ([[0 , 0 , 0 ], [1 , 0 , 0 ], [0 , 1 , 0 ], [0 , 0 , 1 ]])
945
947
faces = np .array ([[1 , 2 , 3 ], [0 , 3 , 2 ], [0 , 1 , 3 ], [0 , 2 , 1 ]])
@@ -972,9 +974,13 @@ def test_custom_surface_geometry(tmp_path):
972
974
assert np .isclose (geom .volume (), 1 / 6 )
973
975
974
976
# test intersections
975
- assert shapely .equals (geom .intersections_plane (x = 0 ), shapely .Polygon ([[0 , 0 ], [0 , 1 ], [1 , 0 ]]))
976
977
assert shapely .equals (
977
- geom .intersections_plane (z = 0.5 ), shapely .Polygon ([[0 , 0 ], [0 , 0.5 ], [0.5 , 0 ]])
978
+ geom .intersections_plane (x = 0 , transpose = transpose ),
979
+ shapely .Polygon ([[0 , 0 ], [0 , 1 ], [1 , 0 ]]),
980
+ )
981
+ assert shapely .equals (
982
+ geom .intersections_plane (z = 0.5 , transpose = transpose ),
983
+ shapely .Polygon ([[0 , 0 ], [0 , 0.5 ], [0.5 , 0 ]]),
978
984
)
979
985
980
986
# test inside
@@ -983,7 +989,7 @@ def test_custom_surface_geometry(tmp_path):
983
989
984
990
# test plot
985
991
_ , ax = plt .subplots ()
986
- _ = geom .plot (z = 0.1 , ax = ax )
992
+ _ = geom .plot (z = 0.1 , ax = ax , transpose = transpose )
987
993
plt .close ()
988
994
989
995
# test inconsistent winding
@@ -1033,7 +1039,7 @@ def test_custom_surface_geometry(tmp_path):
1033
1039
boundary_spec = td .BoundarySpec .all_sides (td .PML ()),
1034
1040
)
1035
1041
_ , ax = plt .subplots ()
1036
- _ = sim .plot (y = 0 , ax = ax )
1042
+ _ = sim .plot (y = 0 , ax = ax , transpose = transpose )
1037
1043
plt .close ()
1038
1044
1039
1045
# allow small triangles
0 commit comments