Skip to content

Commit 5aff2b2

Browse files
committed
reformatted using black . --line-length 100
1 parent 1ff3556 commit 5aff2b2

31 files changed

+507
-214
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 set_datasets_to_none(SIM)._json_string == SIM2._json_string, (
77-
"original and loaded simulations are not the same"
78-
)
76+
assert (
77+
set_datasets_to_none(SIM)._json_string == SIM2._json_string
78+
), "original and loaded simulations are not the same"
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 set_datasets_to_none(SIM)._json_string == SIM2._json_string, (
87-
"original and loaded simulations are not the same"
88-
)
86+
assert (
87+
set_datasets_to_none(SIM)._json_string == SIM2._json_string
88+
), "original and loaded simulations are not the same"
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((src.source_time.freq0 - f0) / f0, 0.0), (
1251-
"f0 of adjoint source should be centered on original f0"
1252-
)
1250+
assert np.isclose(
1251+
(src.source_time.freq0 - f0) / f0, 0.0
1252+
), "f0 of adjoint source should be centered on original f0"
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 (check_fwidth > 0.0), (
1260-
"fwidth of adjoint source should decay sufficiently before f=0"
1261-
)
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"
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((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-
)
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"
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((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-
)
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"
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((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-
)
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"
13691369

13701370

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

tests/test_components/test_autograd_mode_polyslab_numerical.py

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

337339
adj_freq = td.C_0 / adj_wvl_um
338340

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

374376
objective = create_objective_function(
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(
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(
380378
mesh_wvl_um=mesh_wvl_um,
381379
adj_wvl_um=adj_wvl_um,
382380
geometry_size_wvl=geometry_size_wvl,

tests/test_components/test_autograd_numerical.py

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

261263
dim_um = mesh_wvl_um
262264
dim_um = mesh_wvl_um
@@ -279,11 +281,7 @@ def test_finite_difference_field_data(field_data_test_parameters, rng, tmp_path,
279281

280282
objective = create_objective_function(
281283
block,
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(
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(
287285
mesh_wvl_um=mesh_wvl_um,
288286
adj_wvl_um=adj_wvl_um,
289287
monitor_size_wvl=monitor_size_wvl,

tests/test_components/test_eme.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ def test_eme_monitor():
282282
center=(1, 2, 3), size=(2, 2, 2), freqs=[300e12], num_modes=2, name="eme_coeffs"
283283
)
284284

285+
285286
@pytest.mark.parametrize("transpose", [True, False])
286287
def test_eme_simulation(transpose):
287288
sim = make_eme_sim()

tests/test_components/test_geometry.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def test_plot(component, transpose):
9090
_ = component.plot(z=0, ax=AX, transpose=transpose)
9191
plt.close()
9292

93+
9394
@pytest.mark.parametrize("transpose", [True, False])
9495
def test_plot_with_units(transpose):
9596
_ = BOX.plot(z=0, ax=AX, plot_length_units="nm", transpose=transpose)
@@ -329,15 +330,15 @@ def test_polyslab_inf_to_finite_bounds(axis):
329330
vertices=[[0, 0], [2.5, 1], [2, 3], [0.5, 4], [-1.5, 2.5]],
330331
)
331332

332-
assert ps_low_inf.finite_length_axis == (LARGE_NUMBER + axis_bound), (
333-
"Unexpected finite length for polyslab axis with -inf bound"
334-
)
335-
assert ps_high_inf.finite_length_axis == (LARGE_NUMBER + axis_bound), (
336-
"Unexpected finite length for polyslab axis with inf bound"
337-
)
338-
assert ps_inf.finite_length_axis == 2 * LARGE_NUMBER, (
339-
"Unexpected finite length for polyslab axis with two inf bounds"
340-
)
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"
341342

342343

343344
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 voltage_capacitance_sim is not None, (
872-
"Voltage-Capacitance simulation should be created successfully."
873-
)
871+
assert (
872+
voltage_capacitance_sim is not None
873+
), "Voltage-Capacitance simulation should be created successfully."
874874

875875
current_voltage_sim = current_voltage_simulation_data.simulation
876-
assert current_voltage_sim is not None, (
877-
"Current-Voltage simulation should be created successfully."
878-
)
876+
assert (
877+
current_voltage_sim is not None
878+
), "Current-Voltage simulation should be created successfully."
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(override_not_box.geometry, td.Box), (
822-
"Sphere override structure was not converted to Box"
823-
)
821+
assert isinstance(
822+
override_not_box.geometry, td.Box
823+
), "Sphere override structure was not converted to Box"
824824

825825

826826
def test_override_unshadowed():

tests/test_components/test_simulation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2901,9 +2901,11 @@ def test_sim_subsection(unstructured, nz):
29012901
boundary_spec=td.BoundarySpec.all_sides(td.Periodic()),
29022902
# Set theta to 'pi/2' for 2D simulation in the x-y plane
29032903
monitors=[
2904-
mnt.updated_copy(theta=np.pi / 2)
2905-
if isinstance(mnt, td.FieldProjectionAngleMonitor)
2906-
else mnt
2904+
(
2905+
mnt.updated_copy(theta=np.pi / 2)
2906+
if isinstance(mnt, td.FieldProjectionAngleMonitor)
2907+
else mnt
2908+
)
29072909
for mnt in subsection_monitors
29082910
if not isinstance(
29092911
mnt, (td.FieldProjectionCartesianMonitor, td.FieldProjectionKSpaceMonitor)

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 "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-
)
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"
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 test_media[1].__repr__() == material_name, (
86-
"Expected repr to return just the material name."
87-
)
85+
assert (
86+
test_media[1].__repr__() == material_name
87+
), "Expected repr to return just the material name."
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 "eps_inf: 1.5385442336875639" in printed_SiO2_Palik_lossless, (
101-
"Expected eps_inf in SiO2 printed string"
102-
)
100+
assert (
101+
"eps_inf: 1.5385442336875639" in printed_SiO2_Palik_lossless
102+
), "Expected eps_inf in SiO2 printed string"
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 "eps_inf: 2.1560362571240765" in printed_SiO2_Palik_lossy, (
108-
"Expected eps_inf in SiO2 printed string"
109-
)
107+
assert (
108+
"eps_inf: 2.1560362571240765" in printed_SiO2_Palik_lossy
109+
), "Expected eps_inf in SiO2 printed string"
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 "Default Variant: Rakic1998BB" in printed_Ag, (
119-
"Expected default variant in printed string"
120-
)
118+
assert (
119+
"Default Variant: Rakic1998BB" in printed_Ag
120+
), "Expected default variant in printed string"
121121
assert "RakicLorentzDrude1998" in printed_Ag, "Expected variant in printed string"
122122

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

0 commit comments

Comments
 (0)