-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Labels
Description
Describe the issue:
Hi,
I'm using bincount to sum up complex values. However, the method does not accept complex valued weights, however that would be a useful usecase for me.
Reproduce the code example:
import numpy as np
w = 1j * array([0.3, 0.5, 0.2, 0.7, 1., -0.6]) # weights
x = array([0, 1, 1, 2, 2, 2])
np.bincount(x, weights=w)
Error message:
Traceback (most recent call last):
File "/Users/user/PycharmProjects/project/venv/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3378, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-74-24012315fdf7>", line 5, in <module>
np.bincount(x, weights=w)
File "<__array_function__ internals>", line 180, in bincount
TypeError: Cannot cast array data from dtype('complex128') to dtype('float64') according to the rule 'safe'
Runtime information:
1.23.3
3.9.6 (default, Oct 18 2022, 12:41:40)
[Clang 14.0.0 (clang-1400.0.29.202)]
Context for the issue:
Happy to make a pull request myself (if I can do it), but I actually wasn't able to find the definition of the bincount method in the repo.