Repository navigation
fix(geometry): accept path-like filenames in PLY point-cloud I/O - #5092
Merged
Merged
Conversation
The PLY savers and loaders now accept os.PathLike[str], so the message 'must be a string with the .ply extension' misdescribes the contract when a Path with another suffix is passed. Pin the new wording in test_invalid_filename_extension, and say in the changelog fragment what used to happen and that the case-insensitive suffix check is not new.
ducha-aiki
approved these changes
Sep 29, 2026
ducha-aiki
left a comment
Member
There was a problem hiding this comment.
Thanks. This fixes #5072 as the issue proposed: os.fspath first, then the same suffix and missing-file checks. I checked it on main a30540a with torch 2.14.0 (macOS arm64, CPU and MPS). I pushed one small commit on top, 0f7867b, which changes the error message and the changelog wording. Please pull before you push again. Details below; I'm approving with it.
What I verified
- The issue's repro passes. A
pathlib.Pathand a customos.PathLike[str]now save and load in all four functions. On main they raisedTypeError. - Rejected inputs still raise
TypeError, for every input I tried, in all four functions:1234,Noneand a list: the exception type is unchanged, but the message is now Python's ownexpected str, bytes or os.PathLike object, not int. That's fine.bytesand a bytesPathLike:os.fspathreturnsbytes, theisinstance(filename, str)check rejects it, and the message is kornia's, as on main.- a
__fspath__that returns anint:os.fspathraisesTypeError. - a
Pathending in.txt. - A
Pathnaming a missing.plyfile still raisesValueErrorin the loaders.
.PLYis not a behaviour change. Main already accepted"x.PLY"as astr(.lower()), and the PR keeps that.- The output bytes are unchanged. For the same points, the ASCII and binary files have the same SHA-256 on main and here. A file saved through a
Pathor a customPathLikeis byte-identical to the same save through astr. The writers are untouched, so nothing new happens with line endings on Windows. Your byte comparison checks two outputs of the same writer, and the Windows leg passes. - Tests. Your new class fails on main (52 failed: 48
test_pathlike_filename_5072and 4test_missing_file) and passes here. The two tests you removed fromTestSaveLoadPointCloud(1234and"pointcloud.txt"to the ASCII saver) are covered by the new parametrized ones, which run all four functions. The file passes on CPU float32/float64, float16/bfloat16 under their known-failure profiles, and MPS float32. The half-precision RNG audit passes too. - Mutants. Each of the four new
os.fspathlines, when dropped, fails 12–14 tests, andstr(filename)in its place fails 6–7. Dropping.lower()or theisfilecheck fails 6–42 tests. Droppingisinstance(filename, str)survives, but the mutant is equivalent: afteros.fspathit only seesbytes, andbytes.lower().endswith(".ply")raisesTypeErroranyway.
What I changed (0f7867b)
- Error message. It said
Input filename must be a string with the .ply extension, sosave_pointcloud_ply(Path("points.txt"), ...)told the caller to pass a string. It now readsInput filename must be a str or os.PathLike[str] with the .ply extension, in both savers and_check_ply_filename.test_invalid_filename_extensionmatches that wording instead of"extension". - Changelog. The fragment now says these filenames raised
TypeErrorbefore. It also says the case-insensitive.plycheck is the one strings already had, so "including case-insensitive.plyextensions" doesn't read as a new feature.
Our docs PR #5069
#5069 documents this defect, so it conflicts in kornia/geometry/pointcloud.py. This PR merges first, and we'll update #5069 afterwards; nothing for you to do.
Posted on behalf of @ducha-aiki by Claude (Opus 5.5).
ducha-aiki
enabled auto-merge (squash)
September 29, 2026 13:53
ducha-aiki
added a commit
that referenced
this pull request
Sep 30, 2026
Resolve keypoints.py (keep the #5122 NotImplementedError messages under the batch-10b docstrings) and pointcloud.py (keep os.PathLike from #5092 under the Convention block). Drop the wart pins and prose that main fixed: #5072 (PLY path-like filenames, #5092) and #5062 (float16 zero vector, #5084); 13 pins.
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.
What does this pull request do?
The four PLY save/load functions reject valid
pathlib.Pathobjects because their filename checks only accept strings. Normalize filenames withos.fspathand acceptstr | os.PathLike[str], keeping the existing extension and missing-file checks. Parsing, serialization, and tensor handling are unchanged.Regression tests cover strings,
Path, custom string-backed path objects,.ply/.PLY, Path saving with string loading and the reverse, known coordinates, byte-identical serialization, invalid inputs, and missing files. Updates the filename docstrings and addschangelog.d/5092.fixed.md.Related issue or discussion
Fixes #5072.
Checked #5069: it remains unmerged, so its Path-rejection warning and test have not landed on
main. Those need reconciliation if it merges first.What did you check?
Python 3.12.13 / PyTorch 2.14.0 on macOS arm64, importing this checkout. The new regression class failed before the implementation change: 52 failed, 52 passed.
CUDA was unavailable. The full test suite and documentation build were not run. Gradient/compilation checks were not run because this change only handles filenames in file-I/O functions.
How did AI help?
Codex investigated the issue and related PR, implemented the fix and regression tests, reviewed the diff, and ran the checks above.