Skip to content

Commit

Permalink
Update black version
Browse files Browse the repository at this point in the history
  • Loading branch information
momchil-flex committed Jan 5, 2024
1 parent a3831af commit 1cd1bb9
Show file tree
Hide file tree
Showing 67 changed files with 18 additions and 219 deletions.
1 change: 0 additions & 1 deletion make_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


def main(args):

parser = argparse.ArgumentParser(description="Generate tidy3d script from a simulation file.")

parser.add_argument(
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# required for development
pre-commit
black==22.3.0
black==23.12.1
ruff
tox
pytest
Expand Down
1 change: 0 additions & 1 deletion tests/_test_local/_test_adjoint_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def f(eps_values):


def test_time_custom_medium(use_emulated_run):

num_tests = 50
nxs = np.logspace(0, 2.0, num_tests)
times_sec = np.zeros(num_tests)
Expand Down
5 changes: 0 additions & 5 deletions tests/_test_local/_test_data_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def test_memory_2_load():


def test_core_profile_small_1_save():

Nx, Ny, Nz, Nt = 100, 100, 100, 10

x = np.arange(Nx)
Expand All @@ -99,14 +98,12 @@ def test_core_profile_small_1_save():


def test_core_profile_small_2_load():

with Profile():
print(f"file_size = {os.path.getsize(PATH):.2e} Bytes")
data = td.FieldTimeData.from_file(PATH)


def test_core_profile_large():

sim_data = make_sim_data_1()

with Profile():
Expand All @@ -120,7 +117,6 @@ def test_core_profile_large():

@profile
def test_speed_many_datasets():

Nx, Ny, Nz, Nf = 100, 100, 100, 1

x = np.arange(Nx)
Expand Down Expand Up @@ -162,7 +158,6 @@ def make_field_data(num_index: int):
)

with Profile():

sim_data.to_file(PATH)
sim_data2 = sim_data.from_file(PATH)

Expand Down
3 changes: 1 addition & 2 deletions tests/_test_local/_test_fit_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_dispersion_lossless():
)

# a and c for each pole should be purely imaginary
for (a, c) in best_medium.poles:
for a, c in best_medium.poles:
assert isclose(np.real(a), 0)
assert isclose(np.real(c), 0)

Expand All @@ -64,7 +64,6 @@ def test_dispersion_load_file():


def test_dispersion_load_url():

url_csv = "https://refractiveindex.info/data_csv.php?datafile=data/main/Ag/Johnson.yml"
fitter = StableDispersionFitter.from_url(url_csv)

Expand Down
1 change: 0 additions & 1 deletion tests/test_components/test_apodization.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def test_negative_times():


def test_plot():

run_time = 1.0e-13
times = [0, 2.0e-14, 4.0e-14, 6.0e-14, 8.0e-14, 1.0e-13]

Expand Down
1 change: 0 additions & 1 deletion tests/test_components/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def test_updated_copy():


def test_equality():

# test freqs / arraylike
mnt1 = td.FluxMonitor(size=(1, 1, 0), freqs=np.array([1, 2, 3]) * 1e12, name="1")
mnt2 = td.FluxMonitor(size=(1, 1, 0), freqs=np.array([1, 2, 3]) * 1e12, name="1")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_components/test_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def verify_custom_dispersive_medium_methods(mat):
poles_interp = mat.pole_residue.poles_on_grid(coord_interp)
assert len(poles_interp) == len(mat.pole_residue.poles)
coord_shape = tuple(len(grid) for grid in coord_interp.to_list)
for (a, c) in poles_interp:
for a, c in poles_interp:
assert a.shape == coord_shape
assert c.shape == coord_shape

Expand Down
2 changes: 0 additions & 2 deletions tests/test_components/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@ def test_geometry():


def test_geometry_sizes():

# negative in size kwargs errors
for size in (-1, 1, 1), (1, -1, 1), (1, 1, -1):
with pytest.raises(pydantic.ValidationError):
Expand Down Expand Up @@ -851,7 +850,6 @@ def test_custom_surface_geometry(tmp_path):


def test_geo_group_sim():

geo_grp = td.TriangleMesh.from_stl("tests/data/two_boxes_separate.stl")
geos_orig = list(geo_grp.geometries)
geo_grp_full = geo_grp.updated_copy(geometries=geos_orig + [td.Box(size=(1, 1, 1))])
Expand Down
5 changes: 0 additions & 5 deletions tests/test_components/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def test_field_grid():


