mirror of
https://github.com/wassname/ray.git
synced 2026-06-29 05:01:29 +08:00
1775e89f26
Deprecate TupleActions and support arbitrarily nested action spaces. Closes issue #8143.
20 lines
740 B
Python
20 lines
740 B
Python
from collections import namedtuple
|
|
from ray.rllib.utils.deprecation import deprecation_warning
|
|
|
|
|
|
# NOTE: This is a deprecated class. Use native python tuples
|
|
# or dicts (both arbitrarily nested) for multi-actions from here on.
|
|
class TupleActions(namedtuple("TupleActions", ["batches"])):
|
|
"""Used to return tuple actions as a list of batches per tuple element."""
|
|
|
|
def __new__(cls, batches):
|
|
# Throw an informative error if used.
|
|
deprecation_warning(
|
|
old="TupleActions",
|
|
new="`native python tuples (arbitrarily nested)`",
|
|
error=True)
|
|
return super(TupleActions, cls).__new__(cls, batches)
|
|
|
|
def numpy(self):
|
|
return TupleActions([b.numpy() for b in self.batches])
|