fix(ga): Suppress divide-by-zero warning in NumPy solver #17

Merged
jono merged 1 commits from v0.4.1-dev into main 2025-10-27 16:26:58 +00:00

1 Commits

Author SHA1 Message Date
7c75000637 fix(ga): Suppress divide-by-zero warning in NumPy solver
All checks were successful
Publish Python Package to PyPI / deploy (push) Successful in 18s
Run Python Tests / test (3.12) (pull_request) Successful in 12s
Run Python Tests / test (3.10) (pull_request) Successful in 17s
Run Python Tests / test (3.8) (pull_request) Successful in 10s
The `_solve_x_numpy` method was correctly using `np.where(error == 0, ...)` to handle perfect roots. However, NumPy eagerly calculates `1.0 / error` for the entire array before applying the `where` condition, which was causing a `RuntimeWarning: divide by zero` when a perfect root was found.

This warning was harmless but created unnecessary console noise during testing and use.

This commit wraps the `ranks = ...` assignments in a `with np.errstate(divide='ignore'):` block to silence this specific, expected warning. The CUDA kernel is unaffected as its ternary operator already prevents this calculation.
2025-10-27 12:25:54 -04:00