Content-Length: 254271 | pFad | http://github.com/numpy/numpy/pull/29417

94 BUG: Any dtype should call `square` on `arr ** 2` (#29392) by charris · Pull Request #29417 · numpy/numpy · GitHub
Skip to content

BUG: Any dtype should call square on arr ** 2 (#29392) #29417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2025

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








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/numpy/numpy/pull/29417

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy