Skip to content

Commit 0bc4743

Browse files
lmeyerovclaude
andcommitted
fix(gfql/cypher): round() — symmetric errstate over the p=0 branch (wave-4 suggestion)
±inf input warns identically on the p=0 tie subtract; hoist one errstate over both branches (values unchanged, all guarded). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e58bc03 commit 0bc4743

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

graphistry/compute/gfql/row/pipeline.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,17 +1413,17 @@ def _floor_series(s: Any) -> Any:
14131413
import numpy as np
14141414
return np.floor(s)
14151415

1416-
if ndigits == 0:
1417-
fl = _floor_series(f)
1418-
out = fl + ((f - fl) >= 0.5).astype(float) # ties toward +inf
1419-
else:
1420-
import numpy as np
1421-
scale = 10.0 ** ndigits
1422-
with np.errstate(over="ignore", invalid="ignore"):
1423-
# |x·10^p| may legitimately overflow to inf, and the
1424-
# follow-on a-fl is then inf-inf=NaN — both guarded to
1425-
# identity below; suppress the RuntimeWarning noise
1426-
# (wave-3: over= alone still warned on the subtract).
1416+
import numpy as np
1417+
with np.errstate(over="ignore", invalid="ignore"):
1418+
# ±inf input makes the tie subtract inf-inf=NaN on EITHER
1419+
# branch, and p>0's scale multiply may overflow to inf —
1420+
# every such row is guarded to the correct identity below;
1421+
# suppress the benign RuntimeWarning noise (waves 3-4).
1422+
if ndigits == 0:
1423+
fl = _floor_series(f)
1424+
out = fl + ((f - fl) >= 0.5).astype(float) # ties toward +inf
1425+
else:
1426+
scale = 10.0 ** ndigits
14271427
shifted = f * scale
14281428
a = shifted.abs()
14291429
fl = _floor_series(a)

0 commit comments

Comments
 (0)