From dd870381f697e9ed252112ca6b6b8ad58a8c6a79 Mon Sep 17 00:00:00 2001 From: codewithbear Date: Wed, 9 Jul 2025 09:16:45 +0000 Subject: [PATCH 1/2] Fix spelling issues --- smart_control/environment/environment.py | 4 ++-- smart_control/environment/environment_test.py | 4 ++-- .../environment/environment_test_utils.py | 2 +- smart_control/models/base_building.py | 2 +- smart_control/models/base_energy_cost.py | 2 +- .../agents/networks/sac_networks.py | 2 +- .../scripts/populate_starter_buffer.py | 2 +- .../reinforcement_learning/scripts/train.py | 2 +- .../reinforcement_learning/utils/config.py | 2 +- .../reward/base_setpoint_energy_carbon_reward.py | 4 ++-- .../reward/electricity_energy_cost_test.py | 2 +- .../reward/natural_gas_energy_cost_test.py | 2 +- .../reward/setpoint_energy_carbon_regret.py | 2 +- .../reward/setpoint_energy_carbon_reward.py | 2 +- smart_control/simulator/air_handler.py | 4 ++-- smart_control/simulator/air_handler_test.py | 4 ++-- smart_control/simulator/boiler.py | 4 ++-- smart_control/simulator/building.py | 4 ++-- smart_control/simulator/building_test.py | 6 +++--- smart_control/simulator/building_utils.py | 6 +++--- smart_control/simulator/constants.py | 14 ++++---------- smart_control/simulator/hvac.py | 2 +- smart_control/simulator/hvac_test.py | 2 +- .../randomized_arrival_departure_occupancy.py | 14 +++++++------- .../simulator/rejection_simulator_building.py | 2 +- smart_control/simulator/simulator.py | 12 ++++++------ smart_control/simulator/simulator_building.py | 2 +- .../simulator/simulator_building_test_lib.py | 4 ++-- .../simulator/simulator_flexible_floor_plan.py | 4 ++-- .../simulator_flexible_floor_plan_test.py | 2 +- smart_control/simulator/smart_device.py | 2 +- smart_control/simulator/step_function_occupancy.py | 6 +++--- .../simulator/stochastic_convection_simulator.py | 4 ++-- smart_control/simulator/tf_simulator.py | 6 +++--- smart_control/simulator/tf_simulator_test.py | 2 +- smart_control/simulator/thermal_diffuser_utils.py | 6 +++--- smart_control/simulator/thermostat.py | 4 ++-- smart_control/simulator/weather_controller.py | 4 ++-- smart_control/utils/agent_utils.py | 6 +++--- smart_control/utils/agent_utils_test.py | 8 ++++---- smart_control/utils/building_renderer.py | 2 +- smart_control/utils/controller_reader.py | 4 ++-- smart_control/utils/controller_writer.py | 4 ++-- smart_control/utils/conversion_utils.py | 6 +++--- smart_control/utils/energy_utils.py | 4 ++-- smart_control/utils/energy_utils_test.py | 4 ++-- smart_control/utils/environment_utils.py | 4 ++-- smart_control/utils/histogram_reducer.py | 6 +++--- smart_control/utils/histogram_reducer_test.py | 8 ++++---- smart_control/utils/observation_normalizer.py | 4 ++-- smart_control/utils/plot_utils.py | 2 +- smart_control/utils/reader_lib.py | 2 +- .../real_building_temperature_array_generator.py | 2 +- smart_control/utils/regression_building_utils.py | 4 ++-- smart_control/utils/run_command_predictor.py | 2 +- smart_control/utils/test_utils.py | 2 +- smart_control/utils/visual_logger.py | 2 +- smart_control/utils/writer_lib.py | 2 +- 58 files changed, 113 insertions(+), 119 deletions(-) diff --git a/smart_control/environment/environment.py b/smart_control/environment/environment.py index fb252059..c4f739a2 100644 --- a/smart_control/environment/environment.py +++ b/smart_control/environment/environment.py @@ -240,7 +240,7 @@ def compute_action_regularization_cost( Returns the L2 Norm of the actions as a penalty term for large changes. Args: - action_history: Seqential array of actions taken in the episode. + action_history: Sequential array of actions taken in the episode. Returns: A smoothing cost applied to the reward function for applying big changes. @@ -986,7 +986,7 @@ def _normalized_observation_response_to_observation_map_single_timeseries( continuous_value = single_observation_response.continuous_value if not single_observation_response.observation_valid: - logging.warn( + logging.warning( "Invalid observation reported %s %s %f", device_id, measurement_name, diff --git a/smart_control/environment/environment_test.py b/smart_control/environment/environment_test.py index 614ed0ec..6dfa464d 100644 --- a/smart_control/environment/environment_test.py +++ b/smart_control/environment/environment_test.py @@ -66,13 +66,13 @@ class EnvironmentTest(parameterized.TestCase, tf.test.TestCase): 2.236067, ), ) - def test_comput_actions_regularization_cost_valid( + def test_compute_actions_regularization_cost_valid( self, action_history, expected ): cost = environment.compute_action_regularization_cost(action_history) self.assertAlmostEqual(expected, cost, places=3) - def test_comput_actions_regularization_cost_invalid(self): + def test_compute_actions_regularization_cost_invalid(self): action_history = [np.array([1, 0]), np.array([1, 0, 1])] with self.assertRaises(ValueError): _ = environment.compute_action_regularization_cost(action_history) diff --git a/smart_control/environment/environment_test_utils.py b/smart_control/environment/environment_test_utils.py index ff64178a..3d15fc4f 100644 --- a/smart_control/environment/environment_test_utils.py +++ b/smart_control/environment/environment_test_utils.py @@ -1,4 +1,4 @@ -"""Shared test utiltiles for environment tests.""" +"""Shared test utilities for environment tests.""" import collections from typing import Sequence diff --git a/smart_control/models/base_building.py b/smart_control/models/base_building.py index 6e2e104d..3ffbc6a7 100644 --- a/smart_control/models/base_building.py +++ b/smart_control/models/base_building.py @@ -47,7 +47,7 @@ def wait_time(self) -> None: @abc.abstractmethod def reset(self) -> None: - """Resets the building, throwing an RuntimeError if this is impossible.""" + """Resets the building, throwing a RuntimeError if this is impossible.""" @property @abc.abstractmethod diff --git a/smart_control/models/base_energy_cost.py b/smart_control/models/base_energy_cost.py index 960d8b12..6b2f922d 100644 --- a/smart_control/models/base_energy_cost.py +++ b/smart_control/models/base_energy_cost.py @@ -38,7 +38,7 @@ def carbon( """Returns the mass of carbon emitted from the energy consumption. The energy-to-carbon emission is source specific. Assuming a constant - rate of energy consumption (W) of the time interval bounded by + rate of energy consumption (W) over the time interval bounded by start_time and end_time, we can estimate total energy use (J). The type of source will convert energy into carbon mass (kg). diff --git a/smart_control/reinforcement_learning/agents/networks/sac_networks.py b/smart_control/reinforcement_learning/agents/networks/sac_networks.py index d6646ab6..1ccee802 100644 --- a/smart_control/reinforcement_learning/agents/networks/sac_networks.py +++ b/smart_control/reinforcement_learning/agents/networks/sac_networks.py @@ -106,7 +106,7 @@ def split_inputs(inputs): class _TanhNormalProjectionNetworkWrapper( tanh_normal_projection_network.TanhNormalProjectionNetwork ): - """Wrapper to pass predefined `outer_rank` to underlying projection net.""" + """Wrapper to pass predefined `outer_rank` to underlying projection network.""" def __init__(self, sample_spec, predefined_outer_rank=1): super(_TanhNormalProjectionNetworkWrapper, self).__init__(sample_spec) diff --git a/smart_control/reinforcement_learning/scripts/populate_starter_buffer.py b/smart_control/reinforcement_learning/scripts/populate_starter_buffer.py index 16e2303f..9e70278c 100644 --- a/smart_control/reinforcement_learning/scripts/populate_starter_buffer.py +++ b/smart_control/reinforcement_learning/scripts/populate_starter_buffer.py @@ -70,7 +70,7 @@ def populate_replay_buffer( 'This buffer path already exists. This would override the existing' ' buffer. Please use another name' ) - raise FileExistsError('Buffer name already exists, would be overriden') from err # pylint: disable=line-too-long + raise FileExistsError('Buffer name already exists, would be overridden') from err # pylint: disable=line-too-long # Load environment logger.info('Loading environment from standard config') diff --git a/smart_control/reinforcement_learning/scripts/train.py b/smart_control/reinforcement_learning/scripts/train.py index 21d7b8ba..94c831ec 100644 --- a/smart_control/reinforcement_learning/scripts/train.py +++ b/smart_control/reinforcement_learning/scripts/train.py @@ -244,7 +244,7 @@ def train_agent( for i in range(train_iterations): # Get current training step value before operations current_step = train_step.numpy() - logger.exception( + logger.info( 'Starting training loop iteration %d (step %d)', i, current_step ) diff --git a/smart_control/reinforcement_learning/utils/config.py b/smart_control/reinforcement_learning/utils/config.py index 070aa697..0135f916 100644 --- a/smart_control/reinforcement_learning/utils/config.py +++ b/smart_control/reinforcement_learning/utils/config.py @@ -30,7 +30,7 @@ # pylint: enable=unused-import -# Relative filepaths. Consider moving to reinforcement_learning/constants.py +# Relative file paths. Consider moving to reinforcement_learning/constants.py # fmt: off # pylint: disable=line-too-long DATA_PATH = os.path.join(ROOT_DIR, "smart_control", "configs", "resources", "sb1") diff --git a/smart_control/reward/base_setpoint_energy_carbon_reward.py b/smart_control/reward/base_setpoint_energy_carbon_reward.py index d725c5e1..4c768e9a 100644 --- a/smart_control/reward/base_setpoint_energy_carbon_reward.py +++ b/smart_control/reward/base_setpoint_energy_carbon_reward.py @@ -16,7 +16,7 @@ class BaseSetpointEnergyCarbonRewardFunction(BaseRewardFunction): Attributes: max_productivity_personhour_usd: max productivity for average occupancy in $ - productivity_midpoint_delta: temp difference from setpoint of half prod. + productivity_midpoint_delta: temperature difference from setpoint of half productivity. productivity_decay_stiffness: midpoint slope of the decay curve """ @@ -155,7 +155,7 @@ def _sum_electricity_energy_rate( def _sum_natural_gas_energy_rate( self, energy_reward_info: smart_control_reward_pb2.RewardInfo ) -> float: - """Returns the sum of nat gas energy rate over the interval in W.""" + """Returns the sum of natural gas energy rate over the interval in W.""" # Sum up the power in Watts for the total power. gas_energy_rate = 0.0 diff --git a/smart_control/reward/electricity_energy_cost_test.py b/smart_control/reward/electricity_energy_cost_test.py index 6e033d62..18308cc3 100644 --- a/smart_control/reward/electricity_energy_cost_test.py +++ b/smart_control/reward/electricity_energy_cost_test.py @@ -96,7 +96,7 @@ def test_cost(self, start_time, end_time, energy_rate, expected_cost): 0.4410, ), ]) - def test_carbon_emisison( + def test_carbon_emission( self, start_time, end_time, energy_rate, expected_carbon ): cost = electricity_energy_cost.ElectricityEnergyCost() diff --git a/smart_control/reward/natural_gas_energy_cost_test.py b/smart_control/reward/natural_gas_energy_cost_test.py index 9ada9990..b14e36a2 100644 --- a/smart_control/reward/natural_gas_energy_cost_test.py +++ b/smart_control/reward/natural_gas_energy_cost_test.py @@ -40,7 +40,7 @@ def test_energy_cost(self, month, expected_cost): cost_estimate = cost.cost(start_time, end_time, energy_rate) self.assertAlmostEqual(expected_cost, cost_estimate, 2) - def test_carbon_emisison(self): + def test_carbon_emission(self): # Source: # https://www.eia.gov/environment/emissions/co2_vol_mass.php # 1 million BTUs nat gas generate 53.1 kg C02. diff --git a/smart_control/reward/setpoint_energy_carbon_regret.py b/smart_control/reward/setpoint_energy_carbon_regret.py index c840a3d2..259aed3f 100644 --- a/smart_control/reward/setpoint_energy_carbon_regret.py +++ b/smart_control/reward/setpoint_energy_carbon_regret.py @@ -8,7 +8,7 @@ For this pilot there are three principal factors that contribute to the reward function: * Setpoint: Maintaining the zone temperatures within heating and cooling - setpoints results in a positive reward, and any temperature outside of + setpoints results in a positive reward, and any temperature outside of setpoints may also result in a negative reward (i.e., penalty). * Cost: The cost of electricity and natural gas is a negative reward (cost). Then by minimizing negative rewards/maximizing positive reward, the agent diff --git a/smart_control/reward/setpoint_energy_carbon_reward.py b/smart_control/reward/setpoint_energy_carbon_reward.py index 3454a134..3b7dfd83 100644 --- a/smart_control/reward/setpoint_energy_carbon_reward.py +++ b/smart_control/reward/setpoint_energy_carbon_reward.py @@ -24,7 +24,7 @@ s(setpoint) is the reward for maintaining setpoint f(cost) is the cost of consuming electrical and natural gas energy g(carbon) is the cost of emitting carbon, - and u, w are weighing factors for cost and carbon depending on the policy. + and u, w are weighting factors for cost and carbon depending on the policy. The fundamental metric unit of energy is the Joule (J), and the unit of energy applied over a fixed time interval (energy rate) is power measured in J/sec or diff --git a/smart_control/simulator/air_handler.py b/smart_control/simulator/air_handler.py index 1f3ef99b..8daabb43 100644 --- a/smart_control/simulator/air_handler.py +++ b/smart_control/simulator/air_handler.py @@ -13,7 +13,7 @@ @gin.configurable class AirHandler(smart_device.SmartDevice): - """Models an air hander with heating/cooling, input/exhaust and recirculation. + """Models an air handler with heating/cooling, input/exhaust and recirculation. Attributes: recirculation: Proportion of air recirculated. @@ -45,7 +45,7 @@ def __init__( ): if cooling_air_temp_setpoint <= heating_air_temp_setpoint: raise ValueError( - 'cooling_air_temp_setpoint must greater than' + 'cooling_air_temp_setpoint must be greater than' ' heating_air_temp_setpoint' ) diff --git a/smart_control/simulator/air_handler_test.py b/smart_control/simulator/air_handler_test.py index 7961574e..a6a002bb 100644 --- a/smart_control/simulator/air_handler_test.py +++ b/smart_control/simulator/air_handler_test.py @@ -106,7 +106,7 @@ def test_get_mixed_air_temp( ): """Calculates the mixed air temperature. - This function is calculated by muliplying the recirculation_temp by + This function is calculated by multiplying the recirculation_temp by the recirculation factor, and the ambient_temp by 1 minus the recirculation factor, and adding the two. @@ -129,7 +129,7 @@ def test_get_mixed_air_temp( @parameterized.named_parameters( ('below setpoint window case 1', 0.3, 280, 240, 270), - ('below setpount window case 2', 0.6, 244, 270, 270), + ('below setpoint window case 2', 0.6, 244, 270, 270), ('above setpoint window case 1', 0.1, 210, 316, 288), ('above setpoint window case 2', 0.4, 250, 316, 288), ('in setpoint window case 1', 0.4, 286, 266, 0.4 * 286 + 0.6 * 266), diff --git a/smart_control/simulator/boiler.py b/smart_control/simulator/boiler.py index 33b89a0b..dbe1022a 100644 --- a/smart_control/simulator/boiler.py +++ b/smart_control/simulator/boiler.py @@ -263,11 +263,11 @@ def compute_thermal_dissipation_rate( ) -> float: """Returns the amount of thermal loss in W from a boiler tank. - Thermal dissipation is the loss of heat due from the tank to the environment + Thermal dissipation is the loss of heat from the tank to the environment due to imperfect insulation, measured in Watts. The tank is assumed to be a cylindrical annulus, with an internal radius - internal length, and an insulation thickness. Heat is dissapated only + internal length, and an insulation thickness. Heat is dissipated only through the cylinder walls, and no heat is lost through the ends/caps. The equation is computed by applying an energy balance of: diff --git a/smart_control/simulator/building.py b/smart_control/simulator/building.py index 17b9ce68..3c0a4214 100644 --- a/smart_control/simulator/building.py +++ b/smart_control/simulator/building.py @@ -259,7 +259,7 @@ def _construct_cv_type_array( ) -> np.ndarray: """Fills once the CV type matrix and save it. - In the original imlementation, + In the original implementation, the sweep() function would call the get_cv_type() function every time, repeating logic that only needed to be computed once and saved. @@ -390,7 +390,7 @@ class Building(BaseSimulatorBuilding): length of the building. temp: The current temp in K of each control volume. conductivity: Thermal conductivity in of each control volume W/m/K. - heat_capacity: Thermal heat cpacity of each control volume in J/kg/K. + heat_capacity: Thermal heat capacity of each control volume in J/kg/K. density: Material density in kg/m3 of each control volume. input_q: Heat energy applied (sign indicates heating/cooling) at the CV in W (J/s). diff --git a/smart_control/simulator/building_test.py b/smart_control/simulator/building_test.py index 72c79a9e..86617e82 100644 --- a/smart_control/simulator/building_test.py +++ b/smart_control/simulator/building_test.py @@ -807,7 +807,7 @@ def test_enlarge_exterior_walls(self): [0, 0, 0, 0, 0, 0, 0], ]) - expexted_interior_output = np.array([ + expected_interior_output = np.array([ [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], @@ -823,7 +823,7 @@ def test_enlarge_exterior_walls(self): with self.subTest("exterior_output"): np.testing.assert_array_equal(exterior_output, expected_exterior_output) with self.subTest("interior_output"): - np.testing.assert_array_equal(interior_output, expexted_interior_output) + np.testing.assert_array_equal(interior_output, expected_interior_output) def test_interior_air_values(self): initial_temp = 292.0 @@ -1691,7 +1691,7 @@ def test_stochastic_convection_simulator_shuffle_max_dist( continue self.assertEqual(b.temp[i][j], 292.0) - # lets reset and try again, to make sure the chache works + # lets reset and try again, to make sure the cache works # now lets change the temps in a room b.temp[2][2] = 1 b.temp[2][3] = 2 diff --git a/smart_control/simulator/building_utils.py b/smart_control/simulator/building_utils.py index 482bf6b5..d09fb0e7 100644 --- a/smart_control/simulator/building_utils.py +++ b/smart_control/simulator/building_utils.py @@ -129,7 +129,7 @@ def save_images_to_cns_for_debugging( def guarantee_air_padding_in_frame( floor_plan: FileInputFloorPlan, ) -> FileInputFloorPlan: - """Adds a row or column of air if a building is abuts its frame edge. + """Adds a row or column of air if a building abuts its frame edge. Future computation relies on buildings being surrounded by at least one layer of air CVs between them and the edge of the floor plan frame. @@ -175,7 +175,7 @@ def determine_row_size_of_exterior_space_to_add() -> np.ndarray: ) def determine_column_size_of_exterior_space_to_add() -> np.ndarray: - """A helper function to recompute a columns row to add from floor plan dim. + """A helper function to recompute a column row to add from floor plan dim. Returns: a column of constants.EXTERIOR_SPACE_VALUE_IN_FILE_INPUT's to concat if @@ -283,7 +283,7 @@ def _set_exterior_space_neg( """Modifies the connections array so that exterior space is negative. Encoding the exterior space as negative is important in the connections array - as it will encode an aribtrarily large number of rooms as positive integers. + as it will encode an arbitrarily large number of rooms as positive integers. Thus, setting the exterior space as negative ensures that we will always be able to deal with it as its own category of space. diff --git a/smart_control/simulator/constants.py b/smart_control/simulator/constants.py index 365b29be..8ae2e66c 100644 --- a/smart_control/simulator/constants.py +++ b/smart_control/simulator/constants.py @@ -34,13 +34,13 @@ # that designates exterior space in the file input. EXTERIOR_SPACE_VALUE_IN_FILE_INPUT = 2 -# Here we designate a specific placeholder to help use demarcate which CVs +# Here we designate a specific placeholder to help us demarcate which CVs # are for exterior space once processed in the function. It is intentionally # set to -1 so that the connectedComponent function can have access to all # nonzero integers to count upwards in an unbounded way. EXTERIOR_SPACE_VALUE_IN_FUNCTION = -1 -# Here we designate a specific placeholder to help use demarcate which CVs +# Here we designate a specific placeholder to help us demarcate which CVs # are for exterior space are noted in the component. It is intentionally # set to -1 so that the connectedComponent function can have access to all # nonzero integers to count upwards in an unbounded way. @@ -52,7 +52,7 @@ # Here we pick out a specific value that we know will code for interior space # after connectedComponents() processes it. We know this because we have ensured -# that the CV at index (0,0) will always be an "space" CV when ready for +# that the CV at index (0,0) will always be a "space" CV when ready for # input to connectedComponents, but we previously index the exterior space CVs # in their own data array. Thus, after overwriting the exterior space CVs to # the value _EXTERIOR_SPACE_VALUE_IN_FUNCTION, all connectedComponents of @@ -82,17 +82,11 @@ # returning expanded exterior walls when calling enlarge_component() WALLS_AND_EXPANDED_BOOLS = 2 -# Here we wish to specifically set exterior space as indistinguishable -# from exterior walls, as we wish to perform connectedComponents only on -# connected groups of interior space. Thus, we set exterior space to a generic -# space value, i.e. 0. -GENERIC_SPACE_VALUE_IN_CONNECTION_INPUT = 0 - # Here we use a specific placeholder value, matching with the file input schema, # that designates interior space in the file input. INTERIOR_WALL_VALUE_IN_FILE_INPUT = 1 -# Here we designate a specific placeholder to help use demarcate which CVs +# Here we designate a specific placeholder to help us demarcate which CVs # are for interior walls once processed in the function. It is intentionally # set to -3 so that the connectedComponent function can have access to all # nonzero integers to count upwards in an unbounded way. diff --git a/smart_control/simulator/hvac.py b/smart_control/simulator/hvac.py index 8e2c5af6..39cb9537 100644 --- a/smart_control/simulator/hvac.py +++ b/smart_control/simulator/hvac.py @@ -44,7 +44,7 @@ def __init__( Args: zone_coordinates: List of 2-tuple containing zone coordinates to service. - air_handler: the air handler for hte HVAC + air_handler: the air handler for the HVAC boiler: the boiler for the HVAC schedule: the setpoint_schedule for the thermostats vav_max_air_flow_rate: the max airflow rate for the vavs diff --git a/smart_control/simulator/hvac_test.py b/smart_control/simulator/hvac_test.py index 06b549d4..2431871c 100644 --- a/smart_control/simulator/hvac_test.py +++ b/smart_control/simulator/hvac_test.py @@ -199,7 +199,7 @@ def test_vav_device_ids(self): self.assertListEqual(vav_ids, expected_vav_ids) - def test_id_comfort_mode(self): + def test_is_comfort_mode(self): zone_coordinates = [(0, 0), (1, 0), (1, 1), (0, 1)] handler = _get_default_air_handler() b = _get_default_boiler() diff --git a/smart_control/simulator/randomized_arrival_departure_occupancy.py b/smart_control/simulator/randomized_arrival_departure_occupancy.py index fc6948c1..0c4365dc 100644 --- a/smart_control/simulator/randomized_arrival_departure_occupancy.py +++ b/smart_control/simulator/randomized_arrival_departure_occupancy.py @@ -28,8 +28,8 @@ class ZoneOccupant: """Represents a single occupant in a zone. Attributes: - earliest_expected_arrival_hour: earliest arrivel, 0 - 22 - latest_expected_arrival_hour: latest arrivel, 1 - 23 + earliest_expected_arrival_hour: earliest arrival, 0 - 22 + latest_expected_arrival_hour: latest arrival, 1 - 23 earliest_expected_departure_hour: earliest departure, 0 - 22 latest_expected_departure_hour: latest departure, 1 - 23 random_state: random state used to generate events @@ -82,8 +82,8 @@ def _get_event_probability(self, start_hour, end_hour): # The halfway point is the firts half of the trials. n_halfway = window / self._step_size / 2.0 # We'd like to return the probability of event happening in a single time- - # step. This follow a geometric distribution, where E[X] = 1/p, where - # E[x] is the expected number of events before the first success. If + # step. This follows a geometric distribution, where E[X] = 1/p, where + # E[X] is the expected number of events before the first success. If # E[X] is the halfway point, then p = 1 / n_halfway. return 1.0 / n_halfway @@ -91,7 +91,7 @@ def _occupant_arrived(self, timestamp): """Makes a random draw to determine whether occupant arrives.""" local_timestamp = self._to_local_time(timestamp) - # TODO(sipple): Consider effects when time crosses DST> + # TODO(sipple): Consider effects when time crosses DST. if ( local_timestamp.hour < self._earliest_expected_arrival_hour or local_timestamp.hour > self._latest_expected_arrival_hour @@ -138,8 +138,8 @@ class RandomizedArrivalDepartureOccupancy(BaseOccupancy): Attributes: zone_assignment: number of occupants in a zone - earliest_expected_arrival_hour: earliest arrivel, 0 - 22 - latest_expected_arrival_hour: latest arrivel, 1 - 23 + earliest_expected_arrival_hour: earliest arrival, 0 - 22 + latest_expected_arrival_hour: latest arrival, 1 - 23 earliest_expected_departure_hour: earliest departure, 0 - 22 latest_expected_departure_hour: latest departure, 1 - 23 seed: integer used to set the random state for repeatability diff --git a/smart_control/simulator/rejection_simulator_building.py b/smart_control/simulator/rejection_simulator_building.py index a67ffb9d..65c09079 100644 --- a/smart_control/simulator/rejection_simulator_building.py +++ b/smart_control/simulator/rejection_simulator_building.py @@ -17,7 +17,7 @@ @gin.configurable class RejectionSimulatorBuilding(BaseBuilding): - """A Building that throws exception while agent is awaiting authorization.""" + """A Building that throws exceptions while agent is awaiting authorization.""" def __init__( self, base_building: BaseBuilding, initial_rejection_count: int = 0 diff --git a/smart_control/simulator/simulator.py b/smart_control/simulator/simulator.py index 5d79b838..df6b9c49 100644 --- a/smart_control/simulator/simulator.py +++ b/smart_control/simulator/simulator.py @@ -93,7 +93,7 @@ def _get_corner_cv_temp_estimate( """Returns temperature estimate for corner CV in K for next time step. This function calculates the solution to an equation involving the energy - transfer by conduction to neighoring air CVs as well as energy transfer by + transfer by conduction to neighboring air CVs as well as energy transfer by convection from the external ambient air. Args: @@ -139,7 +139,7 @@ def _get_edge_cv_temp_estimate( """Returns temperature estimate for edge CV in K for next time step. This function calculates the solution to an equation involving the energy - transfer by conduction to neighoring air CVs as well as energy transfer by + transfer by conduction to neighboring air CVs as well as energy transfer by convection from the external ambient air. Args: @@ -188,7 +188,7 @@ def _get_interior_cv_temp_estimate( """Returns temperature estimate for interior CV in K for next time step. This function calculates the solution to an equation involving the energy - transfer by conduction to neighoring air CVs as well as energy transfer + transfer by conduction to neighboring air CVs as well as energy transfer from heat input to the CV from a diffuser. Args: @@ -281,7 +281,7 @@ def update_temperature_estimates( convection_coefficient: Current wind convection coefficient (W/m2/K). Returns: - Maximum difference in temperture_estimates across all CVs before and after + Maximum difference in temperature_estimates across all CVs before and after operation. """ nrows, ncols = temperature_estimates.shape @@ -317,7 +317,7 @@ def finite_differences_timestep( 3. Calculate the difference between previous T and new T. If the maximum difference in the grid is less than some small constant, - conversion_threshold, then quit. Otherwise, return to step 2. + convergence_threshold, then quit. Otherwise, return to step 2. The update_temperature_estimates function performs steps 2, and 3. @@ -449,7 +449,7 @@ def _get_zone_reward_info( zone_id: str, zone_air_temperature: float, ) -> RewardInfo.ZoneRewardInfo: - """Returns a messagde with zone data to compute the instantaneous reward.""" + """Returns a message with zone data to compute the instantaneous reward.""" schedule = self._hvac.vavs[zone_coords].thermostat.get_setpoint_schedule() heating_setpoint_temperature, cooling_setpoint_temperature = ( schedule.get_temperature_window(self._current_timestamp) diff --git a/smart_control/simulator/simulator_building.py b/smart_control/simulator/simulator_building.py index 62d9942e..84e9c1ef 100644 --- a/smart_control/simulator/simulator_building.py +++ b/smart_control/simulator/simulator_building.py @@ -82,7 +82,7 @@ def _class_to_value_type(self, clazz: Type[object]) -> _ValueType: if clazz == float: return _ValueType.VALUE_CONTINUOUS elif clazz == int: - # TODO(gusatb): Handle non continuous values. + # TODO(gusatb): Handle non-continuous values. return _ValueType.VALUE_CONTINUOUS else: return _ValueType.VALUE_TYPE_UNDEFINED diff --git a/smart_control/simulator/simulator_building_test_lib.py b/smart_control/simulator/simulator_building_test_lib.py index 8e7279db..a71eb41a 100644 --- a/smart_control/simulator/simulator_building_test_lib.py +++ b/smart_control/simulator/simulator_building_test_lib.py @@ -111,7 +111,7 @@ def _create_small_hvac(self): return hvac def _create_small_simulator(self): - """Creats a small simulator for test.""" + """Creates a small simulator for test.""" # Set up simulation parameters weather_controller = weather_controller_py.WeatherController(296.0, 296.0) time_step_sec = 300.0 @@ -259,7 +259,7 @@ def test_request_observation_incorrect_device(self): ) def test_request_observation_incorrect_measurement(self): - """Tests when an observation is requested for a nonexistnt measurement.""" + """Tests when an observation is requested for a nonexistent measurement.""" simulator_building = self.get_sim_building() observation_request = smart_control_building_pb2.ObservationRequest() diff --git a/smart_control/simulator/simulator_flexible_floor_plan.py b/smart_control/simulator/simulator_flexible_floor_plan.py index 8a91a507..0497bad6 100644 --- a/smart_control/simulator/simulator_flexible_floor_plan.py +++ b/smart_control/simulator/simulator_flexible_floor_plan.py @@ -28,7 +28,7 @@ class SimulatorFlexibleGeometries(simulator.Simulator): """Simulates thermodynamics of a building with flexible geometries. - NOTE: post-refector + NOTE: post-refactor This simulator uses finite differences method (FDM) to approximate the temperature changes in each Control Volume (CV) in a building. This happens @@ -160,7 +160,7 @@ def execute_step_sim( if vav.flow_rate_demand > 0: hvac.air_handler.add_demand(vav.flow_rate_demand) - # Update the boiler demand for hot water as the sum of each VAV"s demand. + # Update the boiler demand for hot water as the sum of each VAV's demand. if vav.reheat_demand > 0: hvac.boiler.add_demand(vav.reheat_demand) diff --git a/smart_control/simulator/simulator_flexible_floor_plan_test.py b/smart_control/simulator/simulator_flexible_floor_plan_test.py index e168593a..79b9d167 100644 --- a/smart_control/simulator/simulator_flexible_floor_plan_test.py +++ b/smart_control/simulator/simulator_flexible_floor_plan_test.py @@ -580,7 +580,7 @@ def test_reset(self): self.assertEqual(simulator.building.input_q[0][3], 0) def test_get_cv_temp_estimate_cell_no_change(self): - """This tests that temperatures don"t change in stable conditions. + """This tests that temperatures don't change in stable conditions. This test sets up a small building at temperature 292. The ambient conditions are also 292. diff --git a/smart_control/simulator/smart_device.py b/smart_control/simulator/smart_device.py index e5cabc29..b3aeaa01 100644 --- a/smart_control/simulator/smart_device.py +++ b/smart_control/simulator/smart_device.py @@ -168,7 +168,7 @@ def set_action( action_timestamp: Timestamp of the action Raises: - AttributeError: If requested field was not declared action or does + AttributeError: If requested field was not declared as action or does not exist. ValueError: If given value is not the declared type. diff --git a/smart_control/simulator/step_function_occupancy.py b/smart_control/simulator/step_function_occupancy.py index 9de06f7c..a69394be 100644 --- a/smart_control/simulator/step_function_occupancy.py +++ b/smart_control/simulator/step_function_occupancy.py @@ -122,7 +122,7 @@ def _split_workday( during_work = 0.0 after_work = 0.0 - # Step through before work, during work, and afterwork phases, and + # Step through before work, during work, and after work phases, and # add up the times in seconds. If the current time is before any # phase, do not add any time, and truncate. # If the end_time precedes any phase, truncate the phase, and do not @@ -134,7 +134,7 @@ def _split_workday( # Before work start: next_step = min(interval_end, self._work_start_time) - # Get the time between the curren time and the next step. + # Get the time between the current time and the next step. if current < next_step: before_work = (next_step - current).total_seconds() current = max(current, next_step) @@ -145,7 +145,7 @@ def _split_workday( during_work = (next_step - current).total_seconds() current = next_step - # Finally, between work end and modnight. + # Finally, between work end and midnight. next_step = interval_end if current < next_step: after_work = (next_step - current).total_seconds() diff --git a/smart_control/simulator/stochastic_convection_simulator.py b/smart_control/simulator/stochastic_convection_simulator.py index a78b8250..ea9332b5 100644 --- a/smart_control/simulator/stochastic_convection_simulator.py +++ b/smart_control/simulator/stochastic_convection_simulator.py @@ -1,4 +1,4 @@ -"""Stochastic simulator of convection flow in bldg. +"""Stochastic simulator of convection flow in building. A convection simulator that randomly shuffles control volumes as a stochastic imitation of convection. @@ -74,7 +74,7 @@ def apply_convection( self._shuffle_max_dist(p, v, distance, temp) def _shuffle_no_max_dist(self, v, temp): - """Special case of shuffling when no max dist is specified.and p=1. + """Special case of shuffling when no max dist is specified and p=1. Args: v: list of CVs to shuffle diff --git a/smart_control/simulator/tf_simulator.py b/smart_control/simulator/tf_simulator.py index 4797c979..f84bb8c4 100644 --- a/smart_control/simulator/tf_simulator.py +++ b/smart_control/simulator/tf_simulator.py @@ -522,7 +522,7 @@ def __init__( n_boundary_elements = len(self._boundary_cv_mapping) logging.info('Number of boundary CVs: %d', n_boundary_elements) # Get a binary mask that mark exterior CVs so that they will always be - # assigned ambinent air temps. + # assigned ambient air temps. self._t_exerior_temps_mask = self._get_tensor_exterior_mask(building) n_exterior_elements = tf.math.count_nonzero(self._t_exerior_temps_mask) logging.info('Number of exterior CVs: %d', n_exterior_elements) @@ -769,7 +769,7 @@ def _get_numerator( t_temp, ambient_temperature ) - # Get the ambinet temperature as a tensor. + # Get the ambient temperature as a tensor. t_temp_inf = tf.constant(ambient_temperature, dtype=tf.float32) # Convert the timestep input to tensor. @@ -831,7 +831,7 @@ def _get_numerator( t_temperature_estimates = tf.math.divide(t_numer, t_denom) # The tensor operation potentially altered the exterior air conditions, - # so we need to reset exterior CVs to the exterior air conditioners. + # so we need to reset exterior CVs to the exterior air conditions. t_temperature_estimates = apply_exterior_temps( t_temperature_estimates, t_temp_inf, self._t_exerior_temps_mask ) diff --git a/smart_control/simulator/tf_simulator_test.py b/smart_control/simulator/tf_simulator_test.py index 51199352..9a7e722c 100644 --- a/smart_control/simulator/tf_simulator_test.py +++ b/smart_control/simulator/tf_simulator_test.py @@ -679,7 +679,7 @@ def test_finite_difference_one_step(self): self.assertLessEqual(7.0, max_delta) def test_finite_difference_convergence(self): - """Tests that the FD problem converges within a fixed numbe of steps.""" + """Tests that the FD problem converges within a fixed number of steps.""" weather_controller = mock.create_autospec( weather_controller_py.WeatherController ) diff --git a/smart_control/simulator/thermal_diffuser_utils.py b/smart_control/simulator/thermal_diffuser_utils.py index c9cbd36a..3715fbdc 100644 --- a/smart_control/simulator/thermal_diffuser_utils.py +++ b/smart_control/simulator/thermal_diffuser_utils.py @@ -1,6 +1,6 @@ """Code for generating thermal diffusers in a building. -These helper functions are separated these out into their own file for +These helper functions are separated out into their own file for extensibility: we can easily put in another function loading these from data and process this using similar function format. """ @@ -206,7 +206,7 @@ def diffuser_allocation_switch( spacing: how many control volumes to put between each diffuser interior_walls: an InteriorWalls for determining whether thermal diffusers are allocated in walls. This measure is intended for cases in which one - needs to provide a interior_walls and zone_map to the Building class, and + needs to provide an interior_walls and zone_map to the Building class, and they may not line up correctly on account of being from different photo sources. buffer_from_walls: how far to place a thermal diffuser away from a wall. @@ -234,7 +234,7 @@ def diffuser_allocation_switch( ## TODO(spangher): This dilate function throws errors when # iterations is greater than 0, which takes away an effort I had - # started to make sure that thermal diffusers are not placed closed to + # started to make sure that thermal diffusers are not placed close to # walls. If data anchoring proceeds with trouble, please consider # restarting the effort to place a buffer in between diffusers and walls. diff --git a/smart_control/simulator/thermostat.py b/smart_control/simulator/thermostat.py index 4b64edfb..ef6640c9 100644 --- a/smart_control/simulator/thermostat.py +++ b/smart_control/simulator/thermostat.py @@ -28,7 +28,7 @@ class Thermostat: Is constructed by passing in a SetpointSchedule, which, for any timestamp, provides heating and cooling setpoints, as well as whether the thermostat - should operate in Eco mode/. + should operate in Eco mode. Attributes: _setpoint_schedule: SetpointSchedule to determine temperature windows. @@ -122,7 +122,7 @@ def update( and self._setpoint_schedule.is_comfort_mode(self._previous_timestamp) ): self._current_mode = self.Mode.PASSIVE_COOL - # Been in eco mod + # Been in eco mode else: if ( self._current_mode == self.Mode.PASSIVE_COOL diff --git a/smart_control/simulator/weather_controller.py b/smart_control/simulator/weather_controller.py index 272d49a4..ccde82cc 100644 --- a/smart_control/simulator/weather_controller.py +++ b/smart_control/simulator/weather_controller.py @@ -150,7 +150,7 @@ def get_outside_air_temp(observation_response): @gin.configurable class ReplayWeatherController: - """Weather controller that interplolates real weather from past observations. + """Weather controller that interpolates real weather from past observations. Attributes: local_weather_path: Path to local weather file. @@ -182,7 +182,7 @@ def get_current_temp(self, timestamp: pd.Timestamp) -> float: if timestamp < min_time: raise ValueError( - f'Attempting to get weather data at {timestamp}, before the latest' + f'Attempting to get weather data at {timestamp}, before the earliest' f' timestamp {min_time}.' ) max_time = max(self._weather_data['Time']) diff --git a/smart_control/utils/agent_utils.py b/smart_control/utils/agent_utils.py index 2d425b30..fdde1a33 100644 --- a/smart_control/utils/agent_utils.py +++ b/smart_control/utils/agent_utils.py @@ -8,7 +8,7 @@ # PolicyStep = number of agent steps to hold the policy constant. # Using a custom type of Tuple[int, Tensor] since it provides a # named type while retaining the structure and form defined by -# TF-Agants. +# TF-Agents. PolicyStep = Tuple[int, tf.Tensor] # Policy = a list of policy steps in the episode. Policy = Sequence[PolicyStep] @@ -30,11 +30,11 @@ def create_random_walk_collect_script( hold for (1 or more), and the second is a Tensor of actions to apply, which are bounded. The policy length are the number of transitions provided. - A random walk script is a a scripted policy that takes a random step + A random walk script is a scripted policy that takes a random step of size random_step_magnitude, independently for each action dimension, which is held constant for time_steps_per_random_step. - The random walk is a a technique to enable the agent to explore action space. + The random walk is a technique to enable the agent to explore action space. Args: fixed_policy: A Tensor of initial values for the random walk. diff --git a/smart_control/utils/agent_utils_test.py b/smart_control/utils/agent_utils_test.py index 46eb2bcc..53931f88 100644 --- a/smart_control/utils/agent_utils_test.py +++ b/smart_control/utils/agent_utils_test.py @@ -55,11 +55,11 @@ def test_create_random_walk_collect_script( # Check step sizes are no larger than random_step_magnitude. with self.subTest(name='CheckStepMagnitude'): - dif = tf.math.subtract(last_step[1], step[1]) - abs_dif = tf.math.abs(dif) - max_dif = np.max(abs_dif.numpy()) + diff = tf.math.subtract(last_step[1], step[1]) + abs_diff = tf.math.abs(diff) + max_diff = np.max(abs_diff.numpy()) # Need to add small tolerance (1e-6) due to float32 imprecision. - self.assertLessEqual(max_dif, random_step_magnitude + 1e-6) + self.assertLessEqual(max_diff, random_step_magnitude + 1e-6) # Check that the results are always inside upper and lower limits. with self.subTest(name='CheckMaxValue'): diff --git a/smart_control/utils/building_renderer.py b/smart_control/utils/building_renderer.py index 76cf395f..7d8dea11 100644 --- a/smart_control/utils/building_renderer.py +++ b/smart_control/utils/building_renderer.py @@ -27,7 +27,7 @@ class BuildingRenderer: def __init__( self, building_layout: building_utils.FileInputFloorPlan, cv_size: int = 6 ): - """Initializes the foreground image, ie the walls of the building. + """Initializes the foreground image, i.e. the walls of the building. Args: building_layout: an array representing where the walls are in the building diff --git a/smart_control/utils/controller_reader.py b/smart_control/utils/controller_reader.py index cf599190..1c78db05 100644 --- a/smart_control/utils/controller_reader.py +++ b/smart_control/utils/controller_reader.py @@ -158,7 +158,7 @@ def _between( start_time: pd.Timestamp, end_time: pd.Timestamp, ) -> bool: - """Turns true if timestamp is equal or between start and end times.""" + """Returns true if timestamp is equal or between start and end times.""" return (timestamp >= start_time) and (timestamp <= end_time) return [ @@ -221,7 +221,7 @@ def read_normalization_info( def get_episode_data(working_dir: str) -> pd.DataFrame: """Returns a dataframe with details about each episode. - In retrieving the summaries of the of the experiment there are various + In retrieving the summaries of the experiment there are various time-stamped files/directories: (1) The episode directory format is [episode_label]_[yymmdd_hhmmss UTC]. (2) The updates (RewardInfo, RewardResponse, ActionResponse, and diff --git a/smart_control/utils/controller_writer.py b/smart_control/utils/controller_writer.py index ad25c8ff..5167f170 100644 --- a/smart_control/utils/controller_writer.py +++ b/smart_control/utils/controller_writer.py @@ -137,7 +137,7 @@ def write_device_infos( """Writes the device infos to disk.""" filepath = os.path.join(self._output_dir, constants.DEVICE_INFO_PREFIX) if os.path.exists(filepath): - logging.info('Deleting an exiting DeviceInfo file.') + logging.info('Deleting an existing DeviceInfo file.') os.remove(filepath) for device_info in device_infos: self._write_msg_to_disk(device_info, filepath) @@ -148,7 +148,7 @@ def write_zone_infos( """Writes the zone infos to disk.""" filepath = os.path.join(self._output_dir, constants.ZONE_INFO_PREFIX) if os.path.exists(filepath): - logging.info('Deleting an exiting ZoneInfo file.') + logging.info('Deleting an existing ZoneInfo file.') os.remove(filepath) for zone_info in zone_infos: self._write_msg_to_disk(zone_info, filepath) diff --git a/smart_control/utils/conversion_utils.py b/smart_control/utils/conversion_utils.py index 50f22c2f..9d12cfd4 100644 --- a/smart_control/utils/conversion_utils.py +++ b/smart_control/utils/conversion_utils.py @@ -78,7 +78,7 @@ def normalize_dow(dow: int) -> float: def normalize_hod(hod: int) -> float: - """Returns a normlized hour of day, mapping [0,23] to [-1., 1.].""" + """Returns a normalized hour of day, mapping [0,23] to [-1., 1.].""" assert hod <= 23 and hod >= 0 return (float(hod) - 11.5) / 11.5 @@ -141,7 +141,7 @@ def fahrenheit_to_kelvin(fahrenheit: float) -> float: """Converts °F to Kelvin. Args: - fahrenheit: Temperature in Kelvin, where 273K = 32°F. + fahrenheit: Temperature in Fahrenheit, where 32°F = 273K. Returns: The temperature in K. @@ -149,7 +149,7 @@ def fahrenheit_to_kelvin(fahrenheit: float) -> float: Raises: A ValueError if the input value <= absolute 0, −459.67°F. """ - if fahrenheit <= -495.67: + if fahrenheit <= -459.67: raise ValueError('Temperature must be greater than absolute zero.') celsius = (fahrenheit - 32.0) * 5.0 / 9.0 return celsius + 273.15 diff --git a/smart_control/utils/energy_utils.py b/smart_control/utils/energy_utils.py index e2a9fd87..7e782418 100644 --- a/smart_control/utils/energy_utils.py +++ b/smart_control/utils/energy_utils.py @@ -154,12 +154,12 @@ def get_fan_power( The fan power in Watts. Raises: - ValueError if neither design_hp or break_hp are provided. + ValueError if neither design_hp or brake_hp are provided. """ if design_hp is None and brake_hp is None: raise ValueError( - 'Must provide either design horseposer or brake horsepower.' + 'Must provide either design horsepower or brake horsepower.' ) if fan_speed_percentage is None: diff --git a/smart_control/utils/energy_utils_test.py b/smart_control/utils/energy_utils_test.py index 8e5a1ed8..cfad9d1a 100644 --- a/smart_control/utils/energy_utils_test.py +++ b/smart_control/utils/energy_utils_test.py @@ -156,7 +156,7 @@ def test_get_compressor_power_utilization_invalid( def test_get_water_pump_power_valid( self, pump_duty_cycle, - pump_speed_percantage, + pump_speed_percentage, brake_horse_power, design_horse_power, motor_factor, @@ -165,7 +165,7 @@ def test_get_water_pump_power_valid( ): p1 = energy_utils.get_water_pump_power( pump_duty_cycle=pump_duty_cycle, - pump_speed_percentage=pump_speed_percantage, + pump_speed_percentage=pump_speed_percentage, brake_horse_power=brake_horse_power, design_motor_horse_power=design_horse_power, motor_factor=motor_factor, diff --git a/smart_control/utils/environment_utils.py b/smart_control/utils/environment_utils.py index 03edaeb1..468f0195 100644 --- a/smart_control/utils/environment_utils.py +++ b/smart_control/utils/environment_utils.py @@ -9,13 +9,13 @@ @gin.configurable def to_timestamp(date_str: str) -> pd.Timestamp: - """Utilty macro for gin config.""" + """Utility macro for gin config.""" return pd.Timestamp(date_str) @gin.configurable def local_time(time_str: str) -> pd.Timedelta: - """Utilty macro for gin config.""" + """Utility macro for gin config.""" return pd.Timedelta(time_str) diff --git a/smart_control/utils/histogram_reducer.py b/smart_control/utils/histogram_reducer.py index f8a1ce9f..1d9af08f 100644 --- a/smart_control/utils/histogram_reducer.py +++ b/smart_control/utils/histogram_reducer.py @@ -73,7 +73,7 @@ def assign_devices_to_bins( Returns: A jagged array with outer dim for each bin, and inner array with device ids. """ - # Create a an eply assignment as a list of lists, one list per bin. + # Create an empty assignment as a list of lists, one list per bin. assignment = [[] for _ in range(len(bins))] for ( @@ -197,7 +197,7 @@ class HistogramReducer(BaseReducer): representing each zone as a separate timeseries is rather inefficient. Reduce function converts a feature from timeseries into a histogram. - For exammple, devices d1, d2 have a zone_air_temperature timeseries, + For example, devices d1, d2 have a zone_air_temperature timeseries, the histogram reducer converts the timeseries into a counts on temperature bins, like 70, 71, 72, etc. and assigns a count to the bin. This reduces the dimensionality into a more compressed format if the number of the devices @@ -432,7 +432,7 @@ def reduce(self, observation_sequence: pd.DataFrame) -> BaseReducedSequence: observation_sequence, feature_mapping ) - # Join the passthrough and the rediced sequences into a single dataframe. + # Join the passthrough and the reduced sequences into a single dataframe. reduced_sequence = passthrough_sequence if reduced_feature_dfs: df_hist = pd.concat(reduced_feature_dfs, axis=1) diff --git a/smart_control/utils/histogram_reducer_test.py b/smart_control/utils/histogram_reducer_test.py index 481251ac..f6571538 100644 --- a/smart_control/utils/histogram_reducer_test.py +++ b/smart_control/utils/histogram_reducer_test.py @@ -407,7 +407,7 @@ def test_histogram_reducer_expand_with_update(self): reduced_sequence = rs.reduced_sequence - # Override the values with updetd predictions: + # Override the values with updated predictions: predicted_measurements = [15.0, 16.0, 17.0] reduced_sequence[('A', 'm2')] = predicted_measurements @@ -514,10 +514,10 @@ def test_assign_devices_to_bins(self): ) # Since D is associated with m1, and this assignment is for m0, - # D should not appear in the expectec assignment. - expected_assignmant = [['A'], ['B'], [], [], ['C']] + # D should not appear in the expected assignment. + expected_assignment = [['A'], ['B'], [], [], ['C']] - self.assertEqual(assignment, expected_assignmant) + self.assertEqual(assignment, expected_assignment) def _get_test_observation_response( self, device_ids, measurement_names, values diff --git a/smart_control/utils/observation_normalizer.py b/smart_control/utils/observation_normalizer.py index f20568e3..7ee2305a 100644 --- a/smart_control/utils/observation_normalizer.py +++ b/smart_control/utils/observation_normalizer.py @@ -20,7 +20,7 @@ class StandardScoreObservationNormalizer( """Normalizes and denormalizes ObservationResponses and ActionResponses. Normalization is simply a shift by mean and scale by sqrt(variance). - Native variable: variable value in original form, before normlization. + Native variable: variable value in original form, before normalization. Normalized variable: variable shifted and scaled, after normalization. Attributes: @@ -106,7 +106,7 @@ def _transform_observation( Args: obs_in: input ObservationResponse - transform_func: normallization or denormlization function + transform_func: normalization or denormalization function Returns: an ObservationResponse with the same fields, but transformed values. diff --git a/smart_control/utils/plot_utils.py b/smart_control/utils/plot_utils.py index 4bab3485..f6e589b5 100644 --- a/smart_control/utils/plot_utils.py +++ b/smart_control/utils/plot_utils.py @@ -436,7 +436,7 @@ def plot_combined_results( def init_metrics(): - """Initializes the metrics for sumlation.""" + """Initializes the metrics for simulation.""" metrics = {} metrics['timestamps'] = [] diff --git a/smart_control/utils/reader_lib.py b/smart_control/utils/reader_lib.py index 11e1c53a..f21d1c5a 100644 --- a/smart_control/utils/reader_lib.py +++ b/smart_control/utils/reader_lib.py @@ -17,7 +17,7 @@ class BaseReader(metaclass=abc.ABCMeta): - """Abstract base class for writing the building and reward protos.""" + """Abstract base class for reading the building and reward protos.""" @abc.abstractmethod def read_observation_responses( diff --git a/smart_control/utils/real_building_temperature_array_generator.py b/smart_control/utils/real_building_temperature_array_generator.py index c6df812b..87f137bd 100644 --- a/smart_control/utils/real_building_temperature_array_generator.py +++ b/smart_control/utils/real_building_temperature_array_generator.py @@ -1,4 +1,4 @@ -"""Utility to go from list of VAV temperatues, to a teperature array.""" +"""Utility to go from list of VAV temperatures, to a temperature array.""" from typing import Mapping, Sequence diff --git a/smart_control/utils/regression_building_utils.py b/smart_control/utils/regression_building_utils.py index 0d9572a8..6a941a54 100644 --- a/smart_control/utils/regression_building_utils.py +++ b/smart_control/utils/regression_building_utils.py @@ -130,7 +130,7 @@ def get_observation_sequence( Returns: a pandas DF, one row for each ObservationResponse and columns for each - (device, meausrement) pair, and also timestamp and Day of Week (dow) + (device, measurement) pair, and also timestamp and Day of Week (dow) and Hour of Day (hod) features. """ @@ -643,7 +643,7 @@ def get_boiler_reward_infos( boiler_reward_infos = {} for device_id in reward_info_devices: # Determine this device is a boiler by its fields, not its name. - # To be a boiler (HW system) is must reoprt both a natural gas heating and + # To be a boiler (HW system) is must report both a natural gas heating and # pump electric power. if _NATURAL_GAS_HEATING_ENERGY_RATE in reward_info_devices[device_id]: natural_has_heating_energy_rate = reward_info_devices[device_id][ diff --git a/smart_control/utils/run_command_predictor.py b/smart_control/utils/run_command_predictor.py index abcee4c9..62b579c0 100644 --- a/smart_control/utils/run_command_predictor.py +++ b/smart_control/utils/run_command_predictor.py @@ -5,7 +5,7 @@ and temperatures, and a discrete on/off run command. Multiple attempts have failed to train an agent to manage the hybrid action -space effectively, but given pressure and temperature setting, it is easy to +space effectively, but given pressure and temperature settings, it is easy to train a classifier to estimate the run command for both air conditioners and hot water systems. This CL adds in the RunCommand predictor that predicts if the device is on or off based on its temp and pressure features. diff --git a/smart_control/utils/test_utils.py b/smart_control/utils/test_utils.py index 8c30932f..b7da7a49 100644 --- a/smart_control/utils/test_utils.py +++ b/smart_control/utils/test_utils.py @@ -326,7 +326,7 @@ def get_test_reward_response( def get_device_infos() -> Sequence[smart_control_building_pb2.DeviceInfo]: - """Returns pre-defined DeviceInfos for unit test.""" + """Returns pre-defined DeviceInfos for unit tests.""" d0 = smart_control_building_pb2.DeviceInfo( device_id='d0', diff --git a/smart_control/utils/visual_logger.py b/smart_control/utils/visual_logger.py index 037dc052..a0a62e4a 100644 --- a/smart_control/utils/visual_logger.py +++ b/smart_control/utils/visual_logger.py @@ -18,7 +18,7 @@ class VisualLogger: """ def __init__(self, renderer: building_renderer.BuildingRenderer): - """Initializes the forground image, ie the walls of the building. + """Initializes the foreground image, ie the walls of the building. Args: renderer: a building renderer diff --git a/smart_control/utils/writer_lib.py b/smart_control/utils/writer_lib.py index dee56c85..3328c855 100644 --- a/smart_control/utils/writer_lib.py +++ b/smart_control/utils/writer_lib.py @@ -89,4 +89,4 @@ class BaseWriterFactory(metaclass=abc.ABCMeta): @abc.abstractmethod def create(self, output_dir: PathLocation) -> BaseWriter: - """Creates a writer with a output directory.""" + """Creates a writer with an output directory.""" From aa881a172e69dfa73bcf54a4c3d91998be0bc7cd Mon Sep 17 00:00:00 2001 From: codewithbear Date: Fri, 11 Jul 2025 09:40:32 +0100 Subject: [PATCH 2/2] fix long lines --- .../reinforcement_learning/agents/networks/sac_networks.py | 2 +- smart_control/reward/base_setpoint_energy_carbon_reward.py | 2 +- smart_control/simulator/air_handler.py | 3 ++- smart_control/simulator/simulator.py | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/smart_control/reinforcement_learning/agents/networks/sac_networks.py b/smart_control/reinforcement_learning/agents/networks/sac_networks.py index 1ccee802..d6646ab6 100644 --- a/smart_control/reinforcement_learning/agents/networks/sac_networks.py +++ b/smart_control/reinforcement_learning/agents/networks/sac_networks.py @@ -106,7 +106,7 @@ def split_inputs(inputs): class _TanhNormalProjectionNetworkWrapper( tanh_normal_projection_network.TanhNormalProjectionNetwork ): - """Wrapper to pass predefined `outer_rank` to underlying projection network.""" + """Wrapper to pass predefined `outer_rank` to underlying projection net.""" def __init__(self, sample_spec, predefined_outer_rank=1): super(_TanhNormalProjectionNetworkWrapper, self).__init__(sample_spec) diff --git a/smart_control/reward/base_setpoint_energy_carbon_reward.py b/smart_control/reward/base_setpoint_energy_carbon_reward.py index 4c768e9a..aa9258c9 100644 --- a/smart_control/reward/base_setpoint_energy_carbon_reward.py +++ b/smart_control/reward/base_setpoint_energy_carbon_reward.py @@ -16,7 +16,7 @@ class BaseSetpointEnergyCarbonRewardFunction(BaseRewardFunction): Attributes: max_productivity_personhour_usd: max productivity for average occupancy in $ - productivity_midpoint_delta: temperature difference from setpoint of half productivity. + productivity_midpoint_delta: temp difference from setpoint of half prod. productivity_decay_stiffness: midpoint slope of the decay curve """ diff --git a/smart_control/simulator/air_handler.py b/smart_control/simulator/air_handler.py index 8daabb43..c70cc004 100644 --- a/smart_control/simulator/air_handler.py +++ b/smart_control/simulator/air_handler.py @@ -13,7 +13,8 @@ @gin.configurable class AirHandler(smart_device.SmartDevice): - """Models an air handler with heating/cooling, input/exhaust and recirculation. + """ + Models an air handler with heating/cooling, input/exhaust and recirculation. Attributes: recirculation: Proportion of air recirculated. diff --git a/smart_control/simulator/simulator.py b/smart_control/simulator/simulator.py index df6b9c49..80b983f4 100644 --- a/smart_control/simulator/simulator.py +++ b/smart_control/simulator/simulator.py @@ -281,8 +281,8 @@ def update_temperature_estimates( convection_coefficient: Current wind convection coefficient (W/m2/K). Returns: - Maximum difference in temperature_estimates across all CVs before and after - operation. + Maximum difference in temperature_estimates across all CVs + before and after operation. """ nrows, ncols = temperature_estimates.shape max_delta = 0.0