Skip to content

Commit d8eeb76

Browse files
committed
BUG: update fast_scalar_power to handle special-case squaring for any array type except object arrays
1 parent b5d6eb4 commit d8eeb76

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

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)