From e452979c0bd9a97b38d100cf11b484daed4e87ff Mon Sep 17 00:00:00 2001 From: Gopala Krishna Date: Sat, 26 Jul 2025 19:12:03 -0400 Subject: [PATCH] Fix: Replaced assert with ValueError in stochastic_occupancy --- smart_control/simulator/stochastic_occupancy.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/smart_control/simulator/stochastic_occupancy.py b/smart_control/simulator/stochastic_occupancy.py index b270d897..f1b29c5e 100644 --- a/smart_control/simulator/stochastic_occupancy.py +++ b/smart_control/simulator/stochastic_occupancy.py @@ -54,13 +54,22 @@ def __init__( random_state: np.random.RandomState, time_zone: Union[datetime.tzinfo, str] = "UTC", ): - assert ( + # Validate that the time bounds are in chronological order + if not ( earliest_expected_arrival_hour < latest_expected_arrival_hour < earliest_expected_departure_hour < latest_expected_departure_hour - ) - assert lunch_start_hour < lunch_end_hour + ): + raise ValueError( + "Time bounds must be in chronological order i.e., " + "expected arrival/departure hours must be strictly increasing:" "earliest_expected_arrival_hour < latest_expected_arrival_hour " + "< earliest_expected_departure_hour < latest_expected_departure_hour." + ) + + # Validate lunch time bounds + if lunch_start_hour >= lunch_end_hour: + raise ValueError("lunch_start_hour must be before lunch_end_hour.") self._earliest_expected_arrival_hour = earliest_expected_arrival_hour self._latest_expected_arrival_hour = latest_expected_arrival_hour