Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return 0 spectrum if no times are above the dft cutoff #1297

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

momchil-flex
Copy link
Collaborator

A few times we've had simulations error out because the times_cut array is empty. The only way I can see this happening is if the source amps are just 0 (and for some reason the 0/0 returns 0 I guess?). Anyway, I think this should at least prevent the simulations from erroring even if the results would be meaningless - or all 0s.

Copy link
Contributor

@caseyflex caseyflex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 81-83 were supposed to accomplish that, but looking at them again, using np.allclose is suspect -- it will be using atol=1e-8, which is quite arbitrary. Maybe replace this with np.equal, in addition to adding your lines just in case.

@caseyflex
Copy link
Contributor

assert not np.all(np.equal(td.GaussianPulse(amplitude=1e-10, freq0=1, fwidth=.1).spectrum(times=np.linspace(0, 10, 100), freqs=np.linspace(0, 10, 100), dt=.1), 0))

this currently asserts False, but replacing np.allclose with np.equal should change it

@momchil-flex momchil-flex merged commit 08ea743 into pre/2.5 Dec 7, 2023
14 checks passed
@momchil-flex momchil-flex deleted the momchil/dft_cutoff branch December 7, 2023 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants