Skip to content

Commit 8f689f3

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/fix-codec' into fix-codec
2 parents 71ea96c + a9276b2 commit 8f689f3

5 files changed

Lines changed: 30 additions & 29 deletions

File tree

mujoco_toolbox/sim.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
from typing import TYPE_CHECKING, Any, Self, TypeAlias
1818

1919
import defusedxml.ElementTree as ET
20-
import matplotlib.pyplot as plt
21-
import matplotlib.animation as animation
2220
import imageio.v3 as iio
21+
import matplotlib.pyplot as plt
2322
import mujoco
2423
import mujoco.viewer
2524
import numpy as np
2625
import yaml
27-
from IPython.display import clear_output, HTML
26+
from IPython.display import HTML, clear_output
27+
from matplotlib import animation
2828
from tqdm.auto import tqdm
2929

3030
from .builder import Builder
@@ -715,7 +715,7 @@ def is_jupyter() -> bool:
715715

716716
# Set up the figure and image once
717717
fig, ax = plt.subplots()
718-
im = ax.imshow(np.zeros((self.resolution[1], self.resolution[0], 3), dtype=np.uint8), interpolation='nearest')
718+
im = ax.imshow(np.zeros((self.resolution[1], self.resolution[0], 3), dtype=np.uint8), interpolation="nearest")
719719
ax.set_axis_off()
720720
ax.set_title(title)
721721
plt.subplots_adjust(left=0, right=1, top=1, bottom=0, wspace=0, hspace=0)
@@ -726,18 +726,17 @@ def is_jupyter() -> bool:
726726
lambda frame: (im.set_data(frame), [im])[1],
727727
frames=subset_frames,
728728
interval=(1000 / self._fps),
729-
blit=True
729+
blit=True,
730730
)
731731
plt.close(fig)
732732
return HTML(ani.to_jshtml())
733-
else:
734-
plt.ion()
735-
delay = 1.0 / self._fps
736-
for frame in subset_frames:
737-
im.set_data(frame)
738-
plt.pause(delay)
739-
plt.ioff()
740-
plt.close(fig)
733+
plt.ion()
734+
delay = 1.0 / self._fps
735+
for frame in subset_frames:
736+
im.set_data(frame)
737+
plt.pause(delay)
738+
plt.ioff()
739+
plt.close(fig)
741740
except Exception as e:
742741
msg = "Error while showing video subset."
743742
raise Exception(msg) from e # noqa: TRY002
@@ -769,15 +768,15 @@ def save(
769768
if not hasattr(self, "_frames") or self._frames is None or len(self._frames) == 0:
770769
msg = "No frames captured to render. Re-run the simulation with render=True."
771770
raise ValueError(msg)
772-
771+
773772
# Extract frames
774773
subset_frames = self._get_index(
775774
frame_idx=frame_idx,
776775
time_idx=time_idx,
777776
)
778777

779778
title_path = Path(title)
780-
779+
781780
try:
782781
# Save the video
783782
iio.imwrite(

tests/test_id.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21

32
import pytest
43

tests/test_media.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import mujoco_toolbox as mjtb
2-
from pathlib import Path
3-
import pytest
41
import os
2+
from pathlib import Path
3+
4+
import mujoco_toolbox as mjtb
5+
6+
FILE_EXTENSIONS = ["mp4", "gif", "avi", "webm", "mov"]
57

68
FILE_EXTENSIONS = ["mp4", "gif", "avi", "webm", "mov"]
79

tests/test_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21

32
from mujoco_toolbox import utils
43

tests/test_warnings.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
1-
from mujoco_toolbox.warnings import SimulationError, SimulationWarning
2-
from mujoco_toolbox.sim import Wrapper
3-
import mujoco_toolbox as mjtb
41
import pytest
52

3+
import mujoco_toolbox as mjtb
4+
from mujoco_toolbox.sim import Wrapper
5+
from mujoco_toolbox.warnings import SimulationError, SimulationWarning
6+
7+
68
# Needs warnings to be enabled (Dummy test to ensure warnings are raised)
7-
def test_simulation_warning():
9+
def test_simulation_warning() -> None:
810
msg = "This is a test warning"
911
try:
1012
raise SimulationWarning(msg)
1113
except SimulationWarning as e:
1214
assert str(e) == msg
1315

14-
def test_simulation_error():
16+
def test_simulation_error() -> None:
1517
msg = "This is a test error"
1618
try:
1719
raise SimulationError(msg)
1820
except SimulationError as e:
1921
assert str(e) == msg
2022

21-
def test_deprecated_wrapper_warning():
23+
def test_deprecated_wrapper_warning() -> None:
2224
with pytest.warns(DeprecationWarning):
2325
Wrapper("<mujoco></mujoco>")
24-
25-
def test_deprecated_wrapper_error():
26+
27+
def test_deprecated_wrapper_error() -> None:
2628
mjtb.__version__ = "1.0.0" # Set version to trigger deprecation
2729
with pytest.raises(RuntimeError):
28-
Wrapper("<mujoco></mujoco>")
30+
Wrapper("<mujoco></mujoco>")

0 commit comments

Comments
 (0)