From 8229e08eb5926e45a9f94433a199127a3349efa1 Mon Sep 17 00:00:00 2001 From: Nimrod Gileadi Date: Thu, 5 Sep 2024 09:20:36 -0700 Subject: [PATCH] Used named_parameters in Menagerie model_test. PiperOrigin-RevId: 671398089 Change-Id: I92fe35b9c4d441da92cfde9a9bdc8541db19ab77 --- test/model_test.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/model_test.py b/test/model_test.py index 2e1ece72..ea5f0c73 100644 --- a/test/model_test.py +++ b/test/model_test.py @@ -34,7 +34,10 @@ def _get_xmls(pattern: str) -> List[pathlib.Path]: for d in _MODEL_DIRS: - yield from d.glob(pattern) + # Produce tuples of test name and XML path. + for f in d.glob(pattern): + test_name = str(f).removeprefix(str(f.parent.parent)) + yield (test_name, f) _MODEL_XMLS = list(_get_xmls('scene*.xml')) _MJX_MODEL_XMLS = list(_get_xmls('scene*mjx.xml')) @@ -65,7 +68,7 @@ def _pseudorandom_ctrlnoise( class ModelsTest(parameterized.TestCase): """Tests that MuJoCo models load and do not emit warnings.""" - @parameterized.parameters(_MODEL_XMLS) + @parameterized.named_parameters(_MODEL_XMLS) def test_compiles_and_steps(self, xml_path: pathlib.Path) -> None: model = mujoco.MjModel.from_xml_path(str(xml_path)) data = mujoco.MjData(model) @@ -86,7 +89,7 @@ def test_compiles_and_steps(self, xml_path: pathlib.Path) -> None: class MjxModelsTest(parameterized.TestCase): """Tests that MJX models load and do not return NaNs.""" - @parameterized.parameters(_MJX_MODEL_XMLS) + @parameterized.named_parameters(_MJX_MODEL_XMLS) def test_compiles_and_steps(self, xml_path: pathlib.Path) -> None: model = mujoco.MjModel.from_xml_path(str(xml_path)) model = mjx.put_model(model)