Commit b44ac7d
committed
Replace the hotspots confidence ladder with boolean arithmetic (#3737)
_calc_hotspots_numpy classified each Gi* z-score through a nine-branch
if/elif ladder that recomputed abs(zscore) up to six times per cell.
The p-value step in that ladder never changed the output: every
p_value < threshold test is implied by the |z| test beside it, so the
whole thing reduces to 99 for |z| > 2.58, 95 for 1.96 < |z| <= 2.58,
90 for 1.65 < |z| <= 1.96, else 0.
Compute the confidence as 90*(az > 1.65) + 5*(az > 1.96) + 4*(az > 2.58)
and the sign as (z > 0) - (z < 0). On a 2000x4000 float64 z-score
array the classifier drops from ~18.1 ms to ~11.6 ms (random normal),
~18.3 ms to ~12.6 ms (smooth ramp) and ~18.9 ms to ~12.1 ms (10% NaN),
with identical int8 results. NaN still classifies to 0 and +/-inf to
+/-99.
Add tests pinning the classification at each threshold and its float64
neighbours at both signs, and for NaN, +/-inf and signed zeros. The
CUDA device function keeps the ladder.1 parent 1dbeb02 commit b44ac7d
2 files changed
Lines changed: 50 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1469 | 1469 | | |
1470 | 1470 | | |
1471 | 1471 | | |
1472 | | - | |
1473 | | - | |
1474 | | - | |
1475 | | - | |
1476 | | - | |
1477 | | - | |
1478 | | - | |
1479 | | - | |
1480 | | - | |
1481 | | - | |
1482 | | - | |
1483 | | - | |
1484 | | - | |
1485 | | - | |
1486 | | - | |
1487 | | - | |
1488 | | - | |
1489 | | - | |
1490 | | - | |
1491 | | - | |
1492 | | - | |
1493 | | - | |
1494 | | - | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
1495 | 1482 | | |
1496 | 1483 | | |
1497 | 1484 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1541 | 1541 | | |
1542 | 1542 | | |
1543 | 1543 | | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
1544 | 1584 | | |
1545 | 1585 | | |
1546 | 1586 | | |
| |||
0 commit comments