This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: cmath.phase array support
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: kolibril13, mark.dickinson
Priority: normal Keywords:

Created on 2019-07-25 06:41 by kolibril13, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg348428 - (view) Author: Hendrik (kolibril13) Date: 2019-07-25 06:41
It would be nice if cmath.phase supports arrays like this: 
```
import cmath
import numpy as np

z=255*np.ones((3,3)) * np.exp(1j * np.pi*np.ones((3,3)))

def get_k_amp_array(z):
    return abs(z)

def get_k_ph_array(z):
    return np.array([[cmath.phase(z_row) for z_row in z_col] for z_col in z ])

amp_array=  get_k_amp_array(z)
ph_array=   get_k_ph_array(z)

print(amp_array)
print(ph_array)
```
msg348481 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2019-07-26 07:52
I think you want numpy.angle (https://docs.scipy.org/doc/numpy/reference/generated/numpy.angle.html).

NumPy is a third-party library, so it doesn't make sense to have the math or cmath functions be aware of NumPy arrays; none of the other math or cmath functions work on arrays. Generally for this sort of thing you want to look for a solution in NumPy or SciPy.
History
Date User Action Args
2022-04-11 14:59:18adminsetgithub: 81857
2019-07-26 07:52:17mark.dickinsonsetstatus: open -> closed
resolution: rejected
messages: + msg348481

stage: resolved
2019-07-25 08:11:21xtreaksetnosy: + mark.dickinson

versions: + Python 3.9, - Python 3.7
2019-07-25 06:41:14kolibril13create