Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 330b54a

Browse files
committed
BUG: Py3 '-2j' is (NZERO - 2j) causes test failures
On python2.x evaluating '-2j' produces complex(0,-2), however, on python3, it instead produces complex(NZERO, -2). This ends up causing a test for the complex arctan to fail. This happens I suppose for the same reason it does in C. The expression -2j ends up being evaluated as (-2 + 0j) * (0 + 1j) == (-0 + -2j).
1 parent 36e0d8b commit 330b54a

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

numpy/core/tests/test_umath.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,22 +1120,22 @@ def test_branch_cuts(self):
11201120
yield _check_branch_cut, np.log1p, -1.5, 1j, 1, -1
11211121
yield _check_branch_cut, np.sqrt, -0.5, 1j, 1, -1
11221122

1123-
yield _check_branch_cut, np.arcsin, [ -2, 2], [1j, -1j], 1, -1
1124-
yield _check_branch_cut, np.arccos, [ -2, 2], [1j, -1j], 1, -1
1125-
yield _check_branch_cut, np.arctan, [-2j, 2j], [1, 1 ], -1, 1
1123+
yield _check_branch_cut, np.arcsin, [ -2, 2], [1j, 0-1j], 1, -1
1124+
yield _check_branch_cut, np.arccos, [ -2, 2], [1j, 0-1j], 1, -1
1125+
yield _check_branch_cut, np.arctan, [0-2j, 2j], [1, 1 ], -1, 1
11261126

1127-
yield _check_branch_cut, np.arcsinh, [-2j, 2j], [-1, 1], -1, 1
1127+
yield _check_branch_cut, np.arcsinh, [0-2j, 2j], [-1, 1], -1, 1
11281128
yield _check_branch_cut, np.arccosh, [ -1, 0.5], [1j, 1j], 1, -1
11291129
yield _check_branch_cut, np.arctanh, [ -2, 2], [1j, 1j], 1, -1
11301130

11311131
# check against bogus branch cuts: assert continuity between quadrants
1132-
yield _check_branch_cut, np.arcsin, [-2j, 2j], [ 1, 1], 1, 1
1133-
yield _check_branch_cut, np.arccos, [-2j, 2j], [ 1, 1], 1, 1
1132+
yield _check_branch_cut, np.arcsin, [0-2j, 2j], [ 1, 1], 1, 1
1133+
yield _check_branch_cut, np.arccos, [0-2j, 2j], [ 1, 1], 1, 1
11341134
yield _check_branch_cut, np.arctan, [ -2, 2], [1j, 1j], 1, 1
11351135

11361136
yield _check_branch_cut, np.arcsinh, [ -2, 2, 0], [1j, 1j, 1 ], 1, 1
1137-
yield _check_branch_cut, np.arccosh, [-2j, 2j, 2], [1, 1, 1j], 1, 1
1138-
yield _check_branch_cut, np.arctanh, [-2j, 2j, 0], [1, 1, 1j], 1, 1
1137+
yield _check_branch_cut, np.arccosh, [0-2j, 2j, 2], [1, 1, 1j], 1, 1
1138+
yield _check_branch_cut, np.arctanh, [0-2j, 2j, 0], [1, 1, 1j], 1, 1
11391139

11401140
@dec.knownfailureif(True, "These branch cuts are known to fail")
11411141
def test_branch_cuts_failing(self):
@@ -1149,8 +1149,8 @@ def test_branch_cuts_failing(self):
11491149
yield _check_branch_cut, np.sqrt, -0.5, 1j, 1, -1, True
11501150
yield _check_branch_cut, np.arcsin, [ -2, 2], [1j, -1j], 1, -1, True
11511151
yield _check_branch_cut, np.arccos, [ -2, 2], [1j, -1j], 1, -1, True
1152-
yield _check_branch_cut, np.arctan, [-2j, 2j], [1, 1 ], -1, 1, True
1153-
yield _check_branch_cut, np.arcsinh, [-2j, 2j], [-1, 1], -1, 1, True
1152+
yield _check_branch_cut, np.arctan, [0-2j, 2j], [1, 1 ], -1, 1, True
1153+
yield _check_branch_cut, np.arcsinh, [0-2j, 2j], [-1, 1], -1, 1, True
11541154
yield _check_branch_cut, np.arccosh, [ -1, 0.5], [1j, 1j], 1, -1, True
11551155
yield _check_branch_cut, np.arctanh, [ -2, 2], [1j, 1j], 1, -1, True
11561156

0 commit comments

Comments
 (0)