Skip to content

MAINT: signal.lombscargle: fix numerical backward-compat #21697

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

Merged
merged 6 commits into from
Oct 13, 2024
Merged

MAINT: signal.lombscargle: fix numerical backward-compat #21697

merged 6 commits into from
Oct 13, 2024

Conversation

adammj
Copy link
Contributor

@adammj adammj commented Oct 12, 2024

Reference issue

#21696

What does this implement/fix?

Change floating_mean default from True to False.

Additional information

Additional verbiage to be figured out. Initial commit is just a placeholder.

@adammj adammj requested review from larsoner and ilayn as code owners October 12, 2024 00:18
@github-actions github-actions bot added scipy.signal maintenance Items related to regular maintenance tasks labels Oct 12, 2024
@tylerjereddy tylerjereddy added this to the 1.15.0 milestone Oct 12, 2024
@tylerjereddy
Copy link
Contributor

Thanks for your patience on this. Perhaps the signal regulars will have a few suggestions given the ecosystem discussion in the matching issue.

@adammj
Copy link
Contributor Author

adammj commented Oct 12, 2024

No worries. I sympathize with the large ecosystem that makes use of scipy. But it also feels unfortunate not to default to the preferred/better option, and hope the user discovers it.

@adammj
Copy link
Contributor Author

adammj commented Oct 12, 2024

I've changed the default, and also tried to suggest in the docstring that the user might want to consider using floating_mean=True. I'm open to any further suggested modifications.

I still propose that the default should be changed eventually—with sufficient notice. I understand there are many downstream users. Because scipy is the most popular toolbox that has this functionality, and is geared towards generalists, I believe providing for a "floating-mean" (which is generally preferred and recommended in literature) is the better choice. On balance, the current status quo is more likely to produce erroneous results.

Copy link
Contributor

@DietBru DietBru left a comment

Choose a reason for hiding this comment

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

I only have cosmetic suggestions:

The following line

Input arrays should be 1-D with a real floating dtype.

could be changed to something like:

Input arrays should be 1-D of a real floating data type, which are converted into float64 arrays before processing.

It describes a little more accurately, what is happening.

>>> ax_p.set_xlabel('Angular frequency [rad/s]')
>>> ax_p.set_ylabel('Power')
>>> ax_p.legend(prop={'size': 7})

Copy link
Contributor

Choose a reason for hiding this comment

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

Cosmetic nitpick: If you add line with ... instead of a pure blank line, i.e,:

>>> ax_p.legend(prop={'size': 7})
...
>>> ax_n.plot(w, pgram_norm, label='default')

you'll get a continuous code block, which is easier to copy and paste.

@neutrinoceros
Copy link

neutrinoceros commented Oct 13, 2024

FWIW I checked that this patch resolves failures in astropy's test suite. Thank you !

@lucascolley lucascolley changed the title MAINT: lombscargle numerical backward-compat #21696 MAINT: signal.lombscargle: fix numerical backward-compat Oct 13, 2024
Copy link
Contributor

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

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

Expert reviewer seems happy, downstream seems happy, CI seems happy. The diff and rendered docstring seem "ok" to me (maybe a few places where more bacticks would render variable names a bit nicer, but not worth holding this up for).

I'll go ahead and squash merge with adjusted commit message now.

@tylerjereddy tylerjereddy merged commit 4c2a19b into scipy:main Oct 13, 2024
38 of 39 checks passed
@tylerjereddy
Copy link
Contributor

thanks @adammj @DietBru @neutrinoceros

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Items related to regular maintenance tasks scipy.signal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants