Skip to content

Commit 559fb1f

Browse files
committed
made get_state_space_bounds return a tuple of xy coords
1 parent e371da2 commit 559fb1f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/local_pathfinding/local_pathfinding/visualizer.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -910,30 +910,30 @@ def build_figure(
910910
return fig, goal_change.new_goal_xy_rounded
911911

912912

913-
def get_state_space_axes(
913+
def get_state_space_bounds(
914914
vs: VisualizerState,
915-
) -> Dict[str, List[float]]:
915+
) -> Tuple[cs.XY, cs.XY]:
916916
"""
917-
Resets the view range to match the current state space bounds.
917+
Gets the state space bounds as min and max XY coordinates.
918918
919919
Args:
920920
vs: VisualizerState containing the current state space.
921921
922922
Returns:
923-
A dict with "x" and "y" keys containing the state space bounds as ranges.
923+
A tuple of (min_xy, max_xy) representing the state space bounds.
924924
Falls back to DEFAULT_PLOT_RANGE if state space is not available.
925925
"""
926926
if vs.state_space is None:
927-
return {
928-
"x": DEFAULT_PLOT_RANGE,
929-
"y": DEFAULT_PLOT_RANGE,
930-
}
927+
return (
928+
cs.XY(DEFAULT_PLOT_RANGE[0], DEFAULT_PLOT_RANGE[0]),
929+
cs.XY(DEFAULT_PLOT_RANGE[1], DEFAULT_PLOT_RANGE[1]),
930+
)
931931

932932
x_min, y_min, x_max, y_max = vs.state_space.bounds
933-
return {
934-
"x": [x_min, x_max],
935-
"y": [y_min, y_max],
936-
}
933+
return (
934+
cs.XY(x_min, y_min),
935+
cs.XY(x_max, y_max),
936+
)
937937

938938

939939
# -----------------------------
@@ -1064,9 +1064,9 @@ def update_graph(
10641064
if current_figure is None:
10651065
return dash.no_update, dash.no_update, dash.no_update
10661066

1067-
axes = get_state_space_axes(vs)
1068-
x_range = axes["x"]
1069-
y_range = axes["y"]
1067+
min_bounds, max_bounds = get_state_space_bounds(vs)
1068+
x_range = [min_bounds.x, max_bounds.x]
1069+
y_range = [min_bounds.y, max_bounds.y]
10701070
last_range = {
10711071
"x": x_range,
10721072
"y": y_range,

0 commit comments

Comments
 (0)