Repository navigation
fix: Accept float64 positions in the Ritter bounding sphere - #85
Open
kylebarron wants to merge 1 commit into
Open
kylebarron wants to merge 1 commit into
kylebarron wants to merge 1 commit into
Conversation
The Ritter second pass is written in Cython and only accepts float32 arrays, so `bounding_sphere` with the default or `'ritter'` method raised `ValueError: Buffer dtype mismatch, expected 'float32_t' but got 'double'` for float64 positions. `encode` casts its input to float32, so this used to be unreachable from it. Under numpy 2's promotion rules (NEP 50), numpy scalars are no longer demoted to an array's dtype, so an `Ellipsoid` whose axes are numpy float64 scalars now makes `to_ecef` return float64, and `encode` fails. On numpy 1.26 the same call succeeds. Cast positions to float32 before the Ritter pass, which matches the precision it has always used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kylebarron
added this pull request to stack #91
October 5, 2026 21:52
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR was written by Claude (Claude Code), not by @kylebarron.
Fixes
encodefailing under numpy 2 when theEllipsoidaxes are numpyfloat64scalars.The bug
The Ritter bounding sphere's second pass is written in Cython and only accepts
float32.encodecasts its input tofloat32, so this used to be unreachable from it. Under numpy 2's promotion rules (NEP 50), numpy scalars are no longer demoted to the array's dtype, soto_ecefreturnsfloat64for such an ellipsoid and the Ritter pass rejects it. The same call works on numpy 1.26. Callingbounding_spheredirectly withfloat64positions fails on both versions.Fix
Cast positions to
float32before the Ritter pass. That's the precision it has always used, so output is unchanged.Tests
test_bounding_sphere_float64(default andrittermethods) andtest_encode_ellipsoid_numpy_scalars. All three fail without the fix and pass with it.🤖 Written by Claude Code