<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cartesian_to_helicity(vector, numeric=False):
 r"""This function takes vectors from the cartesian basis to the helicity basis. For instance, we can check what are the vectors of the helicity basis. Matrix([ [ sqrt(2)/2], [-sqrt(2)*I/2], [ 0]]) Matrix([ [ 0], [ 0], [-1]]) Matrix([ [0], [0], [1]]) Matrix([ [0], [1], [0]]) Matrix([ [ -sqrt(2)/2], [-sqrt(2)*I/2], [ 0]]) Matrix([ [-1], [ 0], [ 0]]) Note that vectors in the helicity basis are built in a weird way by convention: .. math:: \vec{a} = -a_{+1}\vec{e}_{-1} +a_0\vec{e}_0 -a_{-1}\vec{e}_{+1} Matrix([ [ sqrt(2)*am/2 - sqrt(2)*ap/2], [sqrt(2)*I*am/2 + sqrt(2)*I*ap/2], [ a0]]) Matrix([ [am], [a0], [ap]]) We can also convert a numeric array array([[[ 0. +0.j, 0. +0.j], [ 1.4142+0.j, 0. +0.j]], <BLANKLINE> [[ 1. +0.j, 0. +0.j], [ 0. +0.j, -1. +0.j]], <BLANKLINE> [[-0. +0.j, -1.4142+0.j], [-0. +0.j, -0. +0.j]]]) """

    if numeric:
        vector = list(vector)
        vector[0] = nparray(vector[0])
        vector[1] = nparray(vector[1])
        vector[2] = nparray(vector[2])

        v = [(vector[0]-1j*vector[1])/npsqrt(2),
             vector[2],
             -(vector[0]+1j*vector[1])/npsqrt(2)]
        v = nparray(v)
    else:
        v = [(vector[0]-I*vector[1])/sqrt(2),
             vector[2],
             -(vector[0]+I*vector[1])/sqrt(2)]

    if type(vector[0]) in [type(Matrix([1, 0])), type(nparray([1, 0]))]:
        return v
    else:
        return Matrix(v)