MCPcopy
hub / github.com/numpy/numpy / _to_real_if_imag_zero

Function _to_real_if_imag_zero

numpy/linalg/_linalg.py:189–198  ·  view source on GitHub ↗

Backwards compat helper: force w to be real if t.dtype is real and w.imag == 0

(w, t)

Source from the content-addressed store, hash-verified

187
188
189def _to_real_if_imag_zero(w, t):
190 """Backwards compat helper: force w to be real if t.dtype is real and w.imag == 0
191 """
192 result_t = t.dtype.type
193 if not isComplexType(result_t) and all(w.imag == 0.0):
194 w = w.real
195 result_t = _realType(result_t)
196 else:
197 result_t = _complexType(result_t)
198 return w.astype(result_t, copy=False)
199
200
201def _commonType(*arrays):

Callers 4

rootsFunction · 0.90
lagrootsFunction · 0.90
polyrootsFunction · 0.90
hermrootsFunction · 0.90

Calls 5

allFunction · 0.90
isComplexTypeFunction · 0.85
_realTypeFunction · 0.85
_complexTypeFunction · 0.85
astypeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…