Skip to content

Commit a9b91b7

Browse files
committed
renamed the "swap_axes" argument --> "transpose"
1 parent a22a5d4 commit a9b91b7

24 files changed

+482
-482
lines changed

tests/test_components/test_geometry.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@
8585
_, AX = plt.subplots()
8686

8787

88-
@pytest.mark.parametrize("component, swap_axes", zip(GEO_TYPES, [True, False]))
89-
def test_plot(component, swap_axes):
90-
_ = component.plot(z=0, ax=AX, swap_axes=swap_axes)
88+
@pytest.mark.parametrize("component, transpose", zip(GEO_TYPES, [True, False]))
89+
def test_plot(component, transpose):
90+
_ = component.plot(z=0, ax=AX, transpose=transpose)
9191
plt.close()
9292

93-
@pytest.mark.parametrize("swap_axes", [True, False])
94-
def test_plot_with_units(swap_axes):
95-
_ = BOX.plot(z=0, ax=AX, plot_length_units="nm", swap_axes=swap_axes)
93+
@pytest.mark.parametrize("transpose", [True, False])
94+
def test_plot_with_units(transpose):
95+
_ = BOX.plot(z=0, ax=AX, plot_length_units="nm", transpose=transpose)
9696
plt.close()
9797

9898

@@ -204,11 +204,11 @@ def test_array_to_vertices():
204204
assert np.all(np.array(vertices) == np.array(vertices2))
205205

206206

207-
@pytest.mark.parametrize("component, swap_axes", zip(GEO_TYPES, [True, False]))
208-
def test_intersections_plane(component, swap_axes):
209-
assert len(component.intersections_plane(z=0.2, swap_axes=swap_axes)) > 0
210-
assert len(component.intersections_plane(x=0.2, swap_axes=swap_axes)) > 0
211-
assert len(component.intersections_plane(x=10000, swap_axes=swap_axes)) == 0
207+
@pytest.mark.parametrize("component, transpose", zip(GEO_TYPES, [True, False]))
208+
def test_intersections_plane(component, transpose):
209+
assert len(component.intersections_plane(z=0.2, transpose=transpose)) > 0
210+
assert len(component.intersections_plane(x=0.2, transpose=transpose)) > 0
211+
assert len(component.intersections_plane(x=10000, transpose=transpose)) == 0
212212

213213

214214
def test_intersections_plane_inf():
@@ -778,39 +778,39 @@ def test_pop_axis():
778778
assert Ly == _Ly
779779

780780

781-
@pytest.mark.parametrize("swap_axes", [True, False])
782-
def test_pop_axis_and_swap(swap_axes):
781+
@pytest.mark.parametrize("transpose", [True, False])
782+
def test_pop_axis_and_swap(transpose):
783783
b = td.Box(size=(1, 1, 1))
784784
for axis in range(3):
785785
coords = (1, 2, 3)
786-
Lz, (Lx, Ly) = b.pop_axis_and_swap(coords, axis=axis, swap_axes=swap_axes)
787-
_coords = b.unpop_axis_and_swap(Lz, (Lx, Ly), axis=axis, swap_axes=swap_axes)
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)
788788
assert all(c == _c for (c, _c) in zip(coords, _coords))
789-
_Lz, (_Lx, _Ly) = b.pop_axis_and_swap(_coords, axis=axis, swap_axes=swap_axes)
789+
_Lz, (_Lx, _Ly) = b.pop_axis_and_swap(_coords, axis=axis, transpose=transpose)
790790
assert Lz == _Lz
791791
assert Lx == _Lx
792792
assert Ly == _Ly
793793

794794

795-
@pytest.mark.parametrize("swap_axes", [True, False])
796-
def test_2b_box_intersections(swap_axes):
795+
@pytest.mark.parametrize("transpose", [True, False])
796+
def test_2b_box_intersections(transpose):
797797
plane = td.Box(size=(1, 4, 0))
798798
box1 = td.Box(size=(1, 1, 1))
799799
box2 = td.Box(size=(1, 1, 1), center=(3, 0, 0))
800800

