From 9410ff18c4c2ecb2b2854375a25a81386f21b4bd Mon Sep 17 00:00:00 2001 From: Tucker Date: Sat, 6 Jan 2024 18:48:23 -0500 Subject: [PATCH] Fix last of tests. --- smarts/core/agent_interface.py | 6 ++---- smarts/core/tests/test_vehicle.py | 4 ++-- smarts/core/vehicle.py | 15 ++++++--------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/smarts/core/agent_interface.py b/smarts/core/agent_interface.py index ee7b640756..1f974734cb 100644 --- a/smarts/core/agent_interface.py +++ b/smarts/core/agent_interface.py @@ -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.""" diff --git a/smarts/core/tests/test_vehicle.py b/smarts/core/tests/test_vehicle.py index 342cfda8eb..56cfd8d2c3 100644 --- a/smarts/core/tests/test_vehicle.py +++ b/smarts/core/tests/test_vehicle.py @@ -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}") diff --git a/smarts/core/vehicle.py b/smarts/core/vehicle.py index dab6dde1cb..e8b5d811a5 100644 --- a/smarts/core/vehicle.py +++ b/smarts/core/vehicle.py @@ -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) @@ -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: @@ -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: @@ -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