clemense / yourdfpy

Python parser for URDFs
MIT License
122 stars 13 forks source link

Attribute error about removal of ptp in NumPy 2.0 #55

Open stephane-caron opened 2 months ago

stephane-caron commented 2 months ago

Along with the release of robot_descriptions.py 1.11.0, I found two upstream dependencies were affected by the API-breaking changes in NumPy 2.0. One of them is yourdfpy, where loading a URDF fails with:

AttributeError: `ptp` was removed from the ndarray class in NumPy 2.0. Use np.ptp(arr, ...) instead.

Full traceback:

24-06-27T09:16:19.2527715Z ERROR: test_a1_description (test_yourdfpy.TestYourdfpy)
2024-06-27T09:16:19.2528856Z ----------------------------------------------------------------------
2024-06-27T09:16:19.2529614Z Traceback (most recent call last):
2024-06-27T09:16:19.2542477Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/tests/loaders/test_yourdfpy.py", line 32, in test
2024-06-27T09:16:19.2543706Z     load_robot_description(description)
2024-06-27T09:16:19.2545840Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/robot_descriptions/loaders/yourdfpy.py", line 45, in load_robot_description
2024-06-27T09:16:19.2548017Z     return yourdfpy.URDF.load(module.URDF_PATH, mesh_dir=module.PACKAGE_PATH)
2024-06-27T09:16:19.2549990Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/yourdfpy/urdf.py", line 989, in load
2024-06-27T09:16:19.2551980Z     return URDF(robot=URDF._parse_robot(xml_element=xml_root), **kwargs)
2024-06-27T09:16:19.2553959Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/yourdfpy/urdf.py", line 641, in __init__
2024-06-27T09:16:19.2555475Z     self._scene = self._create_scene(
2024-06-27T09:16:19.2557199Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/yourdfpy/urdf.py", line 1335, in _create_scene
2024-06-27T09:16:19.2558753Z     self._add_geometries_to_scene(
2024-06-27T09:16:19.2560525Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/yourdfpy/urdf.py", line 1269, in _add_geometries_to_scene
2024-06-27T09:16:19.2562205Z     new_s = self._geometry2trimeshscene(
2024-06-27T09:16:19.2564151Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/yourdfpy/urdf.py", line 1221, in _geometry2trimeshscene
2024-06-27T09:16:19.2565883Z     new_s = trimesh.load(
2024-06-27T09:16:19.2567458Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/trimesh/exchange/load.py", line 130, in load
2024-06-27T09:16:19.2569063Z     loaded = load_mesh(file_obj,
2024-06-27T09:16:19.2570928Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/trimesh/constants.py", line 153, in timed
2024-06-27T09:16:19.2572295Z     result = method(*args, **kwargs)
2024-06-27T09:16:19.2574161Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/trimesh/exchange/load.py", line 222, in load_mesh
2024-06-27T09:16:19.2575648Z     loaded.append(load_kwargs(kwargs))
2024-06-27T09:16:19.2577415Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/trimesh/exchange/load.py", line 523, in load_kwargs
2024-06-27T09:16:19.2578945Z     return handler()
2024-06-27T09:16:19.2580627Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/trimesh/exchange/load.py", line 421, in handle_scene
2024-06-27T09:16:19.2583164Z     geometry = {k: load_kwargs(v) for
2024-06-27T09:16:19.2585212Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/trimesh/exchange/load.py", line 421, in <dictcomp>
2024-06-27T09:16:19.2586658Z     geometry = {k: load_kwargs(v) for
2024-06-27T09:16:19.2588672Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/trimesh/exchange/load.py", line 523, in load_kwargs
2024-06-27T09:16:19.2589906Z     return handler()
2024-06-27T09:16:19.2592924Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/trimesh/exchange/load.py", line 467, in handle_mesh
2024-06-27T09:16:19.2594457Z     return Trimesh(**kwargs)
2024-06-27T09:16:19.2596074Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/trimesh/base.py", line 144, in __init__
2024-06-27T09:16:19.2597700Z     self.vertex_normals = vertex_normals
2024-06-27T09:16:19.2599509Z   File "/home/runner/work/robot_descriptions.py/robot_descriptions.py/.tox/loader-yourdfpy/lib/python3.9/site-packages/trimesh/base.py", line 471, in vertex_normals
2024-06-27T09:16:19.2601167Z     if values.ptp() < tol.merge:
2024-06-27T09:16:19.2602249Z AttributeError: `ptp` was removed from the ndarray class in NumPy 2.0. Use np.ptp(arr, ...) instead.

Reporting this here so that the information flows (looking back on the trace as I wrap up this message, I find you may likely want to forward it upstream to trimesh). Hoping this helps!