You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When I try to compute
scipy.stats.wasserstein_distance(u,v) or scipy.stats.wasserstein_distance_nd(u,v) between distributions with complex samples, I get this warning:
/home/joao/mambaforge/envs/my-env/lib/python3.9/site-packages/scipy/stats/_stats_py.py:10628:
ComplexWarning: Casting complex values to real discards the imaginary part
Which means the distance is not happening between complex numbers, but between real numbers.
Describe the solution you'd like.
I'm not sure if this is the correct way of doing it, but I would like the distances to work normally for complex vectors. I tried the following changes, and they seem to be working.
Changing line 10628 in _stats_py.py from
values = np.asarray(values, dtype=float)
to:
if type(values) == np.ndarray and values.dtype in [np.complex64, np.complex128]:
pass
else:
values = np.asarray(values, dtype=float)
Describe alternatives you've considered.
I considered unfolding the complex into a 2*N vector with real and imaginary parts separated. But this will compute distances differently. Instead of shortest distances in the complex plane, it would sum the real distance with the imaginary.
(like summing the 2 sides of the rectangular triangle instead of the diagonal)the
Additional context (e.g. screenshots, GIFs)
No response
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
When I try to compute
scipy.stats.wasserstein_distance(u,v) or scipy.stats.wasserstein_distance_nd(u,v) between distributions with complex samples, I get this warning:
/home/joao/mambaforge/envs/my-env/lib/python3.9/site-packages/scipy/stats/_stats_py.py:10628:
ComplexWarning: Casting complex values to real discards the imaginary part
Which means the distance is not happening between complex numbers, but between real numbers.
Describe the solution you'd like.
I'm not sure if this is the correct way of doing it, but I would like the distances to work normally for complex vectors. I tried the following changes, and they seem to be working.
Changing line 10628 in _stats_py.py from
values = np.asarray(values, dtype=float)
to:
Describe alternatives you've considered.
I considered unfolding the complex into a 2*N vector with real and imaginary parts separated. But this will compute distances differently. Instead of shortest distances in the complex plane, it would sum the real distance with the imaginary.
(like summing the 2 sides of the rectangular triangle instead of the diagonal)the
Additional context (e.g. screenshots, GIFs)
No response
The text was updated successfully, but these errors were encountered: