Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
39c39a6
Test Python + NumPy in CI
paulmelnikow Feb 18, 2026
5fe0344
Add comments
paulmelnikow Feb 19, 2026
af5bb21
Add more tests
paulmelnikow Feb 19, 2026
c392794
Add more Python tests
paulmelnikow Feb 19, 2026
54f3ef9
assert_array_almost_equal
paulmelnikow Feb 20, 2026
9ebc6a2
Try decimal=5
paulmelnikow Feb 20, 2026
24666b3
Try to fix vertex test
paulmelnikow Feb 20, 2026
b545df6
Update a comment
paulmelnikow Feb 20, 2026
addf431
Upgrade cibuildwheel
paulmelnikow Feb 20, 2026
79cf530
Fix toml
paulmelnikow Feb 20, 2026
03cfda8
Match the types and call buf.release()
paulmelnikow Feb 20, 2026
2296782
Rm buf.release()
paulmelnikow Feb 20, 2026
9d08abb
Try to clear license warning on build
paulmelnikow Feb 20, 2026
fc06cee
Fix license specifier
paulmelnikow Feb 20, 2026
a027b25
Merge branch 'upgrade-cibw' into numpy-fixes
paulmelnikow Feb 20, 2026
089b386
Move python tests out of python so they don’t end up in the wheel
paulmelnikow Feb 20, 2026
c6d987b
Add some excludes
paulmelnikow Feb 20, 2026
ff2e15b
Reformat and exclude some python files
paulmelnikow Feb 20, 2026
ecbd03b
Merge branch 'python-tests' into upgrade-cibw
paulmelnikow Feb 20, 2026
0101956
Merge branch 'upgrade-cibw' into numpy-fixes
paulmelnikow Feb 20, 2026
06f368c
Update .github/workflows/python.yml
paulmelnikow Feb 23, 2026
ada0c93
Add a note about local numpy install
paulmelnikow Feb 23, 2026
91768a8
Merge remote-tracking branch 'curvewise/python-tests' into python-tests
paulmelnikow Feb 23, 2026
d240cb0
Merge branch 'release' into python-tests
paulmelnikow Feb 23, 2026
b22dcbc
Merge branch 'python-tests' into numpy-fixes
paulmelnikow Feb 23, 2026
99ea28d
Reset a few files
paulmelnikow Feb 23, 2026
4d33a88
Initial plan
Copilot Mar 3, 2026
08c2bfd
Add regression test and .obj file for issue-400 numpy_num_face_vertic…
Copilot Mar 3, 2026
f86ce63
Fix black formatting with line-length=140 from pyproject.toml
Copilot Mar 3, 2026
6fd1061
Merge branch 'release' into copilot/sub-pr-408-again
syoyo Mar 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions models/issue-400-num-face-vertices.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Regression test model for issue #400 - numpy_num_face_vertices()
# Mixed quad and triangle faces to verify correct uint type handling.
# With the bug (unsigned char instead of unsigned int in the numpy binding),
# numpy_num_face_vertices() returned all zeros for quad (4-vertex) faces.
v 0.0 0.0 0.0
v 1.0 0.0 0.0
v 1.0 1.0 0.0
v 0.0 1.0 0.0
v 0.5 0.5 1.0
# quad face (num_face_vertices = 4)
f 1 2 3 4
# triangle face (num_face_vertices = 3)
f 1 2 5
# triangle face (num_face_vertices = 3)
f 2 3 5
61 changes: 60 additions & 1 deletion tests/python/tinyobjloader_tests/test_loader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from pathlib import Path

import numpy as np

from .loader import Loader, LoadException

MODELS_DIR = Path(__file__).parent.parent.parent.parent / "models"

TWO_QUADS = """
v 0 0 0
v 0 0 0
Expand Down Expand Up @@ -130,7 +134,32 @@ def test_numpy_index_array_two_quads():
assert [x.vertex_index for x in shape.mesh.indices] == expected_vertex_index

# Test.
expected_numpy_indices = [0, -1, -1, 1, -1, -1, 2, -1, -1, 3, -1, -1, 4, -1, -1, 5, -1, -1, 6, -1, -1, 7, -1, -1]
expected_numpy_indices = [
0,
-1,
-1,
1,
-1,
-1,
2,
-1,
-1,
3,
-1,
-1,
4,
-1,
-1,
5,
-1,
-1,
6,
-1,
-1,
7,
-1,
-1,
]
np.testing.assert_array_equal(shape.mesh.numpy_indices(), expected_numpy_indices)


Expand Down Expand Up @@ -174,3 +203,33 @@ def test_numpy_vertex_array_two_quads():

# Test.
np.testing.assert_array_almost_equal(loader.attrib.numpy_vertices(), expected_vertices, decimal=6)


def test_numpy_num_face_vertices_from_file():
"""
Regression test for https://github.com/tinyobjloader/tinyobjloader/issues/400

Loads a mixed quad/triangle mesh from a .obj file and checks that
numpy_num_face_vertices() returns correct unsigned int values.
With the bug (unsigned char element type), values were read as zeros.
"""

# Set up.
obj_path = str(MODELS_DIR / "issue-400-num-face-vertices.obj")
loader = Loader(triangulate=False)
loader.load(obj_path)

shapes = loader.shapes
assert len(shapes) == 1

(shape,) = shapes
# The file has one quad face (4 vertices) and two triangle faces (3 vertices each).
expected_num_face_vertices = [4, 3, 3]

# Confidence check using the non-numpy accessor.
assert shape.mesh.num_face_vertices == expected_num_face_vertices

# 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")
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
assert result.dtype == np.dtype("uint32")
assert result.dtype == np.dtype(np.uintc)

Copilot uses AI. Check for mistakes.
Loading