Skip to content

Commit

Permalink
Fix last of tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamenot committed Jan 7, 2024
1 parent 6eb58ea commit 9410ff1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
6 changes: 2 additions & 4 deletions smarts/core/agent_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,10 @@ class AgentInterface:
debug: bool = False
"""Enable debug information for the various sensors and action spaces."""

event_configuration: EventConfiguration = field(
default_factory=lambda: EventConfiguration()
)
event_configuration: EventConfiguration = field(default_factory=EventConfiguration)
"""Configurable criteria of when to trigger events"""

done_criteria: DoneCriteria = field(default_factory=lambda: DoneCriteria())
done_criteria: DoneCriteria = field(default_factory=DoneCriteria)
"""Configurable criteria of when to mark this actor as done. Done actors will be
removed from the environment and may trigger the episode to be done."""

Expand Down
4 changes: 2 additions & 2 deletions smarts/core/tests/test_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def check_attr(sensor_control_name):
sensor_attach = sensor_attach.fget
assert isinstance(sensor_attach, partial)
assert (
vehicle.id == sensor_attach.keywords["self"].id
), f"{vehicle.id} | {sensor_attach.keywords['self'].id}"
vehicle.id == sensor_attach.func.__self__.id
), f"{vehicle.id} | {sensor_attach.func.__self__.id}"

for sensor_name in vehicle.sensor_names:
check_attr(f"attach_{sensor_name}")
Expand Down
15 changes: 6 additions & 9 deletions smarts/core/vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,10 @@ def valid(self) -> bool:
"""Check if the vehicle still `exists` and is still operable."""
return self._initialized

@classmethod
@property
def sensor_names(cls) -> Tuple[str]:
def sensor_names(self) -> Tuple[str]:
"""The names of the sensors that are potentially available to this vehicle."""
return cls._sensor_names
return self._sensor_names

@staticmethod
@lru_cache(maxsize=None)
Expand Down Expand Up @@ -467,6 +466,7 @@ def add_sensor_if_needed(
vehicle.attach_sensor(sensor, sensor_name)
added_sensors.append((sensor_name, sensor))

# pytype: disable=attribute-error
add_sensor_if_needed(TripMeterSensor, sensor_name="trip_meter_sensor")
add_sensor_if_needed(DrivenPathSensor, sensor_name="driven_path_sensor")
if agent_interface.neighborhood_vehicle_states:
Expand Down Expand Up @@ -555,6 +555,7 @@ def add_sensor_if_needed(
"signals_sensor",
lookahead=agent_interface.signals.lookahead,
)
# pytype: enable=attribute-error

for sensor_name, sensor in added_sensors:
if not sensor:
Expand Down Expand Up @@ -676,16 +677,12 @@ def _meta_create_instance_sensor_functions(self):
setattr(
self,
f"attach_{sensor_name}",
partial(
self.__class__.attach_sensor, self=self, sensor_name=sensor_name
),
partial(self.attach_sensor, sensor_name=sensor_name),
)
setattr(
self,
f"detach_{sensor_name}",
partial(
self.__class__.detach_sensor, self=self, sensor_name=sensor_name
),
partial(self.detach_sensor, sensor_name=sensor_name),
)

@classmethod
Expand Down

0 comments on commit 9410ff1

Please sign in to comment.