Repository navigation
BUG: avoid deprecated shape mutation APIs in time - #19182
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
5d4735d to
826f83f
Compare
|
ok so I added an experimental commit that should help bringing more context; The problem I'm currently facing is that the remaining failing test contains several fragile parts that I don't immediately know what to do with
Any insight here, @mhvk ? |
|
(Also I think image test failures are unrelated) |
ce8ee77 to
409225f
Compare
|
note that the problem I'm facing here is similar to #19133 |
mhvk
left a comment
There was a problem hiding this comment.
@neutrinoceros - this basically looks good. Let me know when you take it out of draft.
|
I was actually waiting for early feedback from you. The change may be sensible but it isn't stable: there's still one test failing, and the failure mode is new in this PR |
mhvk
left a comment
There was a problem hiding this comment.
@neutrinoceros - I think I found the problem...
| if val is None or val.size <= 1: | ||
| continue | ||
| try: | ||
| if NUMPY_LT_2_5: |
There was a problem hiding this comment.
The problem is here: you assume that all val will be ndarray subclasses where _set_shape will just work, but for Masked subclasses this does not change the shape of the mask. I think we need to adjust MaskedNDArray -- see comment below.
p.s. I don't quite recall the failure modes for other parts, but possibly the assumption that every attribute is a plain ndarray goes wrong there too.
| @@ -744,13 +745,22 @@ def shape(self): | |||
| @shape.setter | |||
| def shape(self, shape): | |||
There was a problem hiding this comment.
As noted above, for not NUMPY_LT_2_5we also need to override _set_shape since it does not go the correct thing. Possibly easiest is just to call this _set_shape and let shape.setter refer to it.
There was a problem hiding this comment.
THANK YOU ! this is exactly correct, and does resolve the remaining failure.
| if NUMPY_LT_2_5: | ||
| super(MaskedNDArray, type(self)).shape.__set__(self, shape) | ||
| else: | ||
| self._set_shape(shape) |
There was a problem hiding this comment.
Since we need to define our own _set_shape, this needs to be super()._set_shape(shape).
409225f to
f04b9b5
Compare
mhvk
left a comment
There was a problem hiding this comment.
Great that it worked! Let's get it in.
|
And the remaining 33 requires jplephem release or something? What is the wait time on that? Should we put in a ignore filter for now? |
|
Yes, ignoring the |
yes
No idea.
I don't think pytest (really, |
|
I mean, just ignore the entire "Setting the shape on a NumPy array has been deprecated" in pyproject.toml here: Line 247 in 143c9c1 with a follow-up issue to remove the ignore before next v7.2.x release by setting a milestone to the issue. |
|
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the If these instructions are inaccurate, feel free to suggest an improvement. |
|
Also can you please manually backport? Thanks! 🙏 |
I know it's closer to our usual workflow, but I also think it's riskier in this instance: we could easily silence a real warning from ourselves or another third party library. Anyway, best case scenario is still that we don't need a workaround at all. |
BUG: avoid deprecated shape mutation APIs in time (cherry picked from commit 081b25b)
Backport PR #19182 to branch v7.2.x (BUG: avoid deprecated shape mutation APIs in time)
PR: astropy#19210 Issue: astropy#19182 Base commit: 7ad6f3d Changed lines: 66
PR: astropy#19182 Issue: astropy#19126 Base commit: 143c9c1 Changed lines: 64
Description
ref #19126
opening as a draft: what I have seem necessary but not sufficient. Will provide more details later