i have a package built where i’m calling one function called prob
with two methods inside a constructor called QRelaySampler
and after i call it using QR=QRelaySampler([2 3;1 1],1 ,1, 0.5)
then QR.prob(200)
it shows me this following error:
ERROR: MethodError: no method matching iterate(::Task)
Closest candidates are:
iterate(::Core.SimpleVector) at essentials.jl:604
iterate(::Core.SimpleVector, ::Any) at essentials.jl:604
iterate(::ExponentialBackOff) at error.jl:214
the same thing when i call it using the second method QR.prob(200,150,2)
**ERROR:** MethodError: objects of type Float64 are not callable
Stacktrace:
[1] **(::getfield(QuantumRelay, Symbol("#prob#6")){Int64,Int64,Array{Float64,2},Array{Float64,2},getfield(QuantumRelay, Symbol("#setc#3")){Array{Float64,2},JuMP.Model},getfield(QuantumRelay, Symbol("#scan#4")){JuMP.Model,Int64,Array{Int64,1},Array{Int64,1},Array{Int64,1},Array{JuMP.Variable,1}},Float64})(** ::Int64, ::Int64, ::Int64 **)** at **/Users/midow/.julia/packages/QuantumRelay/aX3kK/src/QuantumRelay.jl:78**
[2] top-level scope at **REPL[29]:1**
and this is a part of the code:
function prob(na)
@assert count(!iszero, ui2*na) == 0
b = T0*na
setc(-b)
total = 0.0
for x in Task(scan)
nab = vi2*x + b #the photon numbers for each item in the sum in the note (10)
total += prod([c.^complex(n)/factorial(n) for (c, n) in zip(coef, nab)])
end
return abs(total*omega)^2
end
#compute the probability of detection
#q: the number of photons detectors report
#na: the number of photons arrived at detector
#mask: if there is no detector in this channel, mask=0
function prob(q, na, mask)
q0 = round(Int, q.>0)
m0 = round(Int, mask)
return prod((q0 + (1-2q0).*pdet0(na)).^m0)
end
the code generally for computing the probability for an ideal system for a detector and then for a realistic system.
you can also find the code in Github in this link :