Skip to content

Commit 3e32d3d

Browse files
committed
ran pre-commit run --all-files
1 parent aca545e commit 3e32d3d

File tree

11 files changed

+99
-95
lines changed

11 files changed

+99
-95
lines changed

tests/test_components/test_IO.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@ def test_simulation_load_export(split_string, tmp_path):
7373
SIM.to_hdf5(path_hdf5)
7474
SIM2 = td.Simulation.from_file(path)
7575
SIM_HDF5 = td.Simulation.from_hdf5(path_hdf5)
76-
assert (
77-
set_datasets_to_none(SIM)._json_string == SIM2._json_string
78-
), "original and loaded simulations are not the same"
76+
assert set_datasets_to_none(SIM)._json_string == SIM2._json_string, (
77+
"original and loaded simulations are not the same"
78+
)
7979
assert SIM == SIM_HDF5, "original and loaded from hdf5 simulations are not the same"
8080

8181

8282
def test_simulation_load_export_yaml(tmp_path):
8383
path = str(tmp_path / "simulation.yaml")
8484
SIM.to_file(path)
8585
SIM2 = td.Simulation.from_file(path)
86-
assert (
87-
set_datasets_to_none(SIM)._json_string == SIM2._json_string
88-
), "original and loaded simulations are not the same"
86+
assert set_datasets_to_none(SIM)._json_string == SIM2._json_string, (
87+
"original and loaded simulations are not the same"
88+
)
8989

9090

9191
def test_component_load_export(tmp_path):

tests/test_components/test_autograd.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,18 +1247,18 @@ def test_adjoint_src_width():
12471247
adj_srcs_fwidth = td.SimulationData._adjoint_src_width_single(adj_srcs)
12481248

12491249
for src in adj_srcs_fwidth:
1250-
assert np.isclose(
1251-
(src.source_time.freq0 - f0) / f0, 0.0
1252-
), "f0 of adjoint source should be centered on original f0"
1250+
assert np.isclose((src.source_time.freq0 - f0) / f0, 0.0), (
1251+
"f0 of adjoint source should be centered on original f0"
1252+
)
12531253

12541254
check_fwidth = (
12551255
src.source_time.freq0
12561256
- td.components.data.sim_data.NUM_ADJOINT_FWIDTH_TO_ZERO * src.source_time.fwidth
12571257
) / src.source_time.freq0
12581258

1259-
assert np.isclose(check_fwidth, 0.0) or (
1260-
check_fwidth > 0.0
1261-
), "fwidth of adjoint source should decay sufficiently before f=0"
1259+
assert np.isclose(check_fwidth, 0.0) or (check_fwidth > 0.0), (
1260+
"fwidth of adjoint source should decay sufficiently before f=0"
1261+
)
12621262

12631263

12641264
def test_broadband_adjoint_src_width():
@@ -1305,12 +1305,12 @@ def test_broadband_adjoint_src_width():
13051305
f0_expected - np.min(f0_adj_all)
13061306
) / td.components.data.sim_data.NUM_ADJOINT_FWIDTH_TO_FMIN
13071307

1308-
assert np.isclose(
1309-
(f0_expected - broadband_f0) / f0_expected, 0.0
1310-
), "Expected freq0 not matching for broadband source"
1311-
assert np.isclose(
1312-
(fwidth_expected - broadband_fwidth) / fwidth_expected, 0.0
1313-
), "Expected fwidth not matching for broadband source"
1308+
assert np.isclose((f0_expected - broadband_f0) / f0_expected, 0.0), (
1309+
"Expected freq0 not matching for broadband source"
1310+
)
1311+
assert np.isclose((fwidth_expected - broadband_fwidth) / fwidth_expected, 0.0), (
1312+
"Expected fwidth not matching for broadband source"
1313+
)
13141314

13151315
# Test the case where we need a wider pulse to cover all the adjoint frequencies than we would otherwise choose for
13161316
# each individual adjoint source
@@ -1333,12 +1333,12 @@ def test_broadband_adjoint_src_width():
13331333
f0_expected - np.min(f0_broadband)
13341334
) / td.components.data.sim_data.NUM_ADJOINT_FWIDTH_TO_FMIN
13351335

1336-
assert np.isclose(
1337-
(f0_expected - broadband_f0) / f0_expected, 0.0
1338-
), "Expected freq0 not matching for broadband source"
1339-
assert np.isclose(
1340-
(fwidth_expected - broadband_fwidth) / fwidth_expected, 0.0
1341-
), "Expected fwidth not matching for broadband source"
1336+
assert np.isclose((f0_expected - broadband_f0) / f0_expected, 0.0), (
1337+
"Expected freq0 not matching for broadband source"
1338+
)
1339+
assert np.isclose((fwidth_expected - broadband_fwidth) / fwidth_expected, 0.0), (
1340+
"Expected fwidth not matching for broadband source"
1341+
)
13421342

