Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ineffective trip actors. #1939

Merged
merged 1 commit into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Copy and pasting the git commit messages is __NOT__ enough.
### Changed
### Deprecated
### Fixed
- `Trip.actor` field is now effective. Previously `actor` had no effect.
### Removed
### Security

Expand Down
4 changes: 2 additions & 2 deletions smarts/sstudio/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ def _writexml(
if traffic.trips:
actors_for_vtypes |= {trip.actor for trip in traffic.trips}
vehicle_id_set = {trip.vehicle_name for trip in traffic.trips}
vehilce_ids_list = [trip.vehicle_name for trip in traffic.trips]
if len(vehicle_id_set) != len(vehilce_ids_list):
vehicle_ids_list = [trip.vehicle_name for trip in traffic.trips]
if len(vehicle_id_set) != len(vehicle_ids_list):
raise ValueError("Repeated single vehicle names is not allowed.")

for actor in actors_for_vtypes:
Expand Down
12 changes: 10 additions & 2 deletions smarts/sstudio/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import logging
import math
import random
from dataclasses import dataclass, field
from dataclasses import dataclass, field, replace
from enum import IntEnum
from sys import maxsize
from typing import (
Expand Down Expand Up @@ -518,7 +518,15 @@ def __post_init__(self):
object.__setattr__(
self,
"actor",
TrafficActor(name=self.vehicle_name, vehicle_type=self.vehicle_type),
(
replace(
self.actor, name=self.vehicle_name, vehicle_type=self.vehicle_type
)
if self.actor is not None
else TrafficActor(
name=self.vehicle_name, vehicle_type=self.vehicle_type
)
),
)

@property
Expand Down