Skip to content

Commit 9410ff1

Browse files
committed
Fix last of tests.
1 parent 6eb58ea commit 9410ff1

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

smarts/core/agent_interface.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,10 @@ class AgentInterface:
268268
debug: bool = False
269269
"""Enable debug information for the various sensors and action spaces."""
270270

271-
event_configuration: EventConfiguration = field(
272-
default_factory=lambda: EventConfiguration()
273-
)
271+
event_configuration: EventConfiguration = field(default_factory=EventConfiguration)
274272
"""Configurable criteria of when to trigger events"""
275273

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

smarts/core/tests/test_vehicle.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ def check_attr(sensor_control_name):
153153
sensor_attach = sensor_attach.fget
154154
assert isinstance(sensor_attach, partial)
155155
assert (
156-
vehicle.id == sensor_attach.keywords["self"].id
157-
), f"{vehicle.id} | {sensor_attach.keywords['self'].id}"
156+
vehicle.id == sensor_attach.func.__self__.id
157+
), f"{vehicle.id} | {sensor_attach.func.__self__.id}"
158158

159159
for sensor_name in vehicle.sensor_names:
160160
check_attr(f"attach_{sensor_name}")

smarts/core/vehicle.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,10 @@ def valid(self) -> bool:
264264
"""Check if the vehicle still `exists` and is still operable."""
265265
return self._initialized
266266

267-
@classmethod
268267
@property
269-
def sensor_names(cls) -> Tuple[str]:
268+
def sensor_names(self) -> Tuple[str]:
270269
"""The names of the sensors that are potentially available to this vehicle."""
271-
return cls._sensor_names
270+
return self._sensor_names
272271

273272
@staticmethod
274273
@lru_cache(maxsize=None)
@@ -467,6 +466,7 @@ def add_sensor_if_needed(
467466
vehicle.attach_sensor(sensor, sensor_name)
468467
added_sensors.append((sensor_name, sensor))
469468

469+
# pytype: disable=attribute-error
470470
add_sensor_if_needed(TripMeterSensor, sensor_name="trip_meter_sensor")
471471
add_sensor_if_needed(DrivenPathSensor, sensor_name="driven_path_sensor")
472472
if agent_interface.neighborhood_vehicle_states:
@@ -555,6 +555,7 @@ def add_sensor_if_needed(
555555
"signals_sensor",
556556
lookahead=agent_interface.signals.lookahead,
557557
)
558+
# pytype: enable=attribute-error
558559

559560
for sensor_name, sensor in added_sensors:
560561
if not sensor:
@@ -676,16 +677,12 @@ def _meta_create_instance_sensor_functions(self):
676677
setattr(
677678
self,
678679
f"attach_{sensor_name}",
679-
partial(
680-
self.__class__.attach_sensor, self=self, sensor_name=sensor_name
681-
),
680+
partial(self.attach_sensor, sensor_name=sensor_name),
682681
)
683682
setattr(
684683
self,
685684
f"detach_{sensor_name}",
686-
partial(
687-
self.__class__.detach_sensor, self=self, sensor_name=sensor_name
688-
),
685+
partial(self.detach_sensor, sensor_name=sensor_name),
689686
)
690687

691688
@classmethod

0 commit comments

Comments
 (0)