|
| def | __init__ (self, is3D, port=None, debug=False) |
| |
| "Viewer" | replay (self, pd.DataFrame df, float dt) |
| |
| "Viewer" | live (self, dict params, list[str]|str infos=['type', 'state'], int seed=None, bool benchmark=False, bool withTqdm=False) |
| |
| pd.DataFrame | getData (self) |
| |
| def | show (self, int width=None, int height=None) |
| |
| def | stop (self) |
| |
A live or replay 2D/3D simulation viewer embedded in Jupyter.
This class starts an HTTPServer in a background thread.
You can use it in **replay** mode—feeding it a precomputed DataFrame—or
in **live** mode—running a Simu instance step by step and streaming
results as they arrive.
The server is automatically cleaned up when the Viewer object is
garbage-collected or when you explicitly call `.stop()`.
Definition at line 321 of file viewer.py.
| def viewer.Viewer.__init__ |
( |
|
self, |
|
|
|
is3D, |
|
|
|
port = None, |
|
|
|
debug = False |
|
) |
| |
Instantiate and start the HTTP server.
Args:
is3D (bool): If True, viewer expects 3D coordinates (x,y,z),
otherwise only (x,y).
port (int, optional): TCP port to bind the server on. If None,
tries to find a free port in [8765, 8865].
debug (bool): If True, enables javascript debug mode with additional logging.
Raises:
RuntimeError: If the server thread fails to start within 5 seconds.
Definition at line 334 of file viewer.py.
| "Viewer" viewer.Viewer.live |
( |
|
self, |
|
|
dict |
params, |
|
|
list[str]|str |
infos = ['type', 'state'], |
|
|
int |
seed = None, |
|
|
bool |
benchmark = False, |
|
|
bool |
withTqdm = False |
|
) |
| |
Run a Simu instance live, collect data each step, and stream it.
Args:
params (dict): Simulation parameters (must include Scenario.maxStep & dt).
infos (list[str]|str): List of cell attributes to retrieve, or 'all'
withTqdm (bool): If True, show a tqdm progress bar.
Returns:
self, for method chaining.
Raises:
RuntimeError: If already in replay mode.
Definition at line 393 of file viewer.py.
| "Viewer" viewer.Viewer.replay |
( |
|
self, |
|
|
pd.DataFrame |
df, |
|
|
float |
dt |
|
) |
| |
Load a precomputed DataFrame for step-by-step replay.
Args:
df (pd.DataFrame): Must contain columns ['step','id',…,'positionx',…].
dt (float): Time interval between steps.
Returns:
self, for method chaining.
Raises:
RuntimeError: If already in live mode.
TypeError: If df is not a pandas DataFrame.
Definition at line 367 of file viewer.py.