MCPcopy Index your code
hub / github.com/pydata/xarray / imag

Function imag

xarray/namedarray/_array_api.py:81–111  ·  view source on GitHub ↗

Returns the imaginary component of a complex number for each element x_i of the input array x. Parameters ---------- x : NamedArray Input array. Should have a complex floating-point data type. Returns ------- out : NamedArray An array containing the

(
    x: NamedArray[_ShapeType, np.dtype[_SupportsImag[_ScalarType]]],  # type: ignore[type-var]
    /,
)

Source from the content-addressed store, hash-verified

79
80
81def imag(
82 x: NamedArray[_ShapeType, np.dtype[_SupportsImag[_ScalarType]]], # type: ignore[type-var]
83 /,
84) -> NamedArray[_ShapeType, np.dtype[_ScalarType]]:
85 """
86 Returns the imaginary component of a complex number for each element x_i of the
87 input array x.
88
89 Parameters
90 ----------
91 x : NamedArray
92 Input array. Should have a complex floating-point data type.
93
94 Returns
95 -------
96 out : NamedArray
97 An array containing the element-wise results. The returned array must have a
98 floating-point data type with the same floating-point precision as x
99 (e.g., if x is complex64, the returned array must have the floating-point
100 data type float32).
101
102 Examples
103 --------
104 >>> narr = NamedArray(("x",), np.asarray([1.0 + 2j, 2 + 4j]))
105 >>> imag(narr)
106 <xarray.NamedArray (x: 2)> Size: 16B
107 array([2., 4.])
108 """
109 xp = _get_data_namespace(x)
110 out = x._new(data=xp.imag(x._data))
111 return out
112
113
114def real(

Callers 1

imagMethod · 0.90

Calls 3

_get_data_namespaceFunction · 0.85
_newMethod · 0.45
imagMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…