ERROR: syntax: extra token "QRelaySym" after end of expression

Hello everyone,
im new in Julia i have version 1.0 and there is a code that i want to run but it doesn’t want to, actually it i only one code that i want to use in another file and maybe this code was written in 0.0.6
this is the code:

type QRelaySym{T<:Tuple}
    aH::T
    bH::T
    aV::T
    bV::T
    apH::T
    bpH::T
    apV::T
    bpV::T
end


function trans(op, a, b, ap, bp, B)
    p = B * [ap; bp]
    op = subs(op, a, p[1])
    op = subs(op, b, p[2])
    return op
end

#2D rotation matrix
function rotmat(theta)
    c = cos(theta)
    s = sin(theta)
    return [c s; -s c]
end


function qrelay_op(n, phi, alpha, delta)
    #operators before BS
    aH = symbols(@sprintf("a_H1:%d", n+1))
    bH = symbols(@sprintf("b_H1:%d", n+1))
    aV = symbols(@sprintf("a_V1:%d", n+1))
    bV = symbols(@sprintf("b_V1:%d", n+1))
    
    op = 0
    for i=1:n
        op += phi[i] * (aH[i]*bH[i] + aV[i]*bV[i])
    end

  
    B = 1/sqrt(2)*[1 1;-1 1]
    

    apH = symbols(@sprintf("a'_H1:%d", n+1))
    bpH = symbols(@sprintf("b'_H1:%d", n+1))
    apV = symbols(@sprintf("a'_V1:%d", n+1))
    bpV = symbols(@sprintf("b'_V1:%d", n+1))


    for i=1:n-1
        op = trans(op, bH[i], aH[i+1], bpH[i], apH[i+1], B)
        op = trans(op, bV[i], aV[i+1], bpV[i], apV[i+1], B)
    end


    op = trans(op, aH[1], aV[1], apH[1], apV[1], rotmat(alpha))
    op = trans(op, bH[n], bV[n], bpH[n], bpV[n], rotmat(delta))
    

    syms = QRelaySym(aH, bH, aV, bV, apH, bpH, apV, bpV)

    return syms, op
end


function op_mat(op)
    op = op[:as_poly](domain="C")
    op_a = op.x[:gens]
    nab = op[:length]()
    op_ab = ones(SymPy.Sym, nab)
    coef = zeros(Complex, nab)
    mat = zeros(Int64, length(op_a), nab)
    for (i, (ps, c)) in enumerate(op[:as_dict]())
        for (j, p) in enumerate(ps)
            mat[j, i] = p
            op_ab[i] = op_a[j]^p * op_ab[i]
        end
        coef[i] = c
    end
 
    return op_a, op_ab, mat, coef
end
` ` `
and it shows always this message:
ERROR: syntax: extra token "QRelaySym" after end of expression

type is mutable struct now.

Julia 0.7 prints this:

julia> type X end
┌ Warning: Deprecated syntax `type` at REPL[1]:1.
│ Use `mutable struct` instead.
└ @ REPL[1]:1

Also, please quote your code:

2 Likes

Thank you, that solved the problem but i think that there is one more problem. i changed (@sprintf) to (@printf) in the version 0.7 and it shows me a warning like this
‘’‘Base.@printf is deprecated: it has been moved to the standard library package Printf Add using Printf to your imports. in module Main’‘’

i have added the package but it is the same situation, always the same situation.

using Printf

@printf "%f\n" pi
1 Like

https://docs.julialang.org/en/v1/stdlib/Printf/#Printf.@sprintf

1 Like