You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the function below I made a mistake and got a very explicit error. Only the line was clearly incorrect: the problem is actually subset[i] || continue at line 38.
functiontest(x::AbstractVector...;
subset::Union(Nothing, AbstractVector{Int}, AbstractVector{Bool}, BitVector)=nothing,
weights::Union(Nothing, AbstractVector{Number})=nothing)
n =length(x)
l =map(length, x)
vtypes =map(eltype, x)
for i in1:n
if l[1] != l[i]
error("arguments are not of the same length: $l")
endendif (isa(subset, AbstractVector{Bool}) ||isa(subset, BitVector)) &&length(subset) != l[1]
error("'subset' (length $(length(subset))) must be of the same length as vectors (length $(l[1])) when it is boolean")
endif weights !=nothing&&length(weights) != l[1]
error("'weights' (length $(length(weights))) must be of the same length as vectors (length $(l[1]))")
end
d =cell(n)
if weights ==nothing
counts =Array(Int, 0)
else
counts =Array(eltype(weights), 0)
end
a =Array(Int, (0, 0))
el =cell(n)
if subset ==nothing
subset =1:l[1]
endfor i in subset
subset[i] ||continuefor j in1:n
pos =findfirst(a, x[j][i])
if pos ==0
d =push!(d, x[j][i])
a =cat(j, a, zeros(Int, ntuple(n -1, k -> k >= j ? k : k +1)))
pos =length(d)
end@inbounds el[j] = pos
end@inbounds a[el...] +=1endend
julia>test([1:10]);
ERROR: type: non-boolean (Int64) used in boolean context
in test at none:9
I've tried making a shorter example, but the bug vanishes when removing apparently unrelated code. For example, this version prints the correct line number:
functiontest2(x::AbstractVector...;
subset::Union(Nothing, AbstractVector{Int}, AbstractVector{Bool}, BitVector)=nothing,
weights::Union(Nothing, AbstractVector{Number})=nothing)
n =length(x)
l =map(length, x)
vtypes =map(eltype, x)
d =cell(n)
if weights ==nothing
counts =Array(Int, 0)
else
counts =Array(eltype(weights), 0)
end
a =Array(Int, (0, 0))
el =cell(n)
if subset ==nothing
subset =1:l[1]
endfor i in subset
subset[i] ||continuefor j in1:n
pos =findfirst(a, x[j][i])
if pos ==0
d =push!(d, x[j][i])
a =cat(j, a, zeros(Int, ntuple(n -1, k -> k >= j ? k : k +1)))
pos =length(d)
end@inbounds el[j] = pos
end@inbounds a[el...] +=1endend
julia>test2(x)
ERROR: type: non-boolean (Int64) used in boolean context
in test2 at none:23
For the record, is it useful to make such reports about line numbers, or is there a well-known issue about that?
EDIT: I did not paste the second function correctly.
The text was updated successfully, but these errors were encountered:
With the function below I made a mistake and got a very explicit error. Only the line was clearly incorrect: the problem is actually
subset[i] || continue
at line 38.I've tried making a shorter example, but the bug vanishes when removing apparently unrelated code. For example, this version prints the correct line number:
For the record, is it useful to make such reports about line numbers, or is there a well-known issue about that?
EDIT: I did not paste the second function correctly.
The text was updated successfully, but these errors were encountered: