Skip to content

Commit

Permalink
Fix lambda cannot be serialized. (#2102)
Browse files Browse the repository at this point in the history
* Fix issue where a lambda cannot be serialized.

* Update changelog.

* Make format.
  • Loading branch information
Gamenot authored Nov 1, 2023
1 parent fc90e72 commit 98bfa4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Copy and pasting the git commit messages is __NOT__ enough.
### Fixed
- Fixed issue where `SumoTrafficSimulation` could get locked up on reset if a scenario had only 1 map but multiple scenario variations.
- Fixed an issue where an out-of-scope method reference caused a pickling error.
- Fixed an issue where the `EnvisionDataFormatterArgs` default would use a locally defined lambda and cause a serialization failure.
### Removed
### Security

Expand Down
6 changes: 5 additions & 1 deletion envision/data_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class Operation(IntEnum):
_primitives = {int, float, str, VehicleType, TrafficActorType}


def _passthrough_method_1_arg(v):
return v


class ReductionContext:
"""Mappings between an object and its reduction to an ID."""

Expand Down Expand Up @@ -126,7 +130,7 @@ class EnvisionDataFormatterArgs(NamedTuple):
"""Data formatter configurations."""

id: Optional[str]
serializer: Callable[[list], Any] = lambda d: d
serializer: Callable[[list], Any] = _passthrough_method_1_arg
float_decimals: int = 2
bool_as_int: bool = True
enable_reduction: bool = True
Expand Down

0 comments on commit 98bfa4b

Please sign in to comment.