astropy: TST: test_lombscargle.py has 80 failed tests in devdeps

Example log: https://github.com/astropy/astropy/actions/runs/11256675139/job/31299150063

This should be resolved before we cut v7.0 RC.

I think it is just one test running a lot of variants. One of the failures:

FAILED astropy/timeseries/periodograms/lombscargle/tests/test_lombscargle.py::
    test_all_methods[model-False-none-False-False-fastchi2] - AssertionError: 
Not equal to tolerance rtol=1e-07, atol=0

Mismatched elements: 40 / 40 (100%)
Max absolute difference among violations: 0.05446034
Max relative difference among violations: 4.22703988
 ACTUAL: array([0.000273, 0.001192, 0.003183, 0.00476 , 0.005066, 0.003902,
       0.002159, 0.001589, 0.001829, 0.001277, 0.000414, 0.000883,
       0.003696, 0.007136, 0.006279, 0.001731, 0.002283, 0.015811,...
 DESIRED: array([0.008445, 0.006723, 0.004143, 0.001797, 0.000969, 0.001431,
       0.002082, 0.002242, 0.002408, 0.002709, 0.00248 , 0.002272,
       0.003062, 0.004837, 0.006965, 0.007883, 0.006677, 0.005468,...
==== 80 failed, 28405 passed, 806 skipped, 235 xfailed in 362.91s (0:06:02) ====

https://github.com/astropy/astropy/blob/a7e050ba64aa6889d5f0e1e937aab0c136106812/astropy/timeseries/periodograms/lombscargle/tests/test_lombscargle.py#L61-L69

Since the test does not skip for missing “optional” dependencies, the main suspect is numpy-dev changes.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (19 by maintainers)

Most upvoted comments

I’m all for fixing things, and I understand that the change is backward compatible from a pure API perspective. And indeed the release is not yet there, so really all I meant to note is that people’s science results will change with your PR. The change will be for the better, but I think should be mentioned in the release notes to warn people (even if not many people will see them…)

Just looking at one number, 0.000273 turning into 0.008445 is indeed not numerically exact, so whoever patches this here needs to understand why the numbers have changed and whether it is okay to just slap on a scipy version check and using different truths based on that, or not.

The really large relative errors > 4 all occur for the center_data=False, else they are always around 0.025, 0.06, 0.13 for standard, log and psd normalisations, respectively. This might indicate something related to the now “correct removal of y offsets” mentioned in the PR. In fact it seems even more directly linked to the new floating_mean argument which does change the results significantly when there is a large systematic offset (as in our test data). Changing the call to

p = signal.lombscargle(t, y, 2 * np.pi * frequency, floating_mean=False)

actually already lets all the tests pass again (as it was supposed, fully restoring the previous behaviour). So that might be a quick fix, but I think we should still go through the discussion and literature and find out if our old results really are the desired or mathematically sound ones.

@adammj - we’re just trying to understand why we get the failures with the recent code changes - no value judgement involved! But: are we correct in inferring that before the recent changes, there was no floating mean correction applied?

p.s. This wouldn’t have been such a surprise if it hadn’t been stated that the changes were backwards compatible. The changes would seem well worth a proper release note!

It’s not just method=scipy cases that are breaking, but these tests pass if scipy isn’t installed at all

Re: bug fix – Maybe true but not nice to have RC with failed job because we rely on users to test the RC on whatever envs they feel like (within reason).

Let me ping @jakevdp since he implemented the lombscargle module. It may well be that the changes are within the noise (depending on how large the actual peak is), but would be good to be sure. Since there are multiple methods to calculate the Lomb Scargle periodogramme, presumably we can also run internal cross checks.

Back to the failing test, as per https://github.com/astropy/astropy/pull/17170#issuecomment-2409189777 , we can close this issue when scipy nightly wheel catches up and we see green devdeps again. Thanks, all!

One of the lomb scargle methods just calls out to scipy, and scipy recently updated their implementation: https://github.com/scipy/scipy/pull/21277. The old scipy lomb-scargle had some abnormal conventions if I recall correctly, and I suspect they fixed these which would lead to astropy test failures.

I couldn’t resist digging down a bit tonight and found the culprit with git bisect: https://github.com/scipy/scipy/pull/21277 Since this change is advertised as “backward compatible” we’ll need to clarify whether it’s meant to be exactly equivalent (in which case there’s a regression) or if it’s expected to produce slightly different results, and some tolerance tweaking is needed on our side. I’ll re-kindle the discussion upstream

I’m game to dig into this tommorrow unless someone wants to beat me to it (but of course, feel free to !).