Exorcise deprecated sparse matrix (scipy 2.0) - #20167
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.
|
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
kbwestfall
left a comment
There was a problem hiding this comment.
This comes with the caveat that I've only briefly looked at the migration page. I can dig in more later.
Do we know when this deprecation will actually happen? The warning at the top of this page just says it will be done "in the next few releases".
Scipy usually removes deprecated APIs after just a couple minor releases. |
2ef79cb to
ec1d1fd
Compare
|
scipy might also change more API than this but we can only react to what we see in CI. |
ec1d1fd to
113b589
Compare
This comment was marked as outdated.
This comment was marked as outdated.
| if SCIPY_LT_2_0: | ||
| from scipy.sparse import coo_matrix, csr_matrix, find, isspmatrix_csr, triu | ||
| else: | ||
| from scipy.sparse import coo_array as coo_matrix |
There was a problem hiding this comment.
This indeed should be checked by the nddata folks, most importantly to check no multiplication is used as matrix multiplication, but FWIW, I would tend to flip this around, i.e., turn towards the future by replacing coo_matrix with coo_array in the code and above import coo_matrix as coo_array.
There was a problem hiding this comment.
I was trying to keep the diff to a minimal but I can flip the naming if y'all want. More code to review though.
There was a problem hiding this comment.
Yeah, I had the same thought as Marten. Up to you, but I'm happy to review the changes either way.
There was a problem hiding this comment.
OK sure, I can flip the naming
There was a problem hiding this comment.
OK I flipped names in the code, but I left the in-code comments and docstrings alone. Cannot really touch the docstring or intersphinx would break.
2c76831 to
b3bae88
Compare
|
Any chance someone can read the guide carefully soon (in a few days)? If not, I will temporarily ignore these warnings instead so we don't let even more failures creep into devdeps. Thanks! |
|
I'm paying close attention to devdeps and will be careful not to let new ones through. I can also take over this PR if you like. |
This comment was marked as resolved.
This comment was marked as resolved.
|
I mean pick up where you left off and conduct following iterations. I thought that's what you were asking for. Maybe I misunderstood ? |
|
I am waiting for @kbwestfall to do a careful read of the migration guide, since he wrote the original code. :D |
|
FWIW I'm used to ready migration guides for code I didn't write, so I should be comfortable filling in for Kyle if need be :) |
|
@neutrinoceros do you want to review then? Feel free. Thanks! |
|
sign me up. I'll do this in the morning. |
There was a problem hiding this comment.
The current approach doesn't seem internally consistent to me.
We're immediately dropping coo_matrix as a re-exported API but we're also adding an entirely new wrapper for issparse, just to alias a now deprecated function without the deprecation.
Overall think it's crucial we choose one strategy and apply it everywhere, otherwise we'll just end up with an even messier situation vis-à-vis our own users.
Personally I think the easiest path forward would be to preserve all re-exports as they are, just maybe hide them behind a module level __getattr__ so they don't warn eagerly.
Alternatively, we could wrap all of them with the old API names, and immediately deprecated them all.
I don't think the maintenance burden is justified, but that would at least be consistent, and slightly easier on any downstream user relying on these re-exports. Long term, I think this deprecation is proof that blindly re-exporting foreign APIs isn't worth the effort, which is why I'm suggesting to cut our looses now.
| SCIPY_LT_2_0 = not minversion(scipy, "2.0.0.dev") | ||
|
|
||
| if SCIPY_LT_2_0: | ||
| from scipy.sparse import coo_matrix as coo_array |
There was a problem hiding this comment.
This is not a drop-in replacement. This would lead to inconsistent behavior depending on the scipy version installed.
There was a problem hiding this comment.
I don't have time to deep dive into this module, unfortunately. Do you want to open an alternate PR and close this one?
For now, maybe we should ignore the warnings.
There was a problem hiding this comment.
I can propose my solution in another PR, yes.
|
Sorry that I dropped off the map for this one. Two quick responses (which may be too hasty...):
|
that's my point though: here it's dropped immediately, without a deprecation cycle, so it's a breaking change instead of a backward compatibility layer |
This comment was marked as resolved.
This comment was marked as resolved.
|
Then why does test_scipy_funcs exist ? |
Maybe I'm misunderstanding, but I don't think this is dropping anything that the user's scipy version supports. I.e., if they have scipy < 2.0, the code will import and use The I think it's more important to understand whether or not |
Yes. The fact that we have a test exercising it seems to indicate that this is a supported use case. If that is in fact not its purpose, I don't understand what it's there for.
Me too, but the existing code seems ambiguous wether this was intentionally supported or not, especially because there are 0 indications that these functions are considered private. |
This is a low-level test to ensure that the scipy imports within the
To me, this is like having a |
I don't think it's worth having, but having an inline explanation would solve the biggest problem I have with it: confusion.
I think you're implying that it's a bad idea, and I agree ! Nonetheless, it is sometimes done deliberately and I was under the impression that it was the case here.
we can't really guard against it, though a module level
kill it with fire then 🔥 |
|
I am getting confused. Are we staying with this PR or moving to a new one by @neutrinoceros ? |
My understanding is that we're sticking with this one. The remaining items (as far as I understand) are:
|
b3bae88 to
a1640e8
Compare
|
I have rebased and removed |
|
OK now devdeps only have 1 failure from #20231 that is unrelated to scipy |
Not yet. I'm not on vacation but still traveling so my capacity is limited these days (but I'm hoping to ramp it up in the next couple days). I can prioritize this on request, but until then it's only somewhat near the top of my list. |
but did not read conversion guide carefully Co-authored-by: Kyle Westfall <westfall@ucolick.org>
but leave in-code comments and docstrings alone
because it is confusing to test API of another library as our own
a1640e8 to
da11fe8
Compare
|
I rebased your branch. I think it now addresses the only remaining failures on allowed-deps, so we should be able to see what's up with just the global status on this job now. |
Description
This pull request would need someone familiar with the nddata code and also who has time to read https://docs.scipy.org/doc/scipy/reference/sparse.migration_to_sparray.html carefully to review.
Reviewers should ignore the one
ufuncfailure in devdeps that is being handled separately in #20132Fixes #20164