Skip to content

Commit 6658f2b

Browse files
committed
Fixed pickle loading of BufferDTypes
1 parent 77d6ee1 commit 6658f2b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stable_baselines3/common/buffers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class BufferDTypes:
4141
observations: InitVar[Union[DTypeLike, Mapping[str, DTypeLike]]]
4242
actions: InitVar[DTypeLike]
4343

44-
dict_obs: MappingProxyType[str, np.dtype] = field(init=False)
44+
dict_obs: MappingProxyType[str, np.dtype] = field(default=MappingProxyType({}), init=False)
4545
obs: Optional[np.dtype] = field(default=None, init=False)
4646
act: Optional[np.dtype] = field(default=None, init=False)
4747

@@ -61,7 +61,7 @@ def __getstate__(self):
6161
def __setstate__(self, state: Mapping[str, Any]):
6262
state = dict(state)
6363
if state.get("dict_obs"):
64-
state["dict_obs"] = MappingProxyType(state["dict_obs"])
64+
state["dict_obs"] = MappingProxyType(state["dict_obs"].copy())
6565
self.__dict__.update(state)
6666

6767
@classmethod

0 commit comments

Comments
 (0)