(self)
| 451 | assert_equal(result.imag, ex[1]) |
| 452 | |
| 453 | def test_branches(self): |
| 454 | with np.errstate(all="ignore"): |
| 455 | for t in [np.complex64, np.complex128]: |
| 456 | # tupled (numerator, denominator, expected) |
| 457 | # for testing as expected == numerator/denominator |
| 458 | data = [] |
| 459 | |
| 460 | # trigger branch: real(fabs(denom)) > imag(fabs(denom)) |
| 461 | # followed by else condition as neither are == 0 |
| 462 | data.append((( 2.0, 1.0), ( 2.0, 1.0), (1.0, 0.0))) |
| 463 | |
| 464 | # trigger branch: real(fabs(denom)) > imag(fabs(denom)) |
| 465 | # followed by if condition as both are == 0 |
| 466 | # is performed in test_zero_division(), so this is skipped |
| 467 | |
| 468 | # trigger else if branch: real(fabs(denom)) < imag(fabs(denom)) |
| 469 | data.append(((1.0, 2.0), (1.0, 2.0), (1.0, 0.0))) |
| 470 | |
| 471 | for cases in data: |
| 472 | n = cases[0] |
| 473 | d = cases[1] |
| 474 | ex = cases[2] |
| 475 | result = t(complex(n[0], n[1])) / t(complex(d[0], d[1])) |
| 476 | # check real and imag parts separately to avoid comparison |
| 477 | # in array context, which does not account for signed zeros |
| 478 | assert_equal(result.real, ex[0]) |
| 479 | assert_equal(result.imag, ex[1]) |
| 480 | |
| 481 | |
| 482 | class TestConversion: |
nothing calls this directly
no test coverage detected