Skip to content

Commit 08ea743

Browse files
committed
Return 0 spectrum if no times are above the dft cutoff
1 parent 7fc2c2d commit 08ea743

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tidy3d/components/time.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def spectrum(
7979
time_amps = np.real(time_amps)
8080

8181
# if all time amplitudes are zero, just return (complex-valued) zeros for spectrum
82-
if np.allclose(time_amps, 0.0):
82+
if np.all(np.equal(time_amps, 0.0)):
8383
return (0.0 + 0.0j) * np.zeros_like(freqs)
8484

8585
# Cut to only relevant times
@@ -89,6 +89,8 @@ def spectrum(
8989
stop_ind = relevant_time_inds[0][-1]
9090
time_amps = time_amps[start_ind:stop_ind]
9191
times_cut = times[start_ind:stop_ind]
92+
if times_cut.size == 0:
93+
return (0.0 + 0.0j) * np.zeros_like(freqs)
9294

9395
# only need to compute DTFT kernel for distinct dts
9496
# usually, there is only one dt, if times is simulation time mesh

0 commit comments

Comments
 (0)