From 8b04ab027f2e5e8ce54c3d9ae077835cef138fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E7=BF=8A=E5=87=A1?= Date: Sat, 15 Aug 2026 14:17:36 +0800 Subject: [PATCH 1/4] fix: make numpy.typing import explicit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ArrayLike: TypeAlias = np.typing.ArrayLike | jax.typing.ArrayLike is a module-level expression evaluated at import time. On numpy < 2.0, np.typing only resolves if numpy.typing has been imported earlier; today this happens incidentally via trimesh (a transitive dependency of mujoco-mjx), which imports numpy.typing at startup. Add an explicit import so the alias no longer depends on that side effect — if mujoco-mjx changes its dependencies or import order, this module keeps working. --- mjinx/typing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mjinx/typing.py b/mjinx/typing.py index f97e1ec..7ce3083 100644 --- a/mjinx/typing.py +++ b/mjinx/typing.py @@ -11,6 +11,7 @@ import jax import jax.numpy as jnp import numpy as np +import numpy.typing from mujoco.mjx._src.dataclasses import PyTreeNode ndarray: TypeAlias = np.ndarray | jnp.ndarray From b4c7482d79981f2c8ef71151ceec2c13c05e717f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E7=BF=8A=E5=87=A1?= Date: Fri, 21 Aug 2026 21:00:13 +0800 Subject: [PATCH 2/4] test: use mjx.put_model wrapper in hfield distance test mjx.kinematics expects mjx Model/Data wrapper types (which expose the .impl attribute), not the raw mujoco.MjModel. Wrap the model with mjx.put_model() before calling kinematics. --- tests/unit_tests/configuration/test_configuration.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/unit_tests/configuration/test_configuration.py b/tests/unit_tests/configuration/test_configuration.py index efdbece..7100008 100644 --- a/tests/unit_tests/configuration/test_configuration.py +++ b/tests/unit_tests/configuration/test_configuration.py @@ -305,8 +305,9 @@ def test_get_distance_with_hfield(self) -> None: """ ) - hfield_data = mjx.make_data(hfield_model) - hfield_data = mjx.kinematics(hfield_model, hfield_data) + hfield_model_mjx = mjx.put_model(hfield_model) + hfield_data = mjx.make_data(hfield_model_mjx) + hfield_data = mjx.kinematics(hfield_model_mjx, hfield_data) collision_pairs: list[CollisionPair] = [(0, 1)] # hfield and sphere From 7239283d2b6ee2f8e06794a647fbba600110607f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E7=BF=8A=E5=87=A1?= Date: Fri, 21 Aug 2026 21:00:13 +0800 Subject: [PATCH 3/4] fix: widen target_q/target_com setter types to accept jax.Array jax.Array is not a collections.abc.Sequence, so mypy rejected self.target_q = jnp.zeros(...) against the Sequence-typed setters. The setters already convert via jnp.array(), so accepting jnp.ndarray | Sequence is accurate and keeps list inputs valid. --- mjinx/components/tasks/_com_task.py | 4 ++-- mjinx/components/tasks/_joint_task.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mjinx/components/tasks/_com_task.py b/mjinx/components/tasks/_com_task.py index 4c47c96..8a4835c 100644 --- a/mjinx/components/tasks/_com_task.py +++ b/mjinx/components/tasks/_com_task.py @@ -137,7 +137,7 @@ def target_com(self) -> jnp.ndarray: return self._target_com @target_com.setter - def target_com(self, value: Sequence): + def target_com(self, value: jnp.ndarray | Sequence): """ Set the target center of mass for the task. @@ -145,7 +145,7 @@ def target_com(self, value: Sequence): """ self.update_target_com(value) - def update_target_com(self, target_com: Sequence): + def update_target_com(self, target_com: jnp.ndarray | Sequence): """ Update the target center of mass for the task. diff --git a/mjinx/components/tasks/_joint_task.py b/mjinx/components/tasks/_joint_task.py index 87a4034..707e843 100644 --- a/mjinx/components/tasks/_joint_task.py +++ b/mjinx/components/tasks/_joint_task.py @@ -177,7 +177,7 @@ def target_q(self) -> jnp.ndarray: return self._target_q @target_q.setter - def target_q(self, value: Sequence): + def target_q(self, value: jnp.ndarray | Sequence): """ Set the target joint positions for the task. @@ -185,7 +185,7 @@ def target_q(self, value: Sequence): """ self.update_target_q(value) - def update_target_q(self, target_q: Sequence): + def update_target_q(self, target_q: jnp.ndarray | Sequence): """ Update the target joint positions for the task. From d60c1798e7709c32a4938f8036b6ea6d278a007a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E7=BF=8A=E5=87=A1?= Date: Fri, 21 Aug 2026 21:00:13 +0800 Subject: [PATCH 4/4] build: use list form for pytest filterwarnings config pytest >= 9 strictly validates filterwarnings as a linelist; the single-string form makes pytest fail at startup. The list form is the standard syntax and is accepted by both pytest 8 and 9. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7b96daa..2c1614e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,4 +57,4 @@ line-length = 120 "__init__.py" = ["F401"] [tool.pytest] -filterwarnings = "ignore:.*U.*mode is deprecated:DeprecationWarning" +filterwarnings = ["ignore:.*U.*mode is deprecated:DeprecationWarning"]