3

Are there any differences between the

cmath.phase()

function from the cmath module, and the

np.angle()

function from numpy.

AGN Gazer
  • 8,025
  • 2
  • 27
  • 45
pew31
  • 61
  • 1
  • 5

1 Answers1

5

Mathematically, there is no difference between these two functions. Both compute the phase or argument of a complex number as:

arg = arctan2(zimag, zreal)

See documentation for cmath.phase and source code for numpy.angle. From software point of view, as @Julien mentioned in his comment, cmath.phase() will not work on numpy.ndarray.

AGN Gazer
  • 8,025
  • 2
  • 27
  • 45