Repository navigation
MAINT: signal.lombscargle: fix numerical backward-compat - #21697
Conversation
|
Thanks for your patience on this. Perhaps the |
|
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. |
|
I've changed the default, and also tried to suggest in the docstring that the user might want to consider using 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. |
There was a problem hiding this comment.
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}) | ||
|
|
There was a problem hiding this comment.
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.
|
FWIW I checked that this patch resolves failures in astropy's test suite. Thank you ! |
tylerjereddy
left a comment
There was a problem hiding this comment.
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.
|
thanks @adammj @DietBru @neutrinoceros |
|
This still doesn't restore backwards compatibility for me in a library using The code might be a bit janky in terms of both numerics and implementation, but worked fine for many SciPy releases with |
|
@dnadlinger I'll take a look this weekend. Can you tell me which of your tests fail? |
|
@adammj: Oh, great, thanks a lot! I've pushed a branch without the workaround and with a Poetry lock file at https://github.com/OxfordIonTrapGroup/oitg/tree/scipy-lombscargle-repro. You should be able to reproduce the error by running The code has some plumbing ( |
|
It might be useful to open an issue summarizing some of this to reduce the chances of it falling off our radar. I think we're aiming for our next |
|
@tylerjereddy I don't think this is an issue with lombscargle. @dnadlinger the issue arises in sinusoid.py. You're storing the mean of y ( I added an * there because you're using np.random without a seed. So, I can occasionally get 1 test ( |
|
@adammj: Thanks a lot for investigating this even without a reduced test case! Nevertheless, isn't this still a breaking API change? Technically, the revamped doc comment does state that it performs |
|
I disagree with the characterization that "it's a breaking API change", because the previous API never said what it did with My only other thought is that changing that line from |
|
@tylerjereddy: I created #23474 to track further discussions. @adammj: Thanks – I responded to your points in the description of #23474 as well. My view as a library developer is that silent breaking changes to "reasonable" user progams (i.e. even in the absence of explicit guarantees, what a user might reasonably expect) are the worst kind of breakage, especially in minor versions, as they are harder to track down than any acutal breaking API change. I'd rather see the flag removed outright, because then there would at least be an obvious error message (practially, of course, we'd want to deprecate it first). |

Reference issue
#21696
What does this implement/fix?
Change
floating_meandefault fromTruetoFalse.Additional information
Additional verbiage to be figured out. Initial commit is just a placeholder.