Skip to content

Avoid getting DeprecationWarnings on broadcasted arrays fed into Cython#8965

Merged
bsipocz merged 1 commit intoastropy:masterfrom
mhvk:lombscargle-readonly
Jul 16, 2019
Merged

Avoid getting DeprecationWarnings on broadcasted arrays fed into Cython#8965
bsipocz merged 1 commit intoastropy:masterfrom
mhvk:lombscargle-readonly

Conversation

@mhvk
Copy link
Contributor

@mhvk mhvk commented Jul 7, 2019

Hopefully will fix (most of?) #8935. Note that this goes the route of explicitly declaring broadcast arrays as readonly, which should be futureproof and guarantees a bit more that we're not messing things up inadvertently.

Note: check numpy-dev run in particular!

p.s. Can add a change-log entry if people feel it is useful - noting that users will generally not see the DeprecationWarning

@bsipocz
Copy link
Member

bsipocz commented Jul 7, 2019

I don't think a changelog is necessary, users will have no way to have a say here, this is not different from any of the other compatibility changes we do for new upstream releases.

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

This does the job perfectly and also very nice to have the references in comments when we can remove the workaround.

@mhvk
Copy link
Contributor Author

mhvk commented Jul 8, 2019

Let's hold off on merging a little - there's quite a bit of discussion on how to make things better on the numpy side at numpy/numpy#13929 - it may be that after that, this PR can be simplified further.

@pllim
Copy link
Member

pllim commented Jul 8, 2019

I don't think this can be backported cleanly to 2.x due to moving the code to timeseries in #8591 (v3.2); a separate PR straight to 2.x branch might be necessary.

@mhvk , looks like there was a long discussion over at Numpy indeed. Is there a conclusion yet? Thank you very much for looking into this!

@bsipocz
Copy link
Member

bsipocz commented Jul 8, 2019

This should be an easy backport, git is usually good with recognizing the moves (even if it doesn't the changes are trivial to do manually for a conflicting backport, and to one file only, so I think it's fine as is)

@pllim
Copy link
Member

pllim commented Jul 16, 2019

Let's hold off on merging a little

@mhvk , are we still waiting for some decision upstream at Numpy?

@bsipocz
Copy link
Member

bsipocz commented Jul 16, 2019

Numpy upstream has merge the fix, but it's still broken with us, so I got confused and lost track whether we need to change things or not: numpy/numpy#13993

(note that this PR is might not been in numpy master yet, but I've tested 1.17.x locally with astropy master, and nothing has changed)

@mhvk
Copy link
Contributor Author

mhvk commented Jul 16, 2019

I think we still need the const declarations from this PR - I'll try locally.

@bsipocz
Copy link
Member

bsipocz commented Jul 16, 2019

ah, ok, indeed, that's now clearer. const are needed, but we don't need to set WRITEABLE any more.

@mhvk mhvk force-pushed the lombscargle-readonly branch from bb60083 to 2c78efa Compare July 16, 2019 19:45
@mhvk
Copy link
Contributor Author

mhvk commented Jul 16, 2019

I pushed up the more minimal change. I checked that it works locally on 1.17rc2 (but numpy-dev is not up to date yet). I think we can now just merge this...

@mhvk
Copy link
Contributor Author

mhvk commented Jul 16, 2019

Actually, let me remove the gratuitous extra line in core.py

…on code.

Declare them const so no check on writing is done.
@mhvk mhvk force-pushed the lombscargle-readonly branch from 2c78efa to 53643b8 Compare July 16, 2019 19:47
@mhvk
Copy link
Contributor Author

mhvk commented Jul 16, 2019

OK, now it's just lombscargle (which was under stats in 2.0)

@mhvk
Copy link
Contributor Author

mhvk commented Jul 16, 2019

though not sure we care about numpy 1.17 for astropy 2.0...

@bsipocz
Copy link
Member

bsipocz commented Jul 16, 2019

though not sure we care about numpy 1.17 for astropy 2.0...

so far we're OK, so will backport this to LTS, too.

Copy link
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

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

LGTM. I think this is ok to merge if numpy dev job passes. 🚀

@pllim pllim added the zzz 💤 merge-when-ci-passes Do not use: We have auto-merge option now. label Jul 16, 2019
@bsipocz
Copy link
Member

bsipocz commented Jul 16, 2019

if numpy dev job passes.

it won't as they haven't yet forward ported the fix to master yet.

@mhvk
Copy link
Contributor Author

mhvk commented Jul 16, 2019

Yes, my sense would be just to merge as is if tests pass, since I tested 1.17rc2 locally.

@bsipocz bsipocz merged commit e7d47e4 into astropy:master Jul 16, 2019
@bsipocz
Copy link
Member

bsipocz commented Jul 16, 2019

Thanks for the fix @mhvk, this was a very nice learning experience between the projects (though any understanding of numpy C is way above my level).

@mhvk mhvk deleted the lombscargle-readonly branch July 16, 2019 20:10
@mhvk
Copy link
Contributor Author

mhvk commented Jul 16, 2019

Indeed, goes to show it is worth reporting issues upstream! Certainly, far from an obvious fix to me too...

bsipocz added a commit that referenced this pull request Jul 22, 2019
Avoid getting DeprecationWarnings on broadcasted arrays fed into Cython
bsipocz added a commit that referenced this pull request Jul 22, 2019
Avoid getting DeprecationWarnings on broadcasted arrays fed into Cython
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants