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

Function real

xarray/namedarray/_array_api.py:114–144  ·  view source on GitHub ↗

Returns the real 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 elem

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

Source from the content-addressed store, hash-verified

112
113
114def real(
115 x: NamedArray[_ShapeType, np.dtype[_SupportsReal[_ScalarType]]], # type: ignore[type-var]
116 /,
117) -> NamedArray[_ShapeType, np.dtype[_ScalarType]]:
118 """
119 Returns the real component of a complex number for each element x_i of the
120 input array x.
121
122 Parameters
123 ----------
124 x : NamedArray
125 Input array. Should have a complex floating-point data type.
126
127 Returns
128 -------
129 out : NamedArray
130 An array containing the element-wise results. The returned array must have a
131 floating-point data type with the same floating-point precision as x
132 (e.g., if x is complex64, the returned array must have the floating-point
133 data type float32).
134
135 Examples
136 --------
137 >>> narr = NamedArray(("x",), np.asarray([1.0 + 2j, 2 + 4j]))
138 >>> real(narr)
139 <xarray.NamedArray (x: 2)> Size: 16B
140 array([1., 2.])
141 """
142 xp = _get_data_namespace(x)
143 out = x._new(data=xp.real(x._data))
144 return out
145
146
147# %% Manipulation functions

Callers 1

realMethod · 0.90

Calls 3

_get_data_namespaceFunction · 0.85
_newMethod · 0.45
realMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…