stingray icon indicating copy to clipboard operation
stingray copied to clipboard

Unit tests for `get_phase_lag` and `get_mean_phase_difference`

Open capy-on-caffeine opened this issue 1 year ago • 10 comments

This PR is for adding unit tests for get_phase_lag and get_mean_phase_difference in spectroscopy.py as per issue #358. The current tests can be further improved by creating light curves with more data points.

capy-on-caffeine avatar Apr 04 '23 16:04 capy-on-caffeine

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 48.59%. Comparing base (14756d9) to head (0b6f419). Report is 6 commits behind head on main.

:exclamation: Current head 0b6f419 differs from pull request most recent head 4e5823b. Consider uploading reports for the commit 4e5823b to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #714       +/-   ##
===========================================
- Coverage   96.47%   48.59%   -47.89%     
===========================================
  Files          45       45               
  Lines        9135     9135               
===========================================
- Hits         8813     4439     -4374     
- Misses        322     4696     +4374     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 13 '23 08:04 codecov[bot]

Note to self and @capy-on-caffeine : this is worth completing :)

matteobachetti avatar Oct 30 '23 12:10 matteobachetti

Hello @capy-on-caffeine! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers:

Comment last updated at 2024-04-22 11:18:43 UTC

pep8speaks avatar Jan 21 '24 17:01 pep8speaks

@matteobachetti any suggestions for an improved unit test?

capy-on-caffeine avatar Apr 02 '24 06:04 capy-on-caffeine

Hi @capy-on-caffeine ! One thing that might be worth trying if you want something more fancy is a more realistic case where your lightcurve is a sum of a QPO plus a harmonic (rather than the simple wave you have now), plus the QPO and harmonic have (known) non-zero phase. Then you can test against that known phase rather than 0 (or pi or pi/2) like you are doing now.

matteolucchini1 avatar Apr 03 '24 15:04 matteolucchini1

@matteolucchini1 Thank you, I'll try this out

capy-on-caffeine avatar Apr 04 '24 03:04 capy-on-caffeine

@matteobachetti @matteolucchini1 I made some changes, any changes are welcome.

capy-on-caffeine avatar Apr 14 '24 13:04 capy-on-caffeine

@capy-on-caffeine there is something I don't understand in these tests. Why should phase lags be $\pi/2$ between two identical light curves? Also, @matteolucchini1 's suggestion to inject an actual phase difference and trying to recover it from the measurement is great. Am I missing something? Some comments to the code would not hurt 😅

matteobachetti avatar Apr 22 '24 11:04 matteobachetti

Sorry for the late reply. I'll go through these again and change them after discussing.

capy-on-caffeine avatar Apr 24 '24 01:04 capy-on-caffeine

@matteobachetti @matteolucchini1 I was looking into it and noticed a few things:

  1. get_mean_phase_difference() uses cs.m but m = 1 from the input, which possibly disrupts the calculation. I'm reading through the docs to set that first.
  2. While graphing the crossspectrum, I noticed some peaks. Just wanted to know if these are normal? Screenshot 2024-04-26 200438 Screenshot 2024-04-26 200503

capy-on-caffeine avatar Apr 26 '24 14:04 capy-on-caffeine