MCPcopy Create free account
hub / github.com/numpy/numpy / _fix_real_abs_gt_1

Function _fix_real_abs_gt_1

numpy/lib/scimath.py:167–191  ·  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 -------- >>> np.lib.scimath._fix_real_abs_gt_1

(x)

Source from the content-addressed store, hash-verified

165
166
167def _fix_real_abs_gt_1(x):
168 """Convert `x` to complex if it has real components x_i with abs(x_i)>1.
169
170 Otherwise, output is just the array version of the input (via asarray).
171
172 Parameters
173 ----------
174 x : array_like
175
176 Returns
177 -------
178 array
179
180 Examples
181 --------
182 >>> np.lib.scimath._fix_real_abs_gt_1([0,1])
183 array([0, 1])
184
185 >>> np.lib.scimath._fix_real_abs_gt_1([0,2])
186 array([0.+0.j, 2.+0.j])
187 """
188 x = asarray(x)
189 if any(isreal(x) & (abs(x) > 1)):
190 x = _tocomplex(x)
191 return x
192
193
194def _unary_dispatcher(x):

Callers 3

arccosFunction · 0.85
arcsinFunction · 0.85
arctanhFunction · 0.85

Calls 5

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

Tested by

no test coverage detected