Skip to content

Commit

Permalink
fix optional savefig code
Browse files Browse the repository at this point in the history
  • Loading branch information
MedericFourmy committed Feb 15, 2024
1 parent 719de9b commit 9eb0e4c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
20 changes: 12 additions & 8 deletions tests/test_renderer_bullet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Set of unit tests for Panda3D renderer."""
"""Set of unit tests for bullet renderer."""
import unittest
from pathlib import Path

Expand All @@ -14,7 +14,7 @@


class TestBulletRenderer(unittest.TestCase):
"""Unit tests for Panda3D renderer."""
"""Unit tests for bullet renderer."""

def setUp(self) -> None:

Expand Down Expand Up @@ -84,11 +84,13 @@ def test_scene_renderer(self):

if SAVEFIG:
import matplotlib.pyplot as plt
plt.subplot(1,2,1)
plt.subplot(2,2,1)
plt.imshow(rgb)
plt.subplot(1,2,2)
plt.subplot(2,2,3)
plt.imshow(depth, cmap=plt.cm.gray_r)
fig_path = self.obj_path.parent / f'panda3d_{self.obj_label}_render.png'
plt.subplot(2,2,4)
plt.imshow(binary_mask, cmap=plt.cm.gray)
fig_path = self.obj_path.parent / f'bullet_{self.obj_label}_scene_render.png'
print(f'Saved {fig_path}')
plt.savefig(fig_path)

Expand Down Expand Up @@ -177,11 +179,13 @@ def test_batch_renderer(self):

if SAVEFIG:
import matplotlib.pyplot as plt
plt.subplot(1,2,1)
plt.subplot(2,2,1)
plt.imshow(rgb)
plt.subplot(1,2,2)
plt.subplot(2,2,3)
plt.imshow(depth, cmap=plt.cm.gray_r)
fig_path = self.obj_path.parent / f'panda3d_{self.obj_label}_render.png'
plt.subplot(2,2,4)
plt.imshow(binary_mask, cmap=plt.cm.gray)
fig_path = self.obj_path.parent / f'bullet_{self.obj_label}_batch_render.png'
print(f'Saved {fig_path}')
plt.savefig(fig_path)

Expand Down
26 changes: 14 additions & 12 deletions tests/test_renderer_panda3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@ def test_scene_renderer(self):

if SAVEFIG:
import matplotlib.pyplot as plt
plt.subplot(1,3,1)
plt.subplot(2,2,1)
plt.imshow(rgb)
plt.subplot(1,3,2)
plt.imshow(depth, cmap=plt.cm.gray_r)
plt.subplot(1,3,3)
plt.subplot(2,2,2)
plt.imshow(normals)
fig_path = self.obj_path.parent / f'panda3d_{self.obj_label}_render.png'
plt.subplot(2,2,3)
plt.imshow(depth, cmap=plt.cm.gray_r)
plt.subplot(2,2,4)
plt.imshow(binary_mask, cmap=plt.cm.gray)
fig_path = self.obj_path.parent / f'panda3d_{self.obj_label}_scene_render.png'
print(f'Saved {fig_path}')
plt.savefig(fig_path)

Expand Down Expand Up @@ -262,17 +264,17 @@ def test_batch_renderer(self):
depth = renderings.depths[0].movedim(0,-1).numpy() # (Nc,3,h,w) -> (h,w,3)
binary_mask = renderings.binary_masks[0].movedim(0,-1).numpy() # (Nc,1,h,w) -> (h,w,1)



if SAVEFIG:
import matplotlib.pyplot as plt
plt.subplot(1,3,1)
plt.subplot(2,2,1)
plt.imshow(rgb)
plt.subplot(1,3,2)
plt.imshow(depth, cmap=plt.cm.gray_r)
plt.subplot(1,3,3)
plt.subplot(2,2,2)
plt.imshow(normals)
fig_path = self.obj_path.parent / f'panda3d_{self.obj_label}_render.png'
plt.subplot(2,2,3)
plt.imshow(depth, cmap=plt.cm.gray_r)
plt.subplot(2,2,4)
plt.imshow(binary_mask, cmap=plt.cm.gray)
fig_path = self.obj_path.parent / f'panda3d_{self.obj_label}_batch_render.png'
print(f'Saved {fig_path}')
plt.savefig(fig_path)

Expand Down

0 comments on commit 9eb0e4c

Please sign in to comment.