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

Generic hidden state for RecurrentPPO #4

Merged
merged 3 commits into from
Oct 13, 2023
Merged
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
9 changes: 4 additions & 5 deletions stable_baselines3/common/pytree_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ def __new__(mcs, name, bases, namespace, slots=True, **kwargs):
# Otherwise we just mark the current class as what we're registering.
if not issubclass(cls, (FrozenPyTreeDataclass, MutablePyTreeDataclass)):
raise TypeError(f"Dataclass {cls} should inherit from FrozenPyTreeDataclass or MutablePyTreeDataclass")
mcs.currently_registering = cls
else:
mcs.currently_registering = cls

mcs.currently_registering = cls

if name in _RESERVED_NAMES:
if not (
Expand All @@ -105,10 +104,10 @@ def __new__(mcs, name, bases, namespace, slots=True, **kwargs):

frozen = issubclass(cls, FrozenPyTreeDataclass)
if frozen:
if not (not issubclass(cls, MutablePyTreeDataclass) and issubclass(cls, FrozenPyTreeDataclass)):
if issubclass(cls, MutablePyTreeDataclass) or not issubclass(cls, FrozenPyTreeDataclass):
raise TypeError(f"Frozen dataclass {cls} should inherit from FrozenPyTreeDataclass")
else:
if not (issubclass(cls, MutablePyTreeDataclass) and not issubclass(cls, FrozenPyTreeDataclass)):
if not issubclass(cls, MutablePyTreeDataclass) or issubclass(cls, FrozenPyTreeDataclass):
raise TypeError(f"Mutable dataclass {cls} should inherit from MutablePyTreeDataclass")

# Calling `dataclasses.dataclass` here, with slots, is what triggers the EARLY RETURN path above.
Expand Down