def METHOD_NAME(self):
    """Tests that we will not calculate the Jacobian if not requested"""
    gT1 = Pose2(1, 2, np.pi / 2)
    gT2 = Pose2(-1, 4, np.pi)
    expected = Pose2(2, 2, np.pi / 2)
    def error_func(this: CustomFactor, v: gtsam.Values,
                   H: List[np.ndarray]):
        """
        Error function that mimics a BetweenFactor
        :param this: reference to the current CustomFactor being evaluated
        :param v: Values object
        :param H: list of references to the Jacobian arrays
        :return: the non-linear error
        """
        key0 = this.keys()[0]
        key1 = this.keys()[1]
        gT1, gT2 = v.atPose2(key0), v.atPose2(key1)
        error = expected.localCoordinates(gT1.between(gT2))
        self.assertTrue(
            H is None)  # Should be true if we only request the error
        if H is not None:
            result = gT1.between(gT2)
            H[0] = -result.inverse().AdjointMap()
            H[1] = np.eye(3)
        return error
    noise_model = gtsam.noiseModel.Unit.Create(3)
    cf = CustomFactor(noise_model, [0, 1], error_func)
    v = Values()
    v.insert(0, gT1)
    v.insert(1, gT2)
    bf = gtsam.BetweenFactorPose2(0, 1, expected, noise_model)
    e_cf = cf.error(v)
    e_bf = bf.error(v)
    np.testing.assert_allclose(e_cf, e_bf)