m0g3r commented on code in PR #3808:
URL: https://github.com/apache/iceberg-python/pull/3808#discussion_r3838118008
##########
tests/avro/test_decoder.py:
##########
@@ -160,6 +160,23 @@ def test_read_double(decoder_class: Callable[[bytes],
BinaryDecoder]) -> None:
assert decoder.read_double() == 19.25
[email protected]("decoder_class", AVAILABLE_DECODERS)
[email protected](
+ "value",
+ [
+ 3.141592653589793,
+ 429496729622.314,
+ 0.1,
+ 1.0000000000000002, # smallest double above 1.0
+ 1e308, # overflows to inf in single precision
+ 5e-324, # underflows to 0.0 in single precision
+ ],
+)
+def test_read_double_keeps_full_precision(decoder_class: Callable[[bytes],
BinaryDecoder], value: float) -> None:
Review Comment:
Thanks for checking. The test does fail on the unfixed tree, but only if the
Cython extension is actually rebuilt — and `setup.py` makes that easy to miss.
The `cythonize` call is wrapped in `try/except Exception` with
`allowed_to_fail = os.environ.get("CIBUILDWHEEL", "0") != "1"`, so if the
interpreter running it can't import Cython, `ext_modules` stays `[]` and
`build_ext --inplace` prints `running build_ext`, exits 0, and builds nothing.
The previously built `decoder_fast.*.so` stays on disk with the fix compiled
into it, and the test passes against that stale artifact.
Reverting the source and forcing a real rebuild:
```console
$ git checkout HEAD~1 -- pyiceberg/avro/decoder_fast.pyx # back to cpdef
float
$ .venv/bin/python setup.py build_ext --inplace
Compiling pyiceberg/avro/decoder_fast.pyx because it changed.
building 'pyiceberg.avro.decoder_fast' extension
$ .venv/bin/python -m pytest tests/avro/test_decoder.py -k full_precision -q
6 failed, 6 passed, 44 deselected
```
All six failures are the `CythonBinaryDecoder` parameters. The six
`StreamingBinaryDecoder` ones pass, which is expected — the pure-Python decoder
was always correct. Decoded values on the unfixed build:
```
3.141592653589793 -> 3.1415927410125732
1e+308 -> inf
5e-324 -> 0.0
```
With the fix restored and rebuilt, `tests/avro/test_decoder.py` is 56 passed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]