SIGN IN SIGN UP

Reject non-integral float-like values (numpy floats) for integer parameters (#146)

* Reject non-integral float-like values for integer parameters

The non-integral rejection added in fb5cce6 only covered exact Python
floats: Runtime.PyFloat_Check compares the type pointer, so float
subclasses such as numpy.float64 and __float__-only numbers such as
numpy.float32 bypassed the guard in Converter.ToPrimitive and fell
through to PyNumber_Long/__int__, silently truncating the value (e.g.
SimpleMovingAverage(np.float64(20.5)) built a period-20 indicator).

Extend the guard to any float-like value: Python floats including
subclasses, and numbers that define __float__ but no __index__. True
integer types advertising __index__ (numpy.int64/int32) and plain ints
are unaffected, and integral-valued floats (20.0) keep converting.

Adds embed tests with float-subclass / __float__-only / __index__
fixtures and a numpy-backed python test over ConversionTest fields and
method binding.

* Tighten comments in float-like integer conversion guard and tests
J
Jhonathan Abreu committed
cc517949157bf5d49c5b3c2d4d3f5236eb9e4ec4
Parent: ad87b8f
Committed by GitHub <noreply@github.com> on 8/12/2026, 8:32:51 PM