fix: coerce numpy scalars in colmap write_next_bytes for NumPy 2.x - #3774
Open
f-dy wants to merge 1 commit into
Open
fix: coerce numpy scalars in colmap write_next_bytes for NumPy 2.x#3774f-dy wants to merge 1 commit into
f-dy wants to merge 1 commit into
Conversation
NumPy 2.x no longer implicitly converts a size-1 ndarray or a NumPy scalar to a Python scalar inside struct.pack, so writing COLMAP binary models (e.g. Point3D.error passed as np.array([0])) raised 'struct.error: required argument is not a float'. Coerce ndarray/generic to a Python scalar via .item() before packing. Fixes the failing tests/process_data/test_process_images.py cases.
f-dy
pushed a commit
to f-dy/nerfstudio
that referenced
this pull request
Jul 28, 2026
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.
Problem
buildCI (Core Tests) fails on current dependencies:NumPy 2.x no longer implicitly converts a size-1
ndarray(or a NumPy scalar) to a Python scalar insidestruct.pack. So writing a COLMAP binary model where a field is a NumPy array (e.g.Point3D.error = np.array([0])) now raises.Fix
Coerce
ndarray/np.genericto a Python scalar via.item()in the single-value branch ofwrite_next_bytesbefore packing. One-line, no behavior change on Python scalars/lists/tuples.Testing
Reproduced the failing path against the real module and confirmed write + round-trip read now succeed: