Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: incorrect warning message when call np.linalg.det on apple M1 #24633

@husisy

Description

@husisy

Describe the issue:

On Apple M1, calling np.linalg.det on complex matrix generates incorrect warning message (still correct results).

env libblas results warning
env00 openblas correct yes
env01 accelerate correct no

minimum working example (MWE) to reproduce warning

#libblas from openblas
conda create -c conda-forge -n env00 numpy
conda activate env00

MWE without warning (use libblas from accelerate)

conda create -c conda-forge -n env01 numpy "libblas=*=*accelerate"
conda activate env01

seems related issues: #22025

I also did other tests

  1. no warning message on ubuntu-22.04,AMD R7,openblas,dtype=complex128
  2. no warning message on mac-M1, openblas, dtype=float64

Reproduce the code example:

# python -c "import numpy as np; print(np.linalg.det(np.array([[0,1],[1,0]], dtype=np.complex128)))"
import numpy as np
print(np.linalg.det(np.array([[0,1],[1,0]], dtype=np.complex128)))
# (-1+0j) #still give correct results

Error message:

/Users/zhangc/miniconda3/envs/env00/lib/python3.11/site-packages/numpy/linalg/linalg.py:2180: RuntimeWarning: divide by zero encountered in det
  r = _umath_linalg.det(a, signature=signature)
/Users/zhangc/miniconda3/envs/env00/lib/python3.11/site-packages/numpy/linalg/linalg.py:2180: RuntimeWarning: invalid value encountered in det
  r = _umath_linalg.det(a, signature=signature)

Runtime information:

import sys, numpy
print(numpy.__version__); print(sys.version)
# 1.25.2
# 3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:33:12) [Clang 15.0.7 ]

Context for the issue:

Low priority, it gives the correct results.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions