summaryrefslogtreecommitdiff
path: root/numpy/lib/scimath.py
diff options
context:
space:
mode:
authorMuhammad Motawe <muhammad.a.motawe@gmail.com>2021-10-30 16:44:37 +0000
committerMuhammad Motawe <muhammad.a.motawe@gmail.com>2021-10-30 17:11:28 +0000
commitfce2a361dad67566a6252553492239ec7b0c916d (patch)
treef3fd363c09dbc353e7606d017bd8812b99c89bee /numpy/lib/scimath.py
parent7c512e05192376ae118f9c2a05faf0fe50673aa4 (diff)
downloadnumpy-fce2a361dad67566a6252553492239ec7b0c916d.tar.gz
DOC: Clarify behavior of np.lib.scimath.sqrt in the presence of negative 0
Diffstat (limited to 'numpy/lib/scimath.py')
-rw-r--r--numpy/lib/scimath.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/lib/scimath.py b/numpy/lib/scimath.py
index 308f1328b..afaf4b4c9 100644
--- a/numpy/lib/scimath.py
+++ b/numpy/lib/scimath.py
@@ -234,6 +234,20 @@ def sqrt(x):
>>> np.emath.sqrt([-1,4])
array([0.+1.j, 2.+0.j])
+ Different results are expected because:
+ floating point 0.0 and -0.0 are distinct.
+
+ For more control, explicitly use complex() as follows:
+
+ >>> np.emath.sqrt(complex(-4.0, 0.0))
+ 2j
+ >>> np.emath.sqrt(complex(-4.0, -0.0))
+ -2j
+
+
+
+
+
"""
x = _fix_real_lt_zero(x)
return nx.sqrt(x)