Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions smart_control/simulator/air_handler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def test_observable_field_names(self):
)

self.assertSameElements(
handler.observable_field_names(),
handler.observable_field_names,
[
'differential_pressure_setpoint',
'supply_air_flowrate_sensor',
Expand Down Expand Up @@ -507,7 +507,7 @@ def test_action_field_names(self):
self.fan_efficiency,
)
self.assertSameElements(
handler.action_field_names(),
handler.action_field_names,
[
'supply_air_heating_temperature_setpoint',
'supply_air_cooling_temperature_setpoint',
Expand Down
16 changes: 8 additions & 8 deletions smart_control/simulator/boiler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,12 @@ def test_observable_field_names(self):
b = self.get_default_boiler()

self.assertSameElements(
b.observable_field_names(),
[
'supply_water_setpoint',
'supply_water_temperature_sensor',
'heating_request_count',
],
b.observable_field_names,
[
'supply_water_setpoint',
'supply_water_temperature_sensor',
'heating_request_count',
],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, were these indentation changes made by the auto-formatter during pre-commit hooks? Or are these indentation changes made manually?

Can you please confirm if you have installed pre-commit hooks?
https://google.github.io/sbsim/contributing/#pre-commit-hooks

If our auto-formatter is responsible, we will want to update it (in a separate issue / PR) to use a hanging indentation of four spaces (to match Google internal style rules).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation changes were made manually as pre-commit hooks were not installed locally. I've confirmed the code uses 4-space hanging indentation, which aligns with the Google style guide.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I saw those manual indentation changes were still in place, so I just restored the hanging indentation to use four spaces.

)

def test_observe_supply_water_setpoint(self):
Expand Down Expand Up @@ -432,7 +432,7 @@ def test_compute_thermal_dissipation_rate_invalid(self):
def test_action_field_names(self):
b = self.get_default_boiler()

self.assertSameElements(b.action_field_names(), ['supply_water_setpoint'])
self.assertSameElements(b.action_field_names, ['supply_water_setpoint'])

def test_action_supply_water_setpoint(self):
b = self.get_default_boiler()
Expand All @@ -456,7 +456,7 @@ def test_device_type(self):
def test_device_id(self):
b = self.get_default_boiler()

device_id = b.device_id()
device_id = b.device_id

self.assertEqual(device_id, 'boiler_id')

Expand Down
4 changes: 2 additions & 2 deletions smart_control/simulator/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def _get_air_handler_reward_infos(
This data is used to compute the instantaneous reward.
"""
air_handler_reward_infos = {}
air_handler_id = self._hvac.air_handler.device_id()
air_handler_id = self._hvac.air_handler.device_id
blower_electrical_energy_rate = (
self._hvac.air_handler.compute_intake_fan_energy_rate()
+ self._hvac.air_handler.compute_exhaust_fan_energy_rate()
Expand Down Expand Up @@ -824,7 +824,7 @@ def _get_boiler_reward_infos(
This data is used to compute the instantaneous reward.
"""
boiler_reward_infos = {}
boiler_id = self._hvac.boiler.device_id()
boiler_id = self._hvac.boiler.device_id
return_water_temp = self._hvac.boiler.return_water_temperature_sensor
natural_gas_heating_energy_rate = (
self._hvac.boiler.compute_thermal_energy_rate(
Expand Down
8 changes: 4 additions & 4 deletions smart_control/simulator/simulator_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(
(hvac.air_handler, self._create_device_info(hvac.air_handler)),
]
all_devices.extend([
(vav, self._create_device_info(vav, vav.zone_id()))
(vav, self._create_device_info(vav, vav.zone_id))
for vav in hvac.vavs.values()
])

Expand Down Expand Up @@ -96,11 +96,11 @@ def _create_device_info(
device: SmartDevice to create info object for.
zone_id: Zone Id of the device.
"""
observable_fields = device.observable_field_names()
action_fields = device.action_field_names()
observable_fields = device.observable_field_names
action_fields = device.action_field_names

device_info = smart_control_building_pb2.DeviceInfo()
device_info.device_id = device.device_id()
device_info.device_id = device.device_id
device_info.namespace = f"device_namespace_{uuid.uuid4()}"
device_info.code = f"device_code_{uuid.uuid4()}"
device_info.zone_id = zone_id
Expand Down
4 changes: 2 additions & 2 deletions smart_control/simulator/simulator_flexible_floor_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _get_air_handler_reward_infos(
This data is used to compute the instantaneous reward.
"""
air_handler_reward_infos = {}
air_handler_id = self._hvac.air_handler.device_id()
air_handler_id = self._hvac.air_handler.device_id
blower_electrical_energy_rate = (
self._hvac.air_handler.compute_intake_fan_energy_rate()
+ self._hvac.air_handler.compute_exhaust_fan_energy_rate()
Expand Down Expand Up @@ -267,7 +267,7 @@ def _get_boiler_reward_infos(
This data is used to compute the instantaneous reward.
"""
boiler_reward_infos = {}
boiler_id = self._hvac.boiler.device_id()
boiler_id = self._hvac.boiler.device_id
return_water_temp = self._hvac.boiler.return_water_temperature_sensor
natural_gas_heating_energy_rate = (
self._hvac.boiler.compute_thermal_energy_rate(
Expand Down
4 changes: 2 additions & 2 deletions smart_control/simulator/simulator_flexible_floor_plan_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ def test_reward_info(self):
self.assertEqual(reward_info.zone_reward_infos, expected_zone_reward_infos)

air_handler_reward_info = reward_info.air_handler_reward_infos[
sim._hvac.air_handler.device_id()
sim._hvac.air_handler.device_id
]

blower_electrical_energy_rate = (
Expand Down Expand Up @@ -1533,7 +1533,7 @@ def test_reward_info(self):
)

boiler_reward_info = reward_info.boiler_reward_infos[
sim._hvac.boiler.device_id()
sim._hvac.boiler.device_id
]
natural_gas_heating_energy_rate = (
sim._hvac.boiler.compute_thermal_energy_rate(
Expand Down
4 changes: 2 additions & 2 deletions smart_control/simulator/simulator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ def test_reward_info(self):
self.assertEqual(reward_info.zone_reward_infos, expected_zone_reward_infos)

air_handler_reward_info = reward_info.air_handler_reward_infos[
sim._hvac.air_handler.device_id()
sim._hvac.air_handler.device_id
]

blower_electrical_energy_rate = (
Expand Down Expand Up @@ -1081,7 +1081,7 @@ def test_reward_info(self):
)

boiler_reward_info = reward_info.boiler_reward_infos[
sim._hvac.boiler.device_id()
sim._hvac.boiler.device_id
]
natural_gas_heating_energy_rate = (
sim._hvac.boiler.compute_thermal_energy_rate(
Expand Down
8 changes: 8 additions & 0 deletions smart_control/simulator/smart_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ def __init__(
self._action_timestamp = None
self._observation_timestamp = None


Comment thread
s2t2 marked this conversation as resolved.
Outdated
@property
def device_id(self) -> str:
"""Returns device id."""
return self._device_id


@property
def zone_id(self) -> Optional[str]:
"""Returns zone_id."""
return self._zone_id
Expand All @@ -72,10 +76,14 @@ def device_type(self) -> smart_control_building_pb2.DeviceInfo.DeviceType:
"""Returns device type."""
return self._device_type


@property
def observable_field_names(self) -> Sequence[str]:
"""Returns all observable field names."""
return self._observable_fields.keys() # pytype: disable=bad-return-type


@property
def action_field_names(self) -> Sequence[str]:
"""Returns all action field names."""
return self._action_fields.keys() # pytype: disable=bad-return-type
Expand Down
10 changes: 5 additions & 5 deletions smart_control/simulator/smart_device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,26 @@ def __init__(self):
def test_device_id(self):
heater = self.heater_class()

self.assertEqual(heater.device_id(), 'heater_id')
self.assertEqual(heater.device_id, 'heater_id')

def test_zone_id(self):
heater = self.heater_class()

self.assertEqual(heater.zone_id(), 'zone_id')
self.assertEqual(heater.zone_id, 'zone_id')

def test_observable_field_names(self):
heater = self.heater_class()

self.assertSameElements(
heater.observable_field_names(),
['obs_temp', 'obs_heat_setting', 'obs_seconds_active', 'obs_bad'],
heater.observable_field_names,
['obs_temp', 'obs_heat_setting', 'obs_seconds_active', 'obs_bad'],
)

def test_action_field_names(self):
heater = self.heater_class()

self.assertSameElements(
heater.action_field_names(), ['act_heat_setting', 'act_bad']
heater.action_field_names, ['act_heat_setting', 'act_bad']
)

def test_observable_type(self):
Expand Down
4 changes: 2 additions & 2 deletions smart_control/simulator/vav_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def test_observable_field_names(self):
v = vav.Vav(max_air_flow_rate, reheat_max_water_flow_rate, t, b)

self.assertSameElements(
v.observable_field_names(),
v.observable_field_names,
[
'supply_air_damper_percentage_command',
'supply_air_flowrate_setpoint',
Expand Down Expand Up @@ -477,7 +477,7 @@ def test_action_field_names(self):
v = vav.Vav(max_air_flow_rate, reheat_max_water_flow_rate, t, b)

self.assertSameElements(
v.action_field_names(), ['supply_air_damper_percentage_command']
v.action_field_names, ['supply_air_damper_percentage_command']
)

def test_action_supply_air_flowrate_setpoint(self):
Expand Down
Loading