mikedh / trimesh

Python library for loading and using triangular meshes.
https://trimesh.org
MIT License
2.96k stars 576 forks source link

`tests/test_gltf.py::GLTFTest::test_vertex_colors_import` fails with NumPy 2.0.0rc2 #2237

Closed mgorny closed 2 months ago

mgorny commented 3 months ago

It seems that 4.4.1 introduced a new failure with NumPy 2. The test seems to pass with NumPy 1.

$ python -m pytest tests/test_gltf.py::GLTFTest::test_vertex_colors_import -vv
========================================================= test session starts =========================================================
platform linux -- Python 3.10.14, pytest-8.2.2, pluggy-1.5.0 -- /tmp/trimesh/.venv/bin/python
cachedir: .pytest_cache
rootdir: /tmp/trimesh
configfile: pyproject.toml
plugins: xdist-3.6.1
collected 1 item                                                                                                                      

tests/test_gltf.py::GLTFTest::test_vertex_colors_import FAILED                                                                  [100%]

============================================================== FAILURES ===============================================================
_________________________________________________ GLTFTest.test_vertex_colors_import __________________________________________________

self = <tests.test_gltf.GLTFTest testMethod=test_vertex_colors_import>

    def test_vertex_colors_import(self):
        # get a mesh with face colors
        m = g.get_mesh("cubevc.glb")
        assert len(m.geometry.items()) > 0

        mesh = next(iter(m.geometry.items()))[1]
        assert mesh is not None

        # Loaded mesh should have vertex colors
        assert hasattr(mesh.visual, "vertex_colors")

        # Loaded mesh should have all vertex colors filled with magenta color
        magenta = g.np.array([255, 0, 255, 255])
        for color in mesh.visual.vertex_colors:
            is_magenta = g.np.array_equal(color, magenta)
>           assert is_magenta, f"Imported vertex color is not of expected value: got {color}, expected {magenta}"
E           AssertionError: Imported vertex color is not of expected value: got [  1   0   1 255], expected [255   0 255 255]
E           assert False

tests/test_gltf.py:814: AssertionError
======================================================= short test summary info =======================================================
FAILED tests/test_gltf.py::GLTFTest::test_vertex_colors_import - AssertionError: Imported vertex color is not of expected value: got [  1   0   1 255], expected [255   0 255 255]
assert False
========================================================== 1 failed in 0.28s ==========================================================