CoolFace
Apppublic

cs686/ardy-motion-api

sourceHugging Faceupdated 2mo agoView on Hugging Face
6likes
test_bvh.py47 linesDownload Raw Back to tests
1import tempfile2import unittest3from pathlib import Path4 5import numpy as np6 7from ardy.exports.bvh import write_bvh8 9 10class BvhExportTests(unittest.TestCase):11    def test_writes_blender_readable_hierarchy_and_motion(self):12        rotations = np.repeat(np.eye(3)[None, None], 4, axis=0)13        rotations = np.repeat(rotations, 2, axis=1)14        roots = np.array(15            [16                [0.0, 0.0, 0.0],17                [0.1, 0.0, 0.0],18                [0.2, 0.0, 0.0],19                [0.3, 0.0, 0.0],20            ]21        )22 23        with tempfile.TemporaryDirectory() as folder:24            output = Path(folder) / "motion.bvh"25            write_bvh(26                output,27                joint_names=["Hips", "Spine"],28                parents=[-1, 0],29                rest_positions=np.array([[0.0, 0.0, 0.0], [0.0, 0.5, 0.0]]),30                local_rot_mats=rotations,31                root_positions=roots,32                fps=20,33            )34            text = output.read_text(encoding="utf-8")35 36        self.assertIn("ROOT Hips", text)37        self.assertIn("JOINT Spine", text)38        self.assertIn("Frames: 4", text)39        self.assertIn("Frame Time: 0.050000000", text)40        motion_lines = text.split("Frame Time: 0.050000000\n", 1)[1].strip().splitlines()41        self.assertEqual(len(motion_lines), 4)42        self.assertTrue(motion_lines[-1].startswith("0.3000000 0.0000000 0.0000000"))43 44 45if __name__ == "__main__":46    unittest.main()47