def test_grid():

boundaries_x = np.arange(-1, 2, 1)
boundaries_y = np.arange(-2, 3, 1)
boundaries_z = np.arange(-3, 4, 1)
Expand Down Expand Up @@ -205,7 +204,6 @@ def test_sim_nonuniform_large():


def test_sim_grid():

sim = td.Simulation(
size=(4, 4, 4),
grid_spec=td.GridSpec.uniform(1.0),
Expand Down Expand Up @@ -252,7 +250,6 @@ def test_sim_symmetry_grid():


def test_sim_pml_grid():

sim = td.Simulation(
size=(4, 4, 4),
grid_spec=td.GridSpec.uniform(1.0),
Expand All @@ -271,7 +268,6 @@ def test_sim_pml_grid():


def test_sim_discretize_vol():

sim = td.Simulation(
size=(4, 4, 4),
grid_spec=td.GridSpec.uniform(1.0),
Expand All @@ -293,7 +289,6 @@ def test_sim_discretize_vol():


def test_sim_discretize_plane():

sim = td.Simulation(
size=(4, 4, 4),
grid_spec=td.GridSpec.uniform(1.0),
Expand Down
1 change: 0 additions & 1 deletion tests/test_components/test_grid_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def test_make_coords_2d():


def test_wvl_from_sources():

# no sources
with pytest.raises(SetupError):
td.GridSpec.wavelength_from_sources(sources=[])
Expand Down
1 change: 0 additions & 1 deletion tests/test_components/test_heat.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ def test_heat_sim_bounds(shift_amount, log_level, log_capture):
CENTER_SHIFT = (-1.0, 1.0, 100.0)

def place_box(center_offset):

shifted_center = tuple(c + s for (c, s) in zip(center_offset, CENTER_SHIFT))

_ = td.HeatSimulation(
Expand Down
7 changes: 0 additions & 7 deletions tests/test_components/test_medium.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def test_from_n_less_than_1():


def test_medium():

# mediums error with unacceptable values
with pytest.raises(pydantic.ValidationError):
_ = td.Medium(permittivity=0.0)
Expand Down Expand Up @@ -82,12 +81,10 @@ def test_medium_conversions():


def test_PEC():

_ = td.Structure(geometry=td.Box(size=(1, 1, 1)), medium=td.PEC)


def test_medium_dispersion():

# construct media
m_PR = td.PoleResidue(eps_inf=1.0, poles=[((-1 + 2j), (1 + 3j)), ((-2 + 4j), (1 + 5j))])
m_SM = td.Sellmeier(coeffs=[(2, 3), (2, 4)])
Expand Down Expand Up @@ -126,7 +123,6 @@ def test_medium_dispersion():


def test_medium_dispersion_conversion():

m_PR = td.PoleResidue(eps_inf=1.0, poles=[((-1 + 2j), (1 + 3j)), ((-2 + 4j), (1 + 5j))])
m_SM = td.Sellmeier(coeffs=[(2, 3), (2, 4)])
m_LZ = td.Lorentz(eps_inf=1.0, coeffs=[(1, 3, 2), (2, 4, 1)])
Expand All @@ -142,7 +138,6 @@ def test_medium_dispersion_conversion():


def test_medium_dispersion_create():

m_PR = td.PoleResidue(eps_inf=1.0, poles=[((-1 + 2j), (1 + 3j)), ((-2 + 4j), (1 + 5j))])
m_SM = td.Sellmeier(coeffs=[(2, 3), (2, 4)])
m_LZ = td.Lorentz(eps_inf=1.0, coeffs=[(1, 3, 2), (2, 4, 1)])
Expand Down Expand Up @@ -174,7 +169,6 @@ def test_sellmeier_from_dispersion():


def eps_compare(medium: td.Medium, expected: Dict, tol: float = 1e-5):

for freq, val in expected.items():
assert np.abs(medium.eps_model(freq) - val) < tol

Expand Down Expand Up @@ -464,7 +458,6 @@ def test_fully_anisotropic_media():


def test_perturbation_medium():

# Non-dispersive
pp_real = td.ParameterPerturbation(
heat=td.LinearHeatPerturbation(
Expand Down
3 changes: 0 additions & 3 deletions tests/test_components/test_meshgenerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ def test_grid_in_interval():


def test_grid_analytic_refinement():

max_dl_list = np.array([0.5, 0.5, 0.4, 0.1, 0.4])
len_interval_list = np.array([2.0, 0.5, 0.2, 0.1, 0.3])
max_scale = 1.5
Expand All @@ -291,7 +290,6 @@ def test_grid_analytic_refinement():


def test_grid_refinement():

max_dl_list = np.array([0.5, 0.4, 0.1, 0.4])
len_interval_list = np.array([0.5, 1.2, 0.1, 1.3])
max_scale = 1.5
Expand Down Expand Up @@ -698,7 +696,6 @@ def test_small_structure_size(log_capture):


def test_shapely_strtree_warnings():

with warnings.catch_warnings():
warnings.simplefilter("error")
_ = GradedMesher().parse_structures(
Expand Down
1 change: 0 additions & 1 deletion tests/test_components/test_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


def test_modes():

_ = td.ModeSpec(num_modes=2)
_ = td.ModeSpec(num_modes=1, target_neff=1.0)

Expand Down
5 changes: 0 additions & 5 deletions tests/test_components/test_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def test_downsampled():


def test_excluded_surfaces_flat():

with pytest.raises(pydantic.ValidationError):
_ = td.FluxMonitor(size=(1, 1, 0), name="f", freqs=[1e12], exclude_surfaces=("x-",))

Expand Down Expand Up @@ -296,7 +295,6 @@ def test_monitor_num_modes(log_capture, num_modes, log_level):


def test_diffraction_validators():

# ensure error if boundaries are not periodic
boundary_spec = td.BoundarySpec(
x=td.Boundary.pml(),
Expand All @@ -322,7 +320,6 @@ def test_diffraction_validators():


def test_monitor():

size = (1, 2, 3)
center = (1, 2, 3)

Expand Down Expand Up @@ -357,7 +354,6 @@ def test_monitor():


def test_monitor_plane():

# make sure flux, mode and diffraction monitors fail with non planar geometries
for size in ((0, 0, 0), (1, 0, 0), (1, 1, 1)):
with pytest.raises(pydantic.ValidationError):
Expand All @@ -374,7 +370,6 @@ def _test_freqs_nonempty():


def test_monitor_surfaces_from_volume():

center = (1, 2, 3)

# make sure that monitors with zero volume raise an error (adapted from test_monitor_plane())
Expand Down
5 changes: 0 additions & 5 deletions tests/test_components/test_parameter_perturbation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


def test_heat_perturbation():

perturb = td.LinearHeatPerturbation(
coeff=0.01,
temperature_ref=300,
Expand Down Expand Up @@ -61,7 +60,6 @@ def test_heat_perturbation():
perturb_data = td.HeatDataArray([1 + 1j, 3 + 1j, 1j], coords=dict(T=[200, 300, 400]))

for interp_method in ["linear", "nearest"]:

perturb = td.CustomHeatPerturbation(
perturbation_values=perturb_data, interp_method=interp_method
)
Expand Down Expand Up @@ -110,7 +108,6 @@ def test_heat_perturbation():


def test_charge_perturbation():

perturb = td.LinearChargePerturbation(
electron_coeff=1e-21,
electron_ref=0,
Expand Down Expand Up @@ -216,7 +213,6 @@ def test_charge_perturbation():
)

for interp_method in ["linear", "nearest"]:

perturb = td.CustomChargePerturbation(
perturbation_values=perturb_data, interp_method=interp_method
)
Expand Down Expand Up @@ -306,7 +302,6 @@ def test_charge_perturbation():


def test_parameter_perturbation():

heat = td.LinearHeatPerturbation(
coeff=0.01,
temperature_ref=300,
Expand Down
3 changes: 0 additions & 3 deletions tests/test_components/test_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def test_scene_init():


def test_validate_components_none():

assert SCENE._validate_num_mediums(val=None) is None


Expand Down Expand Up @@ -169,7 +168,6 @@ def _test_names_default():


def test_names_unique():

with pytest.raises(pd.ValidationError):
_ = td.Scene(
structures=[
Expand All @@ -188,7 +186,6 @@ def test_names_unique():


def test_perturbed_mediums_copy():

# Non-dispersive
pp_real = td.ParameterPerturbation(
heat=td.LinearHeatPerturbation(
Expand Down
Loading

0 comments on commit 1cd1bb9

Please sign in to comment.