13431343
# Test the case where we have a narrow set of frequencies for the adjoint sources and so we can
13441344
# choose a wider overall source than is needed for covering those frequencies. This larger pulse width
@@ -1360,12 +1360,12 @@ def test_broadband_adjoint_src_width():
13601360
f0_expected = 0.5 * (np.max(f0_broadband) + np.min(f0_broadband))
13611361
fwidth_expected = f0_expected / td.components.data.sim_data.NUM_ADJOINT_FWIDTH_TO_ZERO
13621362

1363-
assert np.isclose(
1364-
(f0_expected - broadband_f0) / f0_expected, 0.0
1365-
), "Expected freq0 not matching for broadband source"
1366-
assert np.isclose(
1367-
(fwidth_expected - broadband_fwidth) / fwidth_expected, 0.0
1368-
), "Expected fwidth not matching for broadband source"
1363+
assert np.isclose((f0_expected - broadband_f0) / f0_expected, 0.0), (
1364+
"Expected freq0 not matching for broadband source"
1365+
)
1366+
assert np.isclose((fwidth_expected - broadband_fwidth) / fwidth_expected, 0.0), (
1367+
"Expected fwidth not matching for broadband source"
1368+
)
13691369

13701370

13711371
@pytest.mark.parametrize("colocate", [True, False])

tests/test_components/test_autograd_mode_polyslab_numerical.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,7 @@ def test_finite_difference_mode_data_polyslab(
332332
"geometry_size_wvl",
333333
"polyslab_permittivity",
334334
"test_number",
335-
)(
336-
mode_data_test_parameters
337-
)
335+
)(mode_data_test_parameters)
338336

339337
adj_freq = td.C_0 / adj_wvl_um
340338

@@ -374,7 +372,11 @@ def eval_fn(sim_data):
374372
polyslab_height_um = POLYSLAB_HEIGHT_WVL * adj_wvl_um
375373