801-
result = plane.intersections_with(box1, swap_axes=swap_axes)
801+
result = plane.intersections_with(box1, transpose=transpose)
802802
assert len(result) == 1
803803
assert result[0].geom_type == "Polygon"
804-
assert len(plane.intersections_with(box2, swap_axes=swap_axes)) == 0
804+
assert len(plane.intersections_with(box2, transpose=transpose)) == 0
805805

806806
with pytest.raises(ValidationError):
807-
_ = box1.intersections_with(box2, swap_axes=swap_axes)
807+
_ = box1.intersections_with(box2, transpose=transpose)
808808

809-
assert len(box1.intersections_2dbox(plane, swap_axes=swap_axes)) == 1
810-
assert len(box2.intersections_2dbox(plane, swap_axes=swap_axes)) == 0
809+
assert len(box1.intersections_2dbox(plane, transpose=transpose)) == 1
810+
assert len(box2.intersections_2dbox(plane, transpose=transpose)) == 0
811811

812812
with pytest.raises(ValidationError):
813-
_ = box2.intersections_2dbox(box1, swap_axes=swap_axes)
813+
_ = box2.intersections_2dbox(box1, transpose=transpose)
814814

815815

816816
def test_polyslab_merge():
@@ -952,8 +952,8 @@ def test_to_gds(geometry, tmp_path):
952952
assert len(cell.polygons) == 0
953953

954954

955-
@pytest.mark.parametrize("swap_axes", [True, False])
956-
def test_custom_surface_geometry(swap_axes, tmp_path):
955+
@pytest.mark.parametrize("transpose", [True, False])
956+
def test_custom_surface_geometry(transpose, tmp_path):
957957
# create tetrahedron STL
958958
vertices = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]])
959959
faces = np.array([[1, 2, 3], [0, 3, 2], [0, 1, 3], [0, 2, 1]])
@@ -987,11 +987,11 @@ def test_custom_surface_geometry(swap_axes, tmp_path):
987987

988988
# test intersections
989989
assert shapely.equals(
990-
geom.intersections_plane(x=0, swap_axes=swap_axes),
990+
geom.intersections_plane(x=0, transpose=transpose),
991991
shapely.Polygon([[0, 0], [0, 1], [1, 0]]),
992992
)
993993
assert shapely.equals(
994-
geom.intersections_plane(z=0.5, swap_axes=swap_axes),
994+
geom.intersections_plane(z=0.5, transpose=transpose),
995995
shapely.Polygon([[0, 0], [0, 0.5], [0.5, 0]]),
996996
)
997997

@@ -1001,7 +1001,7 @@ def test_custom_surface_geometry(swap_axes, tmp_path):
10011001

10021002
# test plot
10031003
_, ax = plt.subplots()
1004-
_ = geom.plot(z=0.1, ax=ax, swap_axes=swap_axes)
1004+
_ = geom.plot(z=0.1, ax=ax, transpose=transpose)
10051005
plt.close()
10061006

10071007
# test inconsistent winding
@@ -1051,7 +1051,7 @@ def test_custom_surface_geometry(swap_axes, tmp_path):
10511051
boundary_spec=td.BoundarySpec.all_sides(td.PML()),
10521052
)
10531053
_, ax = plt.subplots()
1054-
_ = sim.plot(y=0, ax=ax, swap_axes=swap_axes)
1054+
_ = sim.plot(y=0, ax=ax, transpose=transpose)
10551055
plt.close()
10561056

10571057
# allow small triangles

tests/test_components/test_heat.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,12 @@ def make_heat_sim(include_custom_source: bool = True):
335335
return heat_sim
336336

337337

338-
@pytest.mark.parametrize("swap_axes", [True, False])
339-
def test_heat_sim(swap_axes):
338+
@pytest.mark.parametrize("transpose", [True, False])
339+
def test_heat_sim(transpose):
340340
bc_temp, bc_flux, bc_conv = make_heat_bcs()
341341
heat_sim = make_heat_sim()
342342

