Add regression test for numpy_num_face_vertices() fix (issue #400)#418
Add regression test for numpy_num_face_vertices() fix (issue #400)#418
numpy_num_face_vertices() fix (issue #400)#418Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…es() Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
numpy_num_face_vertices() fix (issue #400)
|
@copilot do python code format to solve the code format CI failures |
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a file-based Python regression test and corresponding OBJ fixture to ensure numpy_num_face_vertices() returns correct values (and dtype) for mixed face arity, covering issue #400.
Changes:
- Add
models/issue-400-num-face-vertices.objtest fixture with one quad and two triangles. - Add
test_numpy_num_face_vertices_from_fileto load the fixture viaLoader.load()and validatenumpy_num_face_vertices(). - Minor refactor in
test_loader.py(introduceMODELS_DIR; reformat expected index list).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/python/tinyobjloader_tests/test_loader.py | Adds a file-based regression test for numpy_num_face_vertices() and introduces MODELS_DIR for locating model fixtures. |
| models/issue-400-num-face-vertices.obj | Adds a minimal mixed-arity OBJ fixture for the regression test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Test: numpy_num_face_vertices() must return the same values with the correct dtype. | ||
| result = shape.mesh.numpy_num_face_vertices() | ||
| np.testing.assert_array_equal(result, expected_num_face_vertices) | ||
| assert result.dtype == np.dtype("uint32") |
There was a problem hiding this comment.
The dtype assertion is hard-coded to uint32, but numpy_num_face_vertices() is meant to expose C++ unsigned int (mesh_t::num_face_vertices), which maps to NumPy's platform-dependent np.uintc / dtype('uintc'). To keep this test portable across platforms, assert against np.dtype(np.uintc) (or np.dtype('uintc')) instead of always uint32.
| assert result.dtype == np.dtype("uint32") | |
| assert result.dtype == np.dtype(np.uintc) |
tests/python/tinyobjloader_tests/)models/issue-400-num-face-vertices.objwith quad/triangle facestest_loader.py(test_numpy_num_face_vertices_from_file) that loads the.objfile and verifiesnumpy_num_face_vertices()returns correct values with the right dtypepyproject.tomlsetsline-length = 140, so wrappednp.testing.assert_array_equalcalls should be on single lines🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.