Skip to content

Commit 33652e7

Browse files
lmeyerovclaude
andcommitted
fix(gfql/cypher): round() wave-3 — widen errstate over the guarded overflow window
over= alone still warned on the inf-inf subtract (invalid value encountered); values unaffected (both guarded to identity). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5625dc9 commit 33652e7

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

graphistry/compute/gfql/row/pipeline.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,17 +1419,19 @@ def _floor_series(s: Any) -> Any:
14191419
else:
14201420
import numpy as np
14211421
scale = 10.0 ** ndigits
1422-
with np.errstate(over="ignore"):
1423-
# |x·10^p| may legitimately overflow to inf (guarded to
1424-
# identity below) — suppress the RuntimeWarning noise.
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).
14251427
shifted = f * scale
1426-
a = shifted.abs()
1427-
fl = _floor_series(a)
1428-
mag = fl + ((a - fl) >= 0.5).astype(float) # ties away from zero
1429-
sig = (shifted > 0).astype(float) - (shifted < 0).astype(float)
1430-
out = mag * sig / scale + 0.0 # +0.0 normalizes -0.0
1431-
# scaled overflow (|x·10^p| = inf): rounding is the identity
1432-
out = out.where(a != float("inf"), f)
1428+
a = shifted.abs()
1429+
fl = _floor_series(a)
1430+
mag = fl + ((a - fl) >= 0.5).astype(float) # ties away
1431+
sig = (shifted > 0).astype(float) - (shifted < 0).astype(float)
1432+
out = mag * sig / scale + 0.0 # +0.0 normalizes -0.0
1433+
# scaled overflow (|x·10^p| = inf): rounding is the identity
1434+
out = out.where(a != float("inf"), f)
14331435
return True, out.where(~null_mask, pd.NA)
14341436
if is_null_scalar(inner):
14351437
return True, None

0 commit comments

Comments
 (0)