From 3b27f30827f632dba421acb4a89c52aeeb57a293 Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Tue, 11 Mar 2025 02:35:55 -0700 Subject: [PATCH] Added comment regarding numpy slices. PiperOrigin-RevId: 735681812 Change-Id: I832219bb63c83ecd5115ac1d5755cd35b4362478 --- doc/python.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/python.rst b/doc/python.rst index 6ccc59e5..edb2067b 100644 --- a/doc/python.rst +++ b/doc/python.rst @@ -243,7 +243,9 @@ access to the raw memory used by MuJoCo without copying or buffering. This means :ref:`mj_step`) change the content of fields *in place*. The user is therefore advised to create copies where required. For example, when logging the position of a body, one could write ``positions.append(data.body('my_body').xpos.copy())``. Without the ``.copy()``, the list would contain identical -elements, all pointing to the most recent value. +elements, all pointing to the most recent value. The same applies to NumPy slices. For example if a local +variable ``qpos_slice = data.qpos[3:8]`` is created and then :ref:`mj_step` is called, the values in ``qpos_slice`` +will have been changed. In order to conform to `PEP 8 `__ naming guidelines, struct names begin with a capital letter, for example ``mjData`` becomes ``mujoco.MjData`` in Python.