def METHOD_NAME(variant_scalar_spectral, spectrum_key, it_pos, wavelength_sample, cutoff_angle, lookat):
    """ Check the correctness of the sample_direction() method """
    cutoff_angle_rad = cutoff_angle / 180 * dr.pi
    beam_width_rad = cutoff_angle_rad * 0.75
    inv_transition_width = 1 / (cutoff_angle_rad - beam_width_rad)
    emitter, spectrum = create_emitter_and_spectrum(lookat, cutoff_angle, spectrum_key)
    eval_t = 0.3
    trafo = mi.Transform4f(emitter.world_transform())
    # Create a surface iteration
    it = dr.zeros(mi.SurfaceInteraction3f)
    it.p = it_pos
    it.time = eval_t
    # Sample a wavelength from spectrum
    wav, spec = spectrum.sample_spectrum(it, mi.sample_shifted(wavelength_sample))
    it.wavelengths = wav
    # Direction from the position to the point emitter
    d = mi.Vector3f(-it.p + lookat.translation())
    dist = dr.norm(d)
    d /= dist
    # Calculate angle between lookat direction and ray direction
    angle = dr.acos((trafo.inverse() @ (-d))[2])
    angle = dr.select(dr.abs(angle - beam_width_rad)
                      < 1e-3, beam_width_rad, angle)
    angle = dr.select(dr.abs(angle - cutoff_angle_rad)
                      < 1e-3, cutoff_angle_rad, angle)
    # Sample a direction from the emitter
    ds, res = emitter.sample_direction(it, [0, 0])
    # Evaluate the spectrum
    spec = spectrum.eval(it)
    spec = dr.select(angle <= beam_width_rad, spec, spec *
                     ((cutoff_angle_rad - angle) * inv_transition_width))
    spec = dr.select(angle <= cutoff_angle_rad, spec, 0)
    assert ds.time == it.time
    assert ds.pdf == 1.0
    assert ds.delta
    assert dr.allclose(ds.d, d)
    assert dr.allclose(res, spec / (dist**2))