From d3c969ee1ab0aed9bf30a314464bdd27bb28f643 Mon Sep 17 00:00:00 2001 From: Emre Arkan Date: Thu, 7 Dec 2023 13:16:10 +0100 Subject: [PATCH] fix loop where ann_count would not count the annotations in the last sample --- python-sdk/nuscenes/nuscenes.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python-sdk/nuscenes/nuscenes.py b/python-sdk/nuscenes/nuscenes.py index c36c023ce..f8ca893bb 100644 --- a/python-sdk/nuscenes/nuscenes.py +++ b/python-sdk/nuscenes/nuscenes.py @@ -794,10 +794,11 @@ def list_scenes(self) -> None: def ann_count(record): count = 0 - sample = self.nusc.get('sample', record['first_sample_token']) - while not sample['next'] == "": + next_sample_token = record['first_sample_token'] + while next_sample_token: + sample = self.nusc.get('sample', next_sample_token) count += len(sample['anns']) - sample = self.nusc.get('sample', sample['next']) + next_sample_token = sample["next"] return count recs = [(self.nusc.get('sample', record['first_sample_token'])['timestamp'], record) for record in