BUG: Fix array_equal for numeric and non-numeric scalar types by charris · Pull Request #27279 · numpy/numpy

@eendebakpt @charris

Backport of numpy#27275

Mitigates numpy#27271. The underlying issue (an array comparison returning a
python bool instead of a numpy bool) is not addressed.

The order of statements is slightly reordered, so that the if
`a1 is a2:` check can be done before the calculation of
`cannot_have_nan`

Closes numpygh-27271