Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

charris
Copy link
Member

@charris charris commented Jul 22, 2025

Backport of #29392.

Fixes #29388.

The simplification in gh-27901 seems to have removed special casing for squares, not considering the differing behavior of np.power(x, 2) and np.square(x) on structured dtypes.

There may be more edge cases to consider--I am looking! Also adding a test. Thanks.

  • BUG: update fast_scalar_power to handle special-case squaring for any array type except object arrays

  • BUG: fix missing declaration

  • TST: add test to ensure arr**2 calls square for structured dtypes

  • STY: remove whitespace

  • BUG: replace new variable is_square with direct op comparison in fast_scalar_power function

* BUG: update fast_scalar_power to handle special-case squaring for any array type except object arrays

* BUG: fix missing declaration

* TST: add test to ensure `arr**2` calls square for structured dtypes

* STY: remove whitespace

* BUG: replace new variable `is_square` with direct op comparison in `fast_scalar_power` function
@charris charris added this to the 2.3.2 release milestone Jul 22, 2025
@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Jul 22, 2025
@charris charris merged commit 727a4a2 into numpy:maintenance/2.3.x Jul 22, 2025
75 checks passed
@charris charris deleted the backport-29392 branch July 22, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 08 - Backport Used to tag backport PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants