Description
Reproducing code example:
import numpy as np
with np.errstate(invalid="raise"):
np.ones(3) ** -1
raises:
<ipython-input-43-02fd0a095546>:2: RuntimeWarning: divide by zero encountered in reciprocal
np.ones(3) ** -1
but the result of the evaluation is still correct: array([1., 1., 1.])
...
I also tried 1 / np.ones(3)
, np.ones(2) ** -1
, np.ones(4) ** -1
which do not raise the warning.
I get it for any numpy array of 3 items with dtype np.float32
or np.float64
but not np.complex64
for instance.
NumPy/Python version information:
I got the problem with:
1.20.1 3.9.2 | packaged by conda-forge | (default, Feb 21 2021, 05:00:30)
[Clang 11.0.1 ]
on macos/arm64.
I cannot get it from a linux/aarch64 docker environment running on the same machine numpy installed from PyPI.org with version:
1.20.1 3.9.1 (default, Dec 12 2020, 08:46:48)
[GCC 8.3.0]
I cannot get it from a linux/aarch64 docker environment running on the same machine numpy installed from conda-forge with version:
1.20.1 3.9.2 | packaged by conda-forge | (default, Feb 21 2021, 05:02:26)
[GCC 9.3.0]
So maybe this is a bug related to clang or macos/arm64? Could someone with an intel mac try to reproduce it, preferably using the numpy from conda-forge?