diff --git a/src/services/philips_hue.py b/src/old/philips_hue.py similarity index 100% rename from src/services/philips_hue.py rename to src/old/philips_hue.py diff --git a/src/philips_hue_counter.py b/src/old/philips_hue_counter.py similarity index 99% rename from src/philips_hue_counter.py rename to src/old/philips_hue_counter.py index a63064c..db30d0e 100644 --- a/src/philips_hue_counter.py +++ b/src/old/philips_hue_counter.py @@ -1,6 +1,6 @@ from datetime import datetime, time, timedelta from typing import Dict -from services.philips_hue import PhilipsHue +from old.philips_hue import PhilipsHue from sensors import PeopleCounter, Directions, VL53L1XSensor import logging import json diff --git a/src/sensors/__init__.py b/src/old/sensors/__init__.py similarity index 100% rename from src/sensors/__init__.py rename to src/old/sensors/__init__.py diff --git a/src/sensors/people_counter.py b/src/old/sensors/people_counter.py similarity index 100% rename from src/sensors/people_counter.py rename to src/old/sensors/people_counter.py diff --git a/src/sensors/tof_sensor.py b/src/old/sensors/tof_sensor.py similarity index 100% rename from src/sensors/tof_sensor.py rename to src/old/sensors/tof_sensor.py diff --git a/src/sensors/vl53l1x_sensor.py b/src/old/sensors/vl53l1x_sensor.py similarity index 100% rename from src/sensors/vl53l1x_sensor.py rename to src/old/sensors/vl53l1x_sensor.py diff --git a/src/statistics/statistics.py b/src/old/statistics/statistics.py similarity index 80% rename from src/statistics/statistics.py rename to src/old/statistics/statistics.py index eac2a96..9ba75bd 100644 --- a/src/statistics/statistics.py +++ b/src/old/statistics/statistics.py @@ -15,13 +15,14 @@ with open(FILE_PATH, "r") as file: content = file.readlines() -def parse_log_entry(entry: Dict) -> Dict: +def parse_log_entry(entry: Dict) -> Dict | bool: # Only keep last record of a sequence if not is_last_in_sequence(entry): return False entry["dateTime"] = datetime.strptime( - str(entry["dateTime"])[:19], "%Y-%m-%d %H:%M:%S") + str(entry["dateTime"])[:19], "%Y-%m-%d %H:%M:%S" + ) if entry["dateTime"] < datetime(2022, 1, 1): return False @@ -31,15 +32,15 @@ def parse_log_entry(entry: Dict) -> Dict: def is_last_in_sequence(entry: Dict) -> Boolean: indoor = entry["directionState"]["indoor"] outdoor = entry["directionState"]["outdoor"] - + if len(indoor) <= 0 or len(outdoor) <= 0: return False - + end_key = "end_distance" # Check version if end_key not in indoor[-1]: end_key = "end" - + if indoor[-1][end_key] is None or outdoor[-1][end_key] is None: return False @@ -47,20 +48,20 @@ def is_last_in_sequence(entry: Dict) -> Boolean: # Collect -log = [json.loads(line.strip("\x00")) for line in content] +log: list[Dict] = [json.loads(line.strip("\x00")) for line in content] print("Number of total entries:", len(log)) # Parse & Filter -log = [parse_log_entry(entry) for entry in log if parse_log_entry(entry)] +log = [parse_log_entry(entry) for entry in log if parse_log_entry(entry)] # type: ignore print("Number of filtered entries:", len(log)) # Render fig, ax = plt.subplots() # Create a figure containing a single axes. times: list[datetime] = [entry["dateTime"] for entry in log] counts: list[int] = [entry["previousPeopleCount"] for entry in log] -ax.step(times, counts, where="pre") +ax.step(times, counts, where="pre") # type: ignore plt.show() -print("-"*20) +print("-" * 20) # Print stats @@ -70,12 +71,11 @@ walk_unders = [entry for entry in log if entry["countChange"] == 0] print("Number of walk-ins:", len(walk_ins)) print("Number of walk-outs:", len(walk_outs)) print("Number of walk-unders:", len(walk_unders)) -print("-"*20) +print("-" * 20) # Calculate faults for c, n in zip(list(range(len(log))), list(range(len(log)))[1:]): - estimated_count: int = log[c]["previousPeopleCount"] + \ - log[c]["countChange"] + estimated_count: int = log[c]["previousPeopleCount"] + log[c]["countChange"] faulty: bool = estimated_count != log[n]["previousPeopleCount"] log[c]["faulty"] = faulty log[c]["faultyCount"] = log[c]["previousPeopleCount"] if faulty else None @@ -85,11 +85,9 @@ fault_count = sum(1 for entry in log if entry["faulty"]) print("Number of faults:", fault_count) print("Percentage of faults:", fault_count / len(log) * 100, "%") -print("-"*20) -faulty_off = [entry for entry in log if entry["faulty"] - and entry["faultyCount"] == 0] -faulty_on = [entry for entry in log if entry["faulty"] - and entry["faultyCount"] != 0] +print("-" * 20) +faulty_off = [entry for entry in log if entry["faulty"] and entry["faultyCount"] == 0] +faulty_on = [entry for entry in log if entry["faulty"] and entry["faultyCount"] != 0] print("Number of false-0:", len(faulty_off)) print("Number of false-1:", len(faulty_on)) print("Percentage of false-0:", len(faulty_off) / fault_count * 100, "%") diff --git a/src/timeloop/LICENSE b/src/old/timeloop/LICENSE similarity index 100% rename from src/timeloop/LICENSE rename to src/old/timeloop/LICENSE diff --git a/src/timeloop/__init__.py b/src/old/timeloop/__init__.py similarity index 100% rename from src/timeloop/__init__.py rename to src/old/timeloop/__init__.py diff --git a/src/timeloop/app.py b/src/old/timeloop/app.py similarity index 100% rename from src/timeloop/app.py rename to src/old/timeloop/app.py diff --git a/src/timeloop/exceptions.py b/src/old/timeloop/exceptions.py similarity index 100% rename from src/timeloop/exceptions.py rename to src/old/timeloop/exceptions.py diff --git a/src/timeloop/helpers.py b/src/old/timeloop/helpers.py similarity index 100% rename from src/timeloop/helpers.py rename to src/old/timeloop/helpers.py diff --git a/src/timeloop/job.py b/src/old/timeloop/job.py similarity index 100% rename from src/timeloop/job.py rename to src/old/timeloop/job.py