Skip to content

Commit

Permalink
feat: ready for notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
Ipuch committed Jun 22, 2024
1 parent 98e04dc commit 283793c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 5 additions & 3 deletions pyorerun/multi_frame_rate_phase_rerun.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ def cumulative_frames_in_merged_t_span(self) -> list[list[int]]:
frame_t_span_idx = self.frame_t_span_idx
return [calculate_cumulative_frames(p, frame_t_span_idx) for p in range(self.nb_phases)]

def rerun(self, name: str = "animation_phase", init: bool = True, clear_last_node: bool = False) -> None:
def rerun(
self, name: str = "animation_phase", init: bool = True, clear_last_node: bool = False, notebook: bool = False
) -> None:
if self.nb_phases == 1:
self.phase_reruns[0].rerun(name, init, clear_last_node)
self.phase_reruns[0].rerun(name, init, clear_last_node, notebook)
return

if init:
rr.init(f"{name}_{0}", spawn=True)
rr.init(f"{name}_{0}", spawn=True if not notebook else False)

for phase_rerun in self.phase_reruns:
frame = 0
Expand Down
6 changes: 4 additions & 2 deletions pyorerun/phase_rerun.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ def add_video(self, name, video_array: np.ndarray) -> None:

self.xp_data.add_data(Video(name=f"{self.name}/{name}", video_array=video_array))

def rerun(self, name: str = "animation_phase", init: bool = True, clear_last_node: bool = False) -> None:
def rerun(
self, name: str = "animation_phase", init: bool = True, clear_last_node: bool = False, notebook: bool = False
) -> None:
if init:
rr.init(f"{name}_{self.phase}", spawn=True)
rr.init(f"{name}_{self.phase}", spawn=True if not notebook else False)

frame = 0
rr.set_time_seconds("stable_time", self.t_span[frame])
Expand Down
5 changes: 4 additions & 1 deletion pyorerun/rrc3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def rrc3d(
video: str | tuple[str, ...] = None,
video_crop_mode: str = "from_c3d",
marker_trajectories: bool = False,
notebook: bool = False,
) -> None:
"""
Display a c3d file in rerun.
Expand All @@ -44,6 +45,8 @@ def rrc3d(
The mode to crop the video. If 'from_c3d', the video will be cropped to the same time span as the c3d file.
marker_trajectories: bool
If True, show the marker trajectories.
notebook: bool
If True, display the animation in the notebook.
"""

# Load a c3d file
Expand Down Expand Up @@ -108,7 +111,7 @@ def rrc3d(
phase_reruns[-1].add_video(vid_name, vid)

multi_phase_rerun = MultiFrameRatePhaseRerun(phase_reruns)
multi_phase_rerun.rerun(filename)
multi_phase_rerun.rerun(filename, notebook=notebook)

if marker_trajectories:
# todo: find a better way to display curves but hacky way ok for now
Expand Down

0 comments on commit 283793c

Please sign in to comment.