Skip to content

RFC: avoid deprecation warnings from numpy 2.5 when updating an array's dtype in place#637

Open
neutrinoceros wants to merge 1 commit intoyt-project:mainfrom
neutrinoceros:compat/numpy2.5/dtype-setter
Open

RFC: avoid deprecation warnings from numpy 2.5 when updating an array's dtype in place#637
neutrinoceros wants to merge 1 commit intoyt-project:mainfrom
neutrinoceros:compat/numpy2.5/dtype-setter

Conversation

@neutrinoceros
Copy link
Copy Markdown
Member

@neutrinoceros neutrinoceros force-pushed the compat/numpy2.5/dtype-setter branch 2 times, most recently from 6b560c0 to 54814c2 Compare April 8, 2026 15:20
@neutrinoceros neutrinoceros force-pushed the compat/numpy2.5/dtype-setter branch from 54814c2 to b56de60 Compare April 8, 2026 15:21
@ngoldbaum
Copy link
Copy Markdown
Contributor

Did you try deleting the code that updates the dtype and allow integer arrays through unchanged? Maybe it just works?

Although it occurs to me now that maybe this code is setting up an in-place multiply that needs a float array, since multiplying by a non-integral conversion factor will suffer truncation error if the array stays an integer array.

Another possibly more disruptive option is to raise a TypeError so callers can reason about this.

@neutrinoceros
Copy link
Copy Markdown
Member Author

Did you try deleting the code that updates the dtype and allow integer arrays through unchanged? Maybe it just works?

It doesn't. 15 tests break quite badly with errors like

numpy._core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'divide' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

Another possibly more disruptive option is to raise a TypeError so callers can reason about this.

I agree that's probably where we should be going with this, though we could probably do that over a deprecation cycle.

@neutrinoceros neutrinoceros marked this pull request as ready for review April 8, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TST: Upcoming dependency test failures

2 participants