Ejemplo n.º 1
0
    def test_raises_error_when_seconds_negative(self) -> None:
        mock_samples = [{'token': '1', 'timestamp': 0, 'anns': ['1', '1b']}]
        nusc = MockNuScenes(self.mock_annotations, mock_samples)
        helper = PredictHelper(nusc)
        with self.assertRaises(ValueError):
            helper.get_future_for_agent('1', '1', -1, False)

        with self.assertRaises(ValueError):
            helper.get_past_for_agent('1', '1', -1, False)

        with self.assertRaises(ValueError):
            helper.get_past_for_sample('1', -1, False)

        with self.assertRaises(ValueError):
            helper.get_future_for_sample('1', -1, False)
Ejemplo n.º 2
0
    def test_get_past_for_sample(self) -> None:

        mock_samples = [{
            'token': '5',
            'timestamp': 0,
            'anns': ['5', '5b']
        }, {
            'token': '4',
            'timestamp': -1e6
        }, {
            'token': '3',
            'timestamp': -2e6
        }, {
            'token': '2',
            'timestamp': -3e6
        }, {
            'token': '1',
            'timestamp': -4e6
        }]

        nusc = MockNuScenes(self.multiagent_mock_annotations, mock_samples)
        helper = PredictHelper(nusc)
        past = helper.get_past_for_sample('5', 3, True)

        answer = {
            '1': np.array([[1, -1], [2, -2], [3, -3]]),
            '2': np.array([[1, -1], [2, -2], [3, -3]])
        }

        for k in answer:
            np.testing.assert_allclose(past[k], answer[k])
Ejemplo n.º 3
0
    def test_get_no_data_when_seconds_0(self):
        mock_samples = [{'token': '1', 'timestamp': 0, 'anns': ['1']}]
        nusc = MockNuScenes(self.mock_annotations, mock_samples)
        helper = PredictHelper(nusc)

        np.testing.assert_equal(helper.get_future_for_agent('1', '1', 0, False), np.array([]))
        np.testing.assert_equal(helper.get_past_for_agent('1', '1', 0, False), np.array([]))
        np.testing.assert_equal(helper.get_future_for_sample('1', 0, False), np.array([]))
        np.testing.assert_equal(helper.get_past_for_sample('1', 0, False), np.array([]))