Skip to content

Commit

Permalink
Enable rendering of notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Ozaq committed Oct 5, 2023
1 parent d37c117 commit 0a29acb
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- name: Build docs
run: |
cp -R notebooks/* docs/source/notebooks
python3 -m pip install -r docs/requirements.txt
sphinx-build docs/source docs/build -j$(nproc)
Expand Down Expand Up @@ -105,4 +106,4 @@ jobs:
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: gh-pages
commit_message: Update versions and stable
commit_message: Update versions and stable
6 changes: 6 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ sphinx-favicon==1.0.1
sphinx-notfound-page==1.0.0
myst-nb @ git+https://github.com/executablebooks/MyST-NB@59854c2
nbconvert==7.7.1

# notebook dependencies
shapely
numpy
pandas
pedpy
7 changes: 6 additions & 1 deletion docs/source/notebooks/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ Notebooks
.. toctree::
:maxdepth: 1

Test <test>
Bottleneck <bottlenneck>
Corner <corner>
Crossing <crossing>
Crossing 4 way <crossing_4_directions>
Double bottleneck <double-bottleneck>
Double bottleneck narrow <double-bottleneck_1m-breit>
45 changes: 0 additions & 45 deletions docs/source/notebooks/test.ipynb

This file was deleted.

11 changes: 9 additions & 2 deletions notebooks/bottlenneck.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,17 @@
"def read_trajectory_data(trajectory_file: str) -> pedpy.TrajectoryData:\n",
" with sqlite3.connect(trajectory_file) as con:\n",
" data = pd.read_sql_query(\n",
" \"select frame, id, pos_x as x, pos_y as y, ori_x as ox, ori_y as oy from trajectory_data\", con)\n",
" fps = float(con.cursor().execute(\"select value from metadata where key = 'fps'\").fetchone()[0])\n",
" \"select frame, id, pos_x as x, pos_y as y, ori_x as ox, ori_y as oy from trajectory_data\",\n",
" con,\n",
" )\n",
" fps = float(\n",
" con.cursor()\n",
" .execute(\"select value from metadata where key = 'fps'\")\n",
" .fetchone()[0]\n",
" )\n",
" return pedpy.TrajectoryData(data=data, frame_rate=fps)\n",
"\n",
"\n",
"def visualize(data_df: pd.DataFrame, area: GeometryCollection) -> Figure:\n",
" \"\"\"Generate moving trajectories based on simulation\"\"\"\n",
" range_color = [0, max(data_df[\"speed\"])]\n",
Expand Down
10 changes: 8 additions & 2 deletions notebooks/corner.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,14 @@
"def read_trajectory_data(trajectory_file: str) -> pedpy.TrajectoryData:\n",
" with sqlite3.connect(trajectory_file) as con:\n",
" data = pd.read_sql_query(\n",
" \"select frame, id, pos_x as x, pos_y as y, ori_x as ox, ori_y as oy from trajectory_data\", con)\n",
" fps = float(con.cursor().execute(\"select value from metadata where key = 'fps'\").fetchone()[0])\n",
" \"select frame, id, pos_x as x, pos_y as y, ori_x as ox, ori_y as oy from trajectory_data\",\n",
" con,\n",
" )\n",
" fps = float(\n",
" con.cursor()\n",
" .execute(\"select value from metadata where key = 'fps'\")\n",
" .fetchone()[0]\n",
" )\n",
" return pedpy.TrajectoryData(data=data, frame_rate=fps)\n",
"\n",
"\n",
Expand Down
15 changes: 12 additions & 3 deletions notebooks/crossing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@
"metadata": {},
"outputs": [],
"source": [
"exits = [simulation.add_exit_stage([(18, 15), (20, 15), (20, 20), (18, 20)]), simulation.add_exit_stage([(8, 0), (12, 0), (12, 2), (8, 2)])]\n",
"exits = [\n",
" simulation.add_exit_stage([(18, 15), (20, 15), (20, 20), (18, 20)]),\n",
" simulation.add_exit_stage([(8, 0), (12, 0), (12, 2), (8, 2)]),\n",
"]\n",
"journeys = [\n",
" simulation.add_journey(jps.JourneyDescription([exit])) for exit in exits\n",
"]"
Expand Down Expand Up @@ -247,8 +250,14 @@
"def read_trajectory_data(trajectory_file: str) -> pedpy.TrajectoryData:\n",
" with sqlite3.connect(trajectory_file) as con:\n",
" data = pd.read_sql_query(\n",
" \"select frame, id, pos_x as x, pos_y as y, ori_x as ox, ori_y as oy from trajectory_data\", con)\n",
" fps = float(con.cursor().execute(\"select value from metadata where key = 'fps'\").fetchone()[0])\n",
" \"select frame, id, pos_x as x, pos_y as y, ori_x as ox, ori_y as oy from trajectory_data\",\n",
" con,\n",
" )\n",
" fps = float(\n",
" con.cursor()\n",
" .execute(\"select value from metadata where key = 'fps'\")\n",
" .fetchone()[0]\n",
" )\n",
" return pedpy.TrajectoryData(data=data, frame_rate=fps)\n",
"\n",
"\n",
Expand Down
20 changes: 14 additions & 6 deletions notebooks/crossing_4_directions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,12 @@
"metadata": {},
"outputs": [],
"source": [
"exits = [simulation.add_exit_stage([(18, 15), (20, 15), (20, 20), (18, 20)]),\n",
" simulation.add_exit_stage([(8, 0), (12, 0), (12, 2), (8, 2)]),\n",
" simulation.add_exit_stage([(0, 15), (2, 15), (2, 20), (0, 20)]),\n",
" simulation.add_exit_stage([(8, 33), (12, 33), (12, 35), (8, 35)]),]\n",
"exits = [\n",
" simulation.add_exit_stage([(18, 15), (20, 15), (20, 20), (18, 20)]),\n",
" simulation.add_exit_stage([(8, 0), (12, 0), (12, 2), (8, 2)]),\n",
" simulation.add_exit_stage([(0, 15), (2, 15), (2, 20), (0, 20)]),\n",
" simulation.add_exit_stage([(8, 33), (12, 33), (12, 35), (8, 35)]),\n",
"]\n",
"journeys = [\n",
" simulation.add_journey(jps.JourneyDescription([exit])) for exit in exits\n",
"]"
Expand Down Expand Up @@ -256,8 +258,14 @@
"def read_trajectory_data(trajectory_file: str) -> pedpy.TrajectoryData:\n",
" with sqlite3.connect(trajectory_file) as con:\n",
" data = pd.read_sql_query(\n",
" \"select frame, id, pos_x as x, pos_y as y, ori_x as ox, ori_y as oy from trajectory_data\", con)\n",
" fps = float(con.cursor().execute(\"select value from metadata where key = 'fps'\").fetchone()[0])\n",
" \"select frame, id, pos_x as x, pos_y as y, ori_x as ox, ori_y as oy from trajectory_data\",\n",
" con,\n",
" )\n",
" fps = float(\n",
" con.cursor()\n",
" .execute(\"select value from metadata where key = 'fps'\")\n",
" .fetchone()[0]\n",
" )\n",
" return pedpy.TrajectoryData(data=data, frame_rate=fps)\n",
"\n",
"\n",
Expand Down
15 changes: 12 additions & 3 deletions notebooks/double-bottleneck.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@
"metadata": {},
"outputs": [],
"source": [
"exits = [simulation.add_exit_stage([(24, 0), (25, 0), (25, 10), (24, 10)]),simulation.add_exit_stage([(0, 0), (1, 0), (1, 10), (0, 10)])]\n",
"exits = [\n",
" simulation.add_exit_stage([(24, 0), (25, 0), (25, 10), (24, 10)]),\n",
" simulation.add_exit_stage([(0, 0), (1, 0), (1, 10), (0, 10)]),\n",
"]\n",
"journeys = [\n",
" simulation.add_journey(jps.JourneyDescription([exit])) for exit in exits\n",
"]"
Expand Down Expand Up @@ -258,8 +261,14 @@
"def read_trajectory_data(trajectory_file: str) -> pedpy.TrajectoryData:\n",
" with sqlite3.connect(trajectory_file) as con:\n",
" data = pd.read_sql_query(\n",
" \"select frame, id, pos_x as x, pos_y as y, ori_x as ox, ori_y as oy from trajectory_data\", con)\n",
" fps = float(con.cursor().execute(\"select value from metadata where key = 'fps'\").fetchone()[0])\n",
" \"select frame, id, pos_x as x, pos_y as y, ori_x as ox, ori_y as oy from trajectory_data\",\n",
" con,\n",
" )\n",
" fps = float(\n",
" con.cursor()\n",
" .execute(\"select value from metadata where key = 'fps'\")\n",
" .fetchone()[0]\n",
" )\n",
" return pedpy.TrajectoryData(data=data, frame_rate=fps)\n",
"\n",
"\n",
Expand Down
15 changes: 12 additions & 3 deletions notebooks/double-bottleneck_1m-breit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@
"metadata": {},
"outputs": [],
"source": [
"exits = [simulation.add_exit_stage([(24, 0), (25, 0), (25, 10), (24, 10)]), simulation.add_exit_stage([(0, 0), (1, 0), (1, 10), (0, 10)])]\n",
"exits = [\n",
" simulation.add_exit_stage([(24, 0), (25, 0), (25, 10), (24, 10)]),\n",
" simulation.add_exit_stage([(0, 0), (1, 0), (1, 10), (0, 10)]),\n",
"]\n",
"journeys = [\n",
" simulation.add_journey(jps.JourneyDescription([exit])) for exit in exits\n",
"]"
Expand Down Expand Up @@ -255,8 +258,14 @@
"def read_trajectory_data(trajectory_file: str) -> pedpy.TrajectoryData:\n",
" with sqlite3.connect(trajectory_file) as con:\n",
" data = pd.read_sql_query(\n",
" \"select frame, id, pos_x as x, pos_y as y, ori_x as ox, ori_y as oy from trajectory_data\", con)\n",
" fps = float(con.cursor().execute(\"select value from metadata where key = 'fps'\").fetchone()[0])\n",
" \"select frame, id, pos_x as x, pos_y as y, ori_x as ox, ori_y as oy from trajectory_data\",\n",
" con,\n",
" )\n",
" fps = float(\n",
" con.cursor()\n",
" .execute(\"select value from metadata where key = 'fps'\")\n",
" .fetchone()[0]\n",
" )\n",
" return pedpy.TrajectoryData(data=data, frame_rate=fps)\n",
"\n",
"\n",
Expand Down

0 comments on commit 0a29acb

Please sign in to comment.