From 3a3e4aed8624a68b89850051f0884b1ccb6336e8 Mon Sep 17 00:00:00 2001 From: Maltimore Date: Tue, 12 Jan 2021 20:15:23 +0100 Subject: [PATCH] [RLlib] Add `__len__()` method to SampleBatch (#13371) --- rllib/policy/sample_batch.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rllib/policy/sample_batch.py b/rllib/policy/sample_batch.py index 08dfa2227..162c62499 100644 --- a/rllib/policy/sample_batch.py +++ b/rllib/policy/sample_batch.py @@ -86,6 +86,11 @@ class SampleBatch: # Keeps track of new columns added after initial ones. self.new_columns = [] + @PublicAPI + def __len__(self): + """Returns the amount of samples in the sample batch.""" + return self.count + @staticmethod @PublicAPI def concat_samples(samples: List["SampleBatch"]) -> \