Skip to content

Commit

Permalink
🔨 fix unflatten when processing Ordered dict
Browse files Browse the repository at this point in the history
  • Loading branch information
mwulfman committed Jun 27, 2024
1 parent 1e0c3b0 commit 7325f65
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions python/jiminy_py/src/jiminy_py/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from functools import lru_cache
from itertools import chain, starmap
from collections.abc import (Mapping, ValuesView, Sequence, Set)
from collections import OrderedDict
from typing import (
Any, Union, Mapping as MappingT, Iterable, Iterator as Iterator, Tuple,
TypeVar, Callable, Type)
Expand Down Expand Up @@ -173,10 +174,10 @@ def _unflatten_as(data: StructNested[Any],
"""
data_type = type(data)
if issubclass_mapping(data_type): # type: ignore[arg-type]
return data_type({ # type: ignore[call-arg]
return data_type(OrderedDict({ # type: ignore[call-arg]
key: _unflatten_as(value, data_leaf_it)
for key, value in data.items() # type: ignore[union-attr]
})
}))
if issubclass_sequence(data_type): # type: ignore[arg-type]
return data_type(tuple( # type: ignore[call-arg]
_unflatten_as(value, data_leaf_it) for value in data
Expand Down

0 comments on commit 7325f65

Please sign in to comment.