I am trying to make a real number complex using numpy. I am using numpy version 1.24.3
Here is the code:
import numpy as np
c=np.complex(1)
However, I get this error:
AttributeError: module 'numpy' has no attribute 'complex'.
np.complex
was a deprecated alias for the builtin complex
.
Instead of np.complex
you can use:
complex(1) #output (1+0j)
#or
np.complex128(1) #output (1+0j)
#or
np.complex_(1) #output (1+0j)
#or
np.cdouble(1) #output (1+0j)
Link to doc: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations