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]
/,
)
| 79 | |
| 80 | |
| 81 | def 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 | |
| 114 | def real( |
no test coverage detected
searching dependent graphs…