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

Skip to content

Commit eab5228

Browse files
committed
BUG: fix cpow tests to match what npy_cpow does.
Annex G of the C99 standard does not define any special values for cpow, allowing the implementation to be as simple as cpow(z,w) = cexp(w*clog(z)). We have a large number of tests for our cpow function, both in the test suite and in test_c99complex.c. (There are actually more in test_c99complex.c, since I'm doing all combinations from TestCpow::test_scalar in test_umath_complex.py.) As of right now, these tests probably mean that we will never use a system cpow implemenation. This is fine, since we handle a large number of edge cases in a sane way and at least glibc does not. With this commit all 48 of our complex functions pass test_c99complex.c.
1 parent c8f13ee commit eab5228

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

numpy/core/test_c99complex.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ int test_cpow()
14581458

14591459
TEST_CPOW_CC(0, 1, 1, 0, 0, 1);
14601460
TEST_CPOW_CC(0, 1, 0, 1, ADDSUFFIX(exp)(-NPY_PI_2), 0);
1461-
TEST_CPOW_CC(0, 1, -0.5, 1.5, 0.067019739708273365, 0.067019739708273365);
1461+
TEST_CPOW_CC(0, 1, -0.5, 1.5, 0.067019739708273365, -0.067019739708273365);
14621462
TEST_CPOW_CC(0, 1, 2, 0, -1, 0);
14631463
TEST_CPOW_CC(0, 1, 3, 0, 0, -1);
14641464

@@ -1473,13 +1473,13 @@ int test_cpow()
14731473
TEST_CPOW_CC(2.5, 0.375, 2, 0, 391.0/64.0, 15.0/8.0);
14741474
TEST_CPOW_CC(2.5, 0.375, 3, 0, 1865.0/128.0, 3573.0/512.0);
14751475

1476-
TEST_CPOW_EE(INFINITY, 0, 1, 0, NAN, NAN);
1476+
TEST_CPOW_EE(INFINITY, 0, 1, 0, INFINITY, 0);
14771477
TEST_CPOW_EE(INFINITY, 0, 0, 1, NAN, NAN);
1478-
TEST_CPOW_EE(INFINITY, 0, -0.5, 1.5, NAN, NAN);
1479-
TEST_CPOW_EE(INFINITY, 0, 2, 0, NAN, NAN);
1478+
TEST_CPOW_EE(INFINITY, 0, -0.5, 1.5, 0, 0);
1479+
TEST_CPOW_EE(INFINITY, 0, 2, 0, INFINITY, NAN);
14801480
TEST_CPOW_EE(INFINITY, 0, 3, 0, NAN, NAN);
14811481

1482-
TEST_CPOW_EE(NAN, 0, 1, 0, NAN, NAN);
1482+
TEST_CPOW_EE(NAN, 0, 1, 0, NAN, 0);
14831483
TEST_CPOW_EE(NAN, 0, 0, 1, NAN, NAN);
14841484
TEST_CPOW_EE(NAN, 0, -0.5, 1.5, NAN, NAN);
14851485
TEST_CPOW_EE(NAN, 0, 2, 0, NAN, NAN);

0 commit comments

Comments
 (0)