Skip to content

Commit

Permalink
silence some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
chraibi committed Oct 15, 2024
1 parent f540a0f commit ca307ef
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 38 deletions.
14 changes: 1 addition & 13 deletions src/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def run() -> None:
)
traj, walkable_area = read_sqlite_file(SELECTED_OUTPUT_FILE)

json_data = load_json_data("files/bottleneck.json")
json_data = load_json_data("files/inifile.json")

if selected == "Heatmap":
handle_heatmap(walkable_area)
Expand Down Expand Up @@ -309,29 +309,17 @@ def handle_distance_to_entrance(traj, measurement_line, motivation_file) -> None
df_time_distance["time_seconds"] = (
df_time_distance["time"] / 1.0 # traj.frame_rate
)
# c1.info("Motivation")
# c2.info("Time distance")
# c3.info("Merged")
# c1.dataframe(speed)
# c2.dataframe(df_time_distance)
speed = speed.merge(df_time_distance, on=[ID_COL, FRAME_COL])
# c3.dataframe(speed)
first_frame_speed = speed.loc[
speed[FRAME_COL] == speed[FRAME_COL].min(),
["speed", "time_seconds", "distance"],
]
norm = Normalize(speed.min().speed, speed.max().speed)
# st.info(
# f"Min: {speed.min().speed}, Max: {speed.max().speed}, first frame: {speed[FRAME_COL].min()}"
# )

cmap = cm.jet # type: ignore
# ---------------
trajectory_ids = df_time_distance["id"].unique()
fig, ax = plt.subplots()
for traj_id in trajectory_ids:
# if traj_id != 44:
# continue
traj_data = df_time_distance[df_time_distance[ID_COL] == traj_id]
speed_id = speed[speed[ID_COL] == traj_id].speed.to_numpy()
# Extract points and speeds for the current trajectory
Expand Down
14 changes: 6 additions & 8 deletions src/logger_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Setup logger
"""
"""Setup logger."""

import logging

Expand Down Expand Up @@ -42,27 +40,27 @@ def setup_logging() -> None:

# Custom log functions
def log_debug(msg: str) -> None:
"""debug messages"""
"""Debug messages."""
logging.debug(msg)


def log_info(msg: str) -> None:
"""info messages"""
"""Info messages."""
logging.info(msg)


def log_warning(msg: str) -> None:
"""warning messages"""
"""Warning messages."""
logging.warning(msg)


def log_error(msg: str) -> None:
"""errror messages"""
"""Error messages."""
logging.error(msg)


def init_logger() -> None:
"""init logger"""
"""Init logger."""
setup_logging()
# jps.set_debug_callback(log_debug)
jps.set_info_callback(log_info)
Expand Down
1 change: 0 additions & 1 deletion src/motivation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ def calculate_motivation_state(
self, motivation_i: float, agent_id: int
) -> Tuple[float, float]:
"""Return v0, T tuples depending on Motivation. (v0,T)=(1.2,1)."""

v_0 = self.normal_v_0 * self.motivation_strategy.get_value(agent_id=agent_id)

time_gap = self.normal_time_gap
Expand Down
2 changes: 1 addition & 1 deletion src/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def ui_value_parameters(data: Dict[str, Any]) -> None:


def ui_competition_parameters(data: Dict[str, Any]) -> None:
"""Set competition function"""
"""Set competition function."""
with st.sidebar.expander("Competition Parameters", expanded=True):
c1, c2 = st.columns(2)
data["motivation_parameters"]["competition_max"] = c1.number_input(
Expand Down
22 changes: 8 additions & 14 deletions src/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,22 @@
from pathlib import Path
from typing import Any, Dict, List, Tuple, TypeAlias, Union
from types import SimpleNamespace

import logging
import jupedsim as jps
import numpy as np
import numpy.typing as npt
import pedpy
import plotly.graph_objects as go

import streamlit as st
from plotly.graph_objs import Figure
from scipy import stats
from shapely import GeometryCollection, Polygon
from shapely.ops import unary_union
from .logger_config import log_error, log_info
from math import sqrt

Point: TypeAlias = Tuple[float, float]


def parse(data: Union[List, Dict, Any]) -> Union[List, SimpleNamespace, Any]:
"""
Recursively converts a nested structure of lists and dictionaries into
a structure of lists and SimpleNamespace objects. Other data types are left unchanged.
Recursively converts a nested structure of lists and dictionaries.
into a structure of lists and SimpleNamespace objects. Other data types are left unchanged.
Parameters:
- data (Union[List, Dict, Any]): The input data to parse. This can be a list,
Expand Down Expand Up @@ -61,7 +55,7 @@ def delete_txt_files() -> None:
try:
os.remove(file)
except Exception as e:
log_error(f"Error deleting {file}: {e}")
logging.error(f"Error deleting {file}: {e}")


def build_geometry(
Expand Down Expand Up @@ -102,17 +96,17 @@ def init_journey(
# log_info(f"{ way_points= }")
# log_info(f"{ exits= }")
exit_ids = []
wp_ids = []
# wp_ids = []
journey = jps.JourneyDescription()
distance = 1
# distance = 1
# for way_point in way_points:
# # log_info(f"add way_point: {way_point}")
# wp_id = simulation.add_waypoint_stage((way_point[0], way_point[1]), distance)
# wp_ids.append(wp_id)
# journey.add(wp_id)

for e in exits:
log_info(f"add {e}")
# log_info(f"add {e}")
exit_id = simulation.add_exit_stage(e)
exit_ids.append(exit_id)
journey.add(exit_id)
Expand Down
1 change: 0 additions & 1 deletion time.txt

This file was deleted.

0 comments on commit ca307ef

Please sign in to comment.