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)
| 151 | |
| 152 | |
| 153 | def _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 | |
| 181 | def _unary_dispatcher(x): |