343-
_ = heat_sim.plot(x=0, swap_axes=swap_axes)
343+
_ = heat_sim.plot(x=0, transpose=transpose)
344344

345345
# wrong names given
346346
for pl in [
@@ -374,14 +374,14 @@ def test_heat_sim(swap_axes):
374374
with pytest.raises(pd.ValidationError):
375375
heat_sim.updated_copy(monitors=[temp_mnt, temp_mnt])
376376

377-
_ = heat_sim.plot(x=0, swap_axes=swap_axes)
377+
_ = heat_sim.plot(x=0, transpose=transpose)
378378
plt.close()
379379

380-
_ = heat_sim.plot_heat_conductivity(y=0, swap_axes=swap_axes)
380+
_ = heat_sim.plot_heat_conductivity(y=0, transpose=transpose)
381381
plt.close()
382382

383383
heat_sim_sym = heat_sim.updated_copy(symmetry=(0, 1, 1))
384-
_ = heat_sim_sym.plot_heat_conductivity(z=0, colorbar="source", swap_axes=swap_axes)
384+
_ = heat_sim_sym.plot_heat_conductivity(z=0, colorbar="source", transpose=transpose)
385385
plt.close()
386386

387387
# no negative symmetry

tests/test_components/test_heat_charge.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,8 @@ def test_heat_charge_sources(structures):
852852
_ = td.HeatSource(structures=["solid_structure"], rate="100")
853853

854854

855-
@pytest.mark.parametrize("swap_axes", [True, False])
856-
def test_heat_charge_simulation(swap_axes, simulation_data):
855+
@pytest.mark.parametrize("transpose", [True, False])
856+
def test_heat_charge_simulation(transpose, simulation_data):
857857
"""Tests 'HeatChargeSimulation' and 'ConductionSimulation' objects."""
858858
heat_sim_data, cond_sim_data, voltage_capacitance_sim_data, current_voltage_simulation_data = (
859859
simulation_data
@@ -877,16 +877,16 @@ def test_heat_charge_simulation(swap_axes, simulation_data):
877877
"Current-Voltage simulation should be created successfully."
878878
)
879879

880-
_ = heat_sim.plot_heat_conductivity(x=0, swap_axes=swap_axes)
880+
_ = heat_sim.plot_heat_conductivity(x=0, transpose=transpose)
881881
plt.close()
882-
_ = heat_sim.plot_property(x=0, property="heat_conductivity", swap_axes=swap_axes)
882+
_ = heat_sim.plot_property(x=0, property="heat_conductivity", transpose=transpose)
883883
plt.close()
884-
_ = cond_sim.plot_property(x=0, property="electric_conductivity", swap_axes=swap_axes)
884+
_ = cond_sim.plot_property(x=0, property="electric_conductivity", transpose=transpose)
885885
plt.close()
886886
for sim in (heat_sim, cond_sim, voltage_capacitance_sim, current_voltage_sim):
887-
_ = sim.plot_boundaries(x=0, swap_axes=swap_axes)
887+
_ = sim.plot_boundaries(x=0, transpose=transpose)
888888
plt.close()
889-
_ = sim.plot_sources(x=0, swap_axes=swap_axes)
889+
_ = sim.plot_sources(x=0, transpose=transpose)
890890
plt.close()
891891

892892

@@ -1446,8 +1446,8 @@ def test_plotting_functions(simulation_data):
14461446
heat_sim_data.plot_field("test", invalid_param=0)
14471447

14481448

1449-
@pytest.mark.parametrize("swap_axes", [True, False])
1450-
def test_bandgap_monitor(swap_axes):
1449+
@pytest.mark.parametrize("transpose", [True, False])
1450+
def test_bandgap_monitor(transpose):
14511451
"""Test energy bandgap monitor ploting function."""
14521452
# create a triangle grid
14531453
tri_grid_points = td.PointDataArray(
@@ -1587,8 +1587,8 @@ def test_bandgap_monitor(swap_axes):
15871587

15881588
# test check for the voltage value in the list of arguments
15891589

1590-
tri_single_voltage_data.plot(x=0.0, swap_axes=swap_axes)
1591-
tri_multi_voltage_data.plot(x=0.0, voltage=1.0, swap_axes=swap_axes)
1590+
tri_single_voltage_data.plot(x=0.0, transpose=transpose)
1591+
tri_multi_voltage_data.plot(x=0.0, voltage=1.0, transpose=transpose)
15921592

15931593
with pytest.raises(DataError):
15941594
tri_multi_voltage_data.plot(x=0.0)

tests/test_components/test_scene.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ def test_validate_components_none():
5050
assert SCENE._validate_num_mediums(val=None) is None
5151

5252

53-
@pytest.mark.parametrize("swap_axes", [True, False])
54-
def test_plot_eps(swap_axes):
55-
ax = SCENE_FULL.plot_eps(x=0, swap_axes=swap_axes)
53+
@pytest.mark.parametrize("transpose", [True, False])
54+
def test_plot_eps(transpose):
55+
ax = SCENE_FULL.plot_eps(x=0, transpose=transpose)
5656
SCENE_FULL._add_cbar_eps(eps_min=1, eps_max=2, ax=ax)
5757
plt.close()
5858

5959

60-
@pytest.mark.parametrize("swap_axes", [True, False])
61-
def test_plot_eps_multiphysics(swap_axes):
60+
@pytest.mark.parametrize("transpose", [True, False])
61+
def test_plot_eps_multiphysics(transpose):
6262
s = td.Scene(
6363
structures=[
6464
td.Structure(
@@ -72,22 +72,22 @@ def test_plot_eps_multiphysics(swap_axes):
7272
]
7373
)
7474
assert s.structures[0].medium.name == "SiO2"
75-
s.plot_eps(x=0, swap_axes=swap_axes)
75+
s.plot_eps(x=0, transpose=transpose)
7676

7777

78-
@pytest.mark.parametrize("swap_axes", [True, False])
79-
def test_plot_eps_bounds(swap_axes):
80-
_ = SCENE_FULL.plot_eps(x=0, hlim=[-0.45, 0.45], swap_axes=swap_axes)
78+
@pytest.mark.parametrize("transpose", [True, False])
79+
def test_plot_eps_bounds(transpose):
80+
_ = SCENE_FULL.plot_eps(x=0, hlim=[-0.45, 0.45], transpose=transpose)
8181
plt.close()
82-
_ = SCENE_FULL.plot_eps(x=0, vlim=[-0.45, 0.45], swap_axes=swap_axes)
82+
_ = SCENE_FULL.plot_eps(x=0, vlim=[-0.45, 0.45], transpose=transpose)
8383
plt.close()
84-
_ = SCENE_FULL.plot_eps(x=0, hlim=[-0.45, 0.45], vlim=[-0.45, 0.45], swap_axes=swap_axes)
84+
_ = SCENE_FULL.plot_eps(x=0, hlim=[-0.45, 0.45], vlim=[-0.45, 0.45], transpose=transpose)
8585
plt.close()
8686

8787

88-
@pytest.mark.parametrize("swap_axes", [True, False])
89-
def test_plot(swap_axes):
90-
SCENE_FULL.plot(x=0, swap_axes=swap_axes)
88+
@pytest.mark.parametrize("transpose", [True, False])
89+
def test_plot(transpose):
90+
SCENE_FULL.plot(x=0, transpose=transpose)
9191
plt.close()
9292

9393

@@ -97,48 +97,48 @@ def test_plot_1d_scene():
9797
plt.close()
9898

9999

100-
@pytest.mark.parametrize("swap_axes", [True, False])
101-
def test_plot_bounds(swap_axes):
102-
_ = SCENE_FULL.plot(x=0, hlim=[-0.45, 0.45], swap_axes=swap_axes)
100+
@pytest.mark.parametrize("transpose", [True, False])
101+
def test_plot_bounds(transpose):
102+
_ = SCENE_FULL.plot(x=0, hlim=[-0.45, 0.45], transpose=transpose)
103103
plt.close()
104-
_ = SCENE_FULL.plot(x=0, vlim=[-0.45, 0.45], swap_axes=swap_axes)
104+
_ = SCENE_FULL.plot(x=0, vlim=[-0.45, 0.45], transpose=transpose)
105105
plt.close()
106-
_ = SCENE_FULL.plot(x=0, hlim=[-0.45, 0.45], vlim=[-0.45, 0.45], swap_axes=swap_axes)
106+
_ = SCENE_FULL.plot(x=0, hlim=[-0.45, 0.45], vlim=[-0.45, 0.45], transpose=transpose)
107107
plt.close()
108108

109109

110-
@pytest.mark.parametrize("swap_axes", [True, False])
111-
def test_structure_alpha(swap_axes):
112-
_ = SCENE_FULL.plot_structures_eps(x=0, alpha=None, swap_axes=swap_axes)
110+
@pytest.mark.parametrize("transpose", [True, False])
111+
def test_structure_alpha(transpose):
112+
_ = SCENE_FULL.plot_structures_eps(x=0, alpha=None, transpose=transpose)
113113
plt.close()
114-
_ = SCENE_FULL.plot_structures_eps(x=0, alpha=-1, swap_axes=swap_axes)
114+
_ = SCENE_FULL.plot_structures_eps(x=0, alpha=-1, transpose=transpose)
115115
plt.close()
116-
_ = SCENE_FULL.plot_structures_eps(x=0, alpha=1, swap_axes=swap_axes)
116+
_ = SCENE_FULL.plot_structures_eps(x=0, alpha=1, transpose=transpose)
117117
plt.close()
118-
_ = SCENE_FULL.plot_structures_eps(x=0, alpha=0.5, swap_axes=swap_axes)
118+
_ = SCENE_FULL.plot_structures_eps(x=0, alpha=0.5, transpose=transpose)
119119
plt.close()
120-
_ = SCENE_FULL.plot_structures_eps(x=0, alpha=0.5, cbar=True, swap_axes=swap_axes)
120+
_ = SCENE_FULL.plot_structures_eps(x=0, alpha=0.5, cbar=True, transpose=transpose)
121121
plt.close()
122122
new_structs = [
123123
td.Structure(geometry=s.geometry, medium=SCENE_FULL.medium) for s in SCENE_FULL.structures
124124
]
125125
S2 = SCENE_FULL.copy(update={"structures": new_structs})
126-
_ = S2.plot_structures_eps(x=0, alpha=0.5, swap_axes=swap_axes)
126+
_ = S2.plot_structures_eps(x=0, alpha=0.5, transpose=transpose)
127127
plt.close()
128128

129129

130-
@pytest.mark.parametrize("swap_axes", [True, False])
131-
def test_plot_with_units(swap_axes):
130+
@pytest.mark.parametrize("transpose", [True, False])
131+
def test_plot_with_units(transpose):
132132
scene_with_units = SCENE_FULL.updated_copy(plot_length_units="nm")
133-
scene_with_units.plot(x=-0.5, swap_axes=swap_axes)
133+
scene_with_units.plot(x=-0.5, transpose=transpose)
134134

135135

136-
@pytest.mark.parametrize("swap_axes", [True, False])
137-
def test_filter_structures(swap_axes):
136+
@pytest.mark.parametrize("transpose", [True, False])
137+
def test_filter_structures(transpose):
138138
s1 = td.Structure(geometry=td.Box(size=(1, 1, 1)), medium=SCENE.medium)
139139
s2 = td.Structure(geometry=td.Box(size=(1, 1, 1), center=(1, 1, 1)), medium=SCENE.medium)
140140
plane = td.Box(center=(0, 0, 1.5), size=(td.inf, td.inf, 0))
141-
SCENE._filter_structures_plane_medium(structures=[s1, s2], plane=plane, swap_axes=swap_axes)
141+
SCENE._filter_structures_plane_medium(structures=[s1, s2], plane=plane, transpose=transpose)
142142

143143

144144
def test_get_structure_plot_params():

0 commit comments

Comments
 (0)