diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/lib/type_check.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/numpy/lib/type_check.py b/numpy/lib/type_check.py index 13db9adc3..2a2982ab3 100644 --- a/numpy/lib/type_check.py +++ b/numpy/lib/type_check.py @@ -492,7 +492,8 @@ def _real_if_close_dispatcher(a, tol=None): @array_function_dispatch(_real_if_close_dispatcher) def real_if_close(a, tol=100): """ - If complex input returns a real array if complex parts are close to zero. + If input is complex with all imaginary parts close to zero, return + real parts. "Close to zero" is defined as `tol` * (machine epsilon of the type for `a`). @@ -527,10 +528,10 @@ def real_if_close(a, tol=100): >>> np.finfo(float).eps 2.2204460492503131e-16 # may vary - >>> np.real_if_close([2.1 + 4e-14j], tol=1000) - array([2.1]) - >>> np.real_if_close([2.1 + 4e-13j], tol=1000) - array([2.1+4.e-13j]) + >>> np.real_if_close([2.1 + 4e-14j, 5.2 + 3e-15j], tol=1000) + array([2.1, 5.2]) + >>> np.real_if_close([2.1 + 4e-13j, 5.2 + 3e-15j], tol=1000) + array([2.1+4.e-13j, 5.2 + 3e-15j]) """ a = asanyarray(a) |