Skip to content

Commit 81f9adf

Browse files
committed
BUG: update fast_scalar_power to handle special-case squaring for any array type except object arrays
1 parent 0664b2b commit 81f9adf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

numpy/_core/src/multiarray/number.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,12 @@ fast_scalar_power(PyObject *o1, PyObject *o2, int inplace, PyObject **result)
363363
}
364364

365365
PyArrayObject *a1 = (PyArrayObject *)o1;
366-
if (!(PyArray_ISFLOAT(a1) || PyArray_ISCOMPLEX(a1))) {
366+
if (PyArray_ISOBJECT(a1)) {
367+
return 1;
368+
}
369+
if (!is_square && !PyArray_ISFLOAT(a1) && !PyArray_ISCOMPLEX(a1)) {
370+
// we special-case squaring for any array type
371+
// gh-29388
367372
return 1;
368373
}
369374

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy