sparse icon indicating copy to clipboard operation
sparse copied to clipboard

wrong nanmean with complex64

Open dcherian opened this issue 1 year ago • 1 comments

Describe the bug np.nanmean of sparse array does not match numpy result

To Reproduce

import numpy as np
import sparse as sp

array = np.array([0. +0.j, 0.+np.nan * 1j], dtype=np.complex64)
sparray = sp.COO.from_numpy(array)

print("numpy:", np.nanmean(array), "sparse:", np.nanmean(sparray))
numpy: 0j sparse: (nan+nanj)

Expected behavior Match the numpy result

System

  • OS and version: [e.g. Windows 10] macOS latest
  • sparse version (sparse.__version__) 0.13.0
  • NumPy version (np.__version__) 1.22.4
  • Numba version (numba.__version__) 0.55.2

Additional context Seen when using hypothesis to test out array wrapping in xarray (https://github.com/pydata/xarray/pull/4972)

dcherian avatar Jul 23 '22 02:07 dcherian

Thanks for the report, I'll look into this.

hameerabbasi avatar Jul 23 '22 06:07 hameerabbasi

Thanks!

dcherian avatar Aug 17 '22 13:08 dcherian