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

[BUG] smearer tests are failing when using numpy 1.25 or later #345

Closed
jonbarker68 opened this issue Sep 17, 2023 · 0 comments · Fixed by #346
Closed

[BUG] smearer tests are failing when using numpy 1.25 or later #345

jonbarker68 opened this issue Sep 17, 2023 · 0 comments · Fixed by #346
Labels
bug Something isn't working

Comments

@jonbarker68
Copy link
Contributor

clarity/evaluator/msbg/smearing.py tests failing with numpy 1.25 or later.

Tracked it down to the smear3 function in smearing.py which computes power by multiply complex number by its conjugate, which should give a real result but in the newer numpy there are precision errors.

Solution is to use np.abs to get the length and then square it. In smear3() the function needs to look like this.

    mag = np.abs(spectrum[0:nyquist])
    phasor = spectrum[0:nyquist] / (mag + (mag == 0))

    smeared = np.dot(f_smear, (mag**2).astype(complex))

With this it passes the tests with all numpy versions, i.e. 1.24 or 1.25

@jonbarker68 jonbarker68 added bug Something isn't working question Further information is requested and removed question Further information is requested labels Sep 17, 2023
@jonbarker68 jonbarker68 linked a pull request Sep 17, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant