Skip to content

Commit

Permalink
Resolved missing ValueError in estimate_cost
Browse files Browse the repository at this point in the history
scs_combined was failing with a tidy3d error due to a missing source
Added source and monkeypatch to prevent live computation
  • Loading branch information
m-bone committed Sep 17, 2024
1 parent 3d3a076 commit 415efd0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_plugins/test_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def scs_combined(radius: float, num_spheres: int, tag: str) -> float:

# set up simulation
spheres = []
freq0 = td.C_0 / 0.5

for _ in range(int(num_spheres)):
spheres.append(
Expand All @@ -187,6 +188,13 @@ def scs_combined(radius: float, num_spheres: int, tag: str) -> float:
sim = td.Simulation(
size=(1, 1, 1),
structures=spheres,
sources=[
td.PointDipole(
center=(0, 0, 0),
source_time=td.GaussianPulse(freq0=freq0, fwidth=freq0 / 10),
polarization="Ex",
)
],
grid_spec=td.GridSpec.auto(wavelength=1.0),
run_time=1e-12,
monitors=[mnt],
Expand Down Expand Up @@ -469,6 +477,11 @@ def test_estimate_cost(est_cost_func, sweep_method, monkeypatch):
def emulated_job_delete(self):
pass

# Still need to emulate the run as tests may call tidy3d
monkeypatch.setattr(web, "run", run_emulated)

monkeypatch.setattr(web.Batch, "run", emulated_batch_run)

monkeypatch.setattr(web.Job, "delete", emulated_job_delete)

monkeypatch.setattr(web.Job, "estimate_cost", est_cost_func)
Expand Down

0 comments on commit 415efd0

Please sign in to comment.