def testComputeVelocityScalingLongitudinal(self):
    pred_score = np.reshape([0.5], (1, 1, 1))
    pred_trajectory = np.reshape([[[4, 4], [6, 6], [8, 8], [10, 10]],
                                  [[-2, 0], [-3, 0], [-4, 0], [-6.5, 0]]],
                                 (1, 1, 1, 2, 4, 2))

    config = motion_metrics_pb2.MotionMetricsConfig()
    config.CopyFrom(self._config)
    config.speed_scale_lower = 0.5
    config.speed_scale_upper = 1.0
    config.speed_lower_bound = 1.0
    config.speed_upper_bound = 3.0

    val = self._RunEval(pred_score, pred_trajectory, config=config)
    # miss_rate of Vehicle.
    self.assertEqual(val[2][0], 0.0)
    # mean_ap of Vehicle.
    self.assertEqual(val[4][0], 1.0)

    # Decrease the velocity below the speed lower bound.
    gt = copy.deepcopy(self._gt)
    gt['gt_trajectory'][0, 1, :, 5:7] = 0.0
    val = self._RunEval(pred_score, pred_trajectory, config=config, gt=gt)
    # miss_rate of Vehicle.
    self.assertEqual(val[2][0], 1.0)

    # Set the velocity to just below the speed required for object2 to fit.
    gt = copy.deepcopy(self._gt)
    gt['gt_trajectory'][0, 1, :, 5] = 1.999
    val = self._RunEval(pred_score, pred_trajectory, config=config, gt=gt)
    # miss_rate of Vehicle.
    self.assertEqual(val[2][0], 1.0)

    # Set the velocity to just above the speed required for object2 to fit.
    gt = copy.deepcopy(self._gt)
    gt['gt_trajectory'][0, 1, :, 5] = 2.001
    val = self._RunEval(pred_score, pred_trajectory, config=config, gt=gt)
    # miss_rate of Vehicle.
    self.assertEqual(val[2][0], 0.0)