Skip to content

Commit

Permalink
Interim changes to add wrap_resources_at argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Bergam0t committed Jan 10, 2025
1 parent 049ebe7 commit 7e563c1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vidigi/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def animate_activity_log(
scenario=None,
every_x_time_units=10,
wrap_queues_at=20,
wrap_resources_at=20,
step_snapshot_max=50,
limit_duration=10*60*24,
plotly_height=900,
Expand Down Expand Up @@ -341,6 +342,8 @@ def animate_activity_log(
Time interval between animation frames in minutes (default is 10).
wrap_queues_at : int, optional
Maximum number of entities to display in a queue before wrapping to a new row (default is 20).
wrap_resources_at : int, optional
Number of resources to show before wrapping to a new row (default is 20).
step_snapshot_max : int, optional
Maximum number of patients to show in each snapshot per event (default is 50).
limit_duration : int, optional
Expand Down Expand Up @@ -423,6 +426,7 @@ def animate_activity_log(
full_patient_df=full_patient_df,
event_position_df=event_position_df,
wrap_queues_at=wrap_queues_at,
wrap_resources_at=wrap_resources_at,
step_snapshot_max=step_snapshot_max,
gap_between_entities=gap_between_entities,
gap_between_resources=gap_between_resources,
Expand Down
11 changes: 11 additions & 0 deletions vidigi/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def generate_animation_df(
full_patient_df,
event_position_df,
wrap_queues_at=20,
wrap_resources_at=20,
step_snapshot_max=50,
gap_between_entities=10,
gap_between_resources=10,
Expand All @@ -196,6 +197,8 @@ def generate_animation_df(
DataFrame with columns 'event', 'x', and 'y', specifying initial positions for each event type.
wrap_queues_at : int, optional
Number of entities in a queue before wrapping to a new row (default is 20).
wrap_resources_at : int, optional
Number of resources to show before wrapping to a new row (default is 20).
step_snapshot_max : int, optional
Maximum number of patients to show in each snapshot (default is 50).
gap_between_entities : int, optional
Expand Down Expand Up @@ -244,6 +247,14 @@ def generate_animation_df(
resource_use = resource_use.rename(columns={"y": "y_final"})
resource_use['x_final'] = resource_use['x'] - resource_use['resource_id'] * gap_between_resources

# If we want resources to wrap at a certain queue length, do this here
# They'll wrap at the defined point and then the queue will start expanding upwards
# from the starting row
if wrap_resources_at is not None:
resource_use['row'] = np.floor((resource_use['resource_id'] - 1) / (wrap_resources_at))
resource_use['x_final'] = resource_use['x_final'] + (wrap_resources_at * resource_use['row'] * gap_between_resources) + gap_between_resources
resource_use['y_final'] = resource_use['y_final'] + (resource_use['row'] * gap_between_rows)

# Determine the position for any queuing steps
queues = full_patient_df_plus_pos[full_patient_df_plus_pos['event_type']=='queue'].copy()
# queues['y_final'] = queues['y']
Expand Down

0 comments on commit 7e563c1

Please sign in to comment.