376374
objective = create_objective_function(
377-
lambda mesh_wvl_um=mesh_wvl_um, adj_wvl_um=adj_wvl_um, geometry_size_wvl=geometry_size_wvl, polyslab_permittivity=polyslab_permittivity, box_for_override=box_for_override: make_base_sim(
375+
lambda mesh_wvl_um=mesh_wvl_um,
376+
adj_wvl_um=adj_wvl_um,
377+
geometry_size_wvl=geometry_size_wvl,
378+
polyslab_permittivity=polyslab_permittivity,
379+
box_for_override=box_for_override: make_base_sim(
378380
mesh_wvl_um=mesh_wvl_um,
379381
adj_wvl_um=adj_wvl_um,
380382
geometry_size_wvl=geometry_size_wvl,

tests/test_components/test_autograd_numerical.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,7 @@ def test_finite_difference_field_data(field_data_test_parameters, rng, tmp_path,
256256
"eval_fn",
257257
"eval_fn_name",
258258
"test_number",
259-
)(
260-
field_data_test_parameters
261-
)
259+
)(field_data_test_parameters)
262260

263261
dim_um = mesh_wvl_um
264262
dim_um = mesh_wvl_um
@@ -281,7 +279,11 @@ def test_finite_difference_field_data(field_data_test_parameters, rng, tmp_path,
281279

282280
objective = create_objective_function(
283281
block,
284-
lambda mesh_wvl_um=mesh_wvl_um, adj_wvl_um=adj_wvl_um, monitor_size_wvl=monitor_size_wvl, box_for_override=box_for_override, monitor_bg_index=monitor_bg_index: make_base_sim(
282+
lambda mesh_wvl_um=mesh_wvl_um,
283+
adj_wvl_um=adj_wvl_um,
284+
monitor_size_wvl=monitor_size_wvl,
285+
box_for_override=box_for_override,
286+
monitor_bg_index=monitor_bg_index: make_base_sim(
285287
mesh_wvl_um=mesh_wvl_um,
286288
adj_wvl_um=adj_wvl_um,
287289
monitor_size_wvl=monitor_size_wvl,

tests/test_components/test_geometry.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,15 @@ def test_polyslab_inf_to_finite_bounds(axis):
330330
vertices=[[0, 0], [2.5, 1], [2, 3], [0.5, 4], [-1.5, 2.5]],
331331
)
332332

333-
assert ps_low_inf.finite_length_axis == (
334-
LARGE_NUMBER + axis_bound
335-
), "Unexpected finite length for polyslab axis with -inf bound"
336-
assert ps_high_inf.finite_length_axis == (
337-
LARGE_NUMBER + axis_bound
338-
), "Unexpected finite length for polyslab axis with inf bound"
339-
assert (
340-
ps_inf.finite_length_axis == 2 * LARGE_NUMBER
341-
), "Unexpected finite length for polyslab axis with two inf bounds"
333+
assert ps_low_inf.finite_length_axis == (LARGE_NUMBER + axis_bound), (
334+
"Unexpected finite length for polyslab axis with -inf bound"
335+
)
336+
assert ps_high_inf.finite_length_axis == (LARGE_NUMBER + axis_bound), (
337+
"Unexpected finite length for polyslab axis with inf bound"
338+
)
339+
assert ps_inf.finite_length_axis == 2 * LARGE_NUMBER, (
340+
"Unexpected finite length for polyslab axis with two inf bounds"
341+
)
342342

343343

344344
def test_validate_polyslab_vertices_valid():

tests/test_components/test_heat_charge.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -868,14 +868,14 @@ def test_heat_charge_simulation(transpose, simulation_data):
868868
assert cond_sim is not None, "Conduction simulation should be created successfully."
869869

870870
voltage_capacitance_sim = voltage_capacitance_sim_data.simulation
871-
assert (
872-
voltage_capacitance_sim is not None
873-
), "Voltage-Capacitance simulation should be created successfully."
871+
assert voltage_capacitance_sim is not None, (
872+
"Voltage-Capacitance simulation should be created successfully."
873+
)
874874

875875
current_voltage_sim = current_voltage_simulation_data.simulation
876-
assert (
877-
current_voltage_sim is not None
878-
), "Current-Voltage simulation should be created successfully."
876+
assert current_voltage_sim is not None, (
877+
"Current-Voltage simulation should be created successfully."
878+
)
879879

880880
_ = heat_sim.plot_heat_conductivity(x=0, transpose=transpose)
881881
plt.close()

tests/test_components/test_meshgenerate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,9 @@ def test_override_are_box():
818818
dl=[1, 2, 3],
819819
)
820820

821-
assert isinstance(
822-
override_not_box.geometry, td.Box
823-
), "Sphere override structure was not converted to Box"
821+
assert isinstance(override_not_box.geometry, td.Box), (
822+
"Sphere override structure was not converted to Box"
823+
)
824824

825825

826826
def test_override_unshadowed():

tests/test_material_library/test_material_library.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,20 @@ def test_medium_repr():
7171
repr_noname_medium = test_media[0].__repr__()
7272
str_noname_medium_dict = str(noname_medium_in_dict)
7373

74-
assert (
75-
"type='Medium' permittivity=2.25 conductivity=0.0" in str_noname_medium
76-
), "Expected medium information in string"
77-
assert (
78-
"Medium(attrs={}, name=None, frequency_range=None" in repr_noname_medium
79-
), "Expcted medium information in repr"
74+
assert "type='Medium' permittivity=2.25 conductivity=0.0" in str_noname_medium, (
75+
"Expected medium information in string"
76+
)
77+
assert "Medium(attrs={}, name=None, frequency_range=None" in repr_noname_medium, (
78+
"Expcted medium information in repr"
79+
)
8080
assert repr_noname_medium in str_noname_medium_dict, "Expected repr in dictionary string"
8181

8282
for medium in test_media:
8383
repr_str = medium.__repr__()
8484

85-
assert (
86-
test_media[1].__repr__() == material_name
87-
), "Expected repr to return just the material name."
85+
assert test_media[1].__repr__() == material_name, (
86+
"Expected repr to return just the material name."
87+
)
8888

8989

9090
def test_variant_str():
@@ -97,16 +97,16 @@ def test_variant_str():
9797

9898
printed_SiO2_Palik_lossless = str(td.material_library["SiO2"].variants["Palik_Lossless"])
9999

100-
assert (
101-
"eps_inf: 1.5385442336875639" in printed_SiO2_Palik_lossless
102-
), "Expected eps_inf in SiO2 printed string"
100+
assert "eps_inf: 1.5385442336875639" in printed_SiO2_Palik_lossless, (
101+
"Expected eps_inf in SiO2 printed string"
102+
)
103103
assert "poles: 2" in printed_SiO2_Palik_lossless, "Expected 1 pole in SiO2 printed string"
104104

105105
printed_SiO2_Palik_lossy = str(td.material_library["SiO2"].variants["Palik_Lossy"])
106106

107-
assert (
108-
"eps_inf: 2.1560362571240765" in printed_SiO2_Palik_lossy
109-
), "Expected eps_inf in SiO2 printed string"
107+
assert "eps_inf: 2.1560362571240765" in printed_SiO2_Palik_lossy, (
108+
"Expected eps_inf in SiO2 printed string"
109+
)
110110
assert "poles: 5" in printed_SiO2_Palik_lossy, "Expected 1 pole in SiO2 printed string"
111111

112112

@@ -115,9 +115,9 @@ def test_material_str():
115115

116116
printed_Ag = str(td.material_library["Ag"])
117117

118-
assert (
119-
"Default Variant: Rakic1998BB" in printed_Ag
120-
), "Expected default variant in printed string"
118+
assert "Default Variant: Rakic1998BB" in printed_Ag, (
119+
"Expected default variant in printed string"
120+
)
121121
assert "RakicLorentzDrude1998" in printed_Ag, "Expected variant in printed string"
122122

123123
printed_Au = str(td.material_library["Au"])

tests/test_plugins/smatrix/test_component_modeler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,12 @@ def test_run_component_modeler(monkeypatch):
281281
coords_in = {"port_in": port_in.name, "mode_index_in": mode_index_in}
282282
coords_out = {"port_out": port_out.name, "mode_index_out": mode_index_out}
283283

284-
assert np.all(
285-
s_matrix.sel(**coords_in) != 0
286-
), "source index not present in S matrix"
287-
assert np.all(
288-
s_matrix.sel(**coords_in).sel(**coords_out) != 0
289-
), "monitor index not present in S matrix"
284+
assert np.all(s_matrix.sel(**coords_in) != 0), (
285+
"source index not present in S matrix"
286+
)
287+
assert np.all(s_matrix.sel(**coords_in).sel(**coords_out) != 0), (
288+
"monitor index not present in S matrix"
289+
)
290290

291291

292292
def test_component_modeler_run_only(monkeypatch):

tests/test_plugins/smatrix/test_terminal_component_modeler.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ def test_run_component_modeler(monkeypatch, tmp_path):
144144
coords_out = {"port_out": port_out.name}
145145

146146
assert np.all(s_matrix.sel(**coords_in) != 0), "source index not present in S matrix"
147-
assert np.all(
148-
s_matrix.sel(**coords_in).sel(**coords_out) != 0
149-
), "monitor index not present in S matrix"
147+
assert np.all(s_matrix.sel(**coords_in).sel(**coords_out) != 0), (
148+
"monitor index not present in S matrix"
149+
)
150150

151151

152152
def test_s_to_z_component_modeler():
@@ -280,9 +280,9 @@ def test_run_coaxial_component_modeler(monkeypatch, tmp_path):
280280
coords_out = {"port_out": port_out.name}
281281

282282
assert np.all(s_matrix.sel(**coords_in) != 0), "source index not present in S matrix"
283-
assert np.all(
284-
s_matrix.sel(**coords_in).sel(**coords_out) != 0
285-
), "monitor index not present in S matrix"
283+
assert np.all(s_matrix.sel(**coords_in).sel(**coords_out) != 0), (
284+
"monitor index not present in S matrix"
285+
)
286286

287287

288288
def test_coarse_grid_at_coaxial_port(monkeypatch, tmp_path):
@@ -458,9 +458,9 @@ def test_run_coaxial_component_modeler_with_wave_ports(
458458
coords_in = {"port_in": port_in.name}
459459
coords_out = {"port_out": port_out.name}
460460

461-
assert np.all(
462-
s_matrix.sel(**coords_in).values.shape == shape_one_port
463-
), "source index not present in S matrix"
461+
assert np.all(s_matrix.sel(**coords_in).values.shape == shape_one_port), (
462+
"source index not present in S matrix"
463+
)
464464
assert np.all(
465465
s_matrix.sel(**coords_in).sel(**coords_out).values.shape == shape_both_ports
466466
), "monitor index not present in S matrix"
@@ -483,9 +483,9 @@ def test_run_mixed_component_modeler_with_wave_ports(monkeypatch, tmp_path):
483483
coords_in = {"port_in": port_in.name}
484484
coords_out = {"port_out": port_out.name}
485485

486-
assert np.all(
487-
s_matrix.sel(**coords_in).values.shape == shape_one_port
488-
), "source index not present in S matrix"
486+
assert np.all(s_matrix.sel(**coords_in).values.shape == shape_one_port), (
487+
"source index not present in S matrix"
488+
)
489489
assert np.all(
490490
s_matrix.sel(**coords_in).sel(**coords_out).values.shape == shape_both_ports
491491
), "monitor index not present in S matrix"

0 commit comments

Comments
 (0)