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)
| 165 | |
| 166 | |
| 167 | def _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 | |
| 194 | def _unary_dispatcher(x): |