MCPcopy Index your code
hub / github.com/numpy/numpy / _fix_real_abs_gt_1

Function _fix_real_abs_gt_1

numpy/lib/_scimath_impl.py:153–178  ·  view source on GitHub ↗

Convert `x` to complex if it has real components x_i with abs(x_i)>1. Otherwise, output is just the array version of the input (via asarray). Parameters ---------- x : array_like Returns ------- array Examples -------- >>> import numpy as np >>> np.lib

(x)

Source from the content-addressed store, hash-verified

151
152
153def _fix_real_abs_gt_1(x):
154 """Convert `x` to complex if it has real components x_i with abs(x_i)>1.
155
156 Otherwise, output is just the array version of the input (via asarray).
157
158 Parameters
159 ----------
160 x : array_like
161
162 Returns
163 -------
164 array
165
166 Examples
167 --------
168 >>> import numpy as np
169 >>> np.lib.scimath._fix_real_abs_gt_1([0,1])
170 array([0, 1])
171
172 >>> np.lib.scimath._fix_real_abs_gt_1([0,2])
173 array([0.+0.j, 2.+0.j])
174 """
175 x = asarray(x)
176 if any(isreal(x) & (abs(x) > 1)):
177 x = _tocomplex(x)
178 return x
179
180
181def _unary_dispatcher(x):

Callers 3

arccosFunction · 0.85
arcsinFunction · 0.85
arctanhFunction · 0.85

Calls 4

anyFunction · 0.90
isrealFunction · 0.90
_tocomplexFunction · 0.85
asarrayFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…