I have been banging my head against the following bug for more than a couple days now, and I’m still baffled. I want to count the number of zero and non-zero elements in a couple vectors as shown below. In the code below, the counts get printed in the @show statement labelled “90”. However, for some reason m
and m0
are both printing as zero, even though @show statements labelled 82 and 91 (which are executed immediately before and after the counting loops) show a bunch of nonzero elements in the “unaryIdToFeatValList” vector. (The binaryIdToFeatValList vector doesn’t have this problem.) The declaration of unaryIdToFeatValList (a member of a struct) is:
...
unaryIdToFeatValList::Vector{Tuple{UInt32, UInt16, UInt16}}
@show 82, base.unaryIdToFeatValList[fvi-10:fvi]
m0 = m = x = 0
for e in base.unaryIdToFeatValList
x += 1
UInt(e[1]) == 0 ? (m0 += 1) : (m += 0)
end
n0 = n = y = 0
for e in base.binaryIdToFeatValList
y+=1
e[1] == 0 ? n0 += 1 : n += 1
end
@show 90, m, m0, x, n0, n ,y
@show 91, base.unaryIdToFeatValList[fvi-10:fvi]
A sample output is:
(82, base.unaryIdToFeatValList[fvi - 3:fvi]) = (82, Tuple{UInt32, UInt16, UInt16}[(0x00000007, 0x0003, 0x0000), (0x00000008, 0x0003, 0x0000), (0x00000009, 0x0003, 0x0000), (0x00000001, 0x0004, 0x0000)])
(90, m, m0, x, n0, n, y) = (90, 0, 0, 659, 257499955, 45, 257500000)
(91, base.unaryIdToFeatValList[fvi - 3:fvi]) = (91, Tuple{UInt32, UInt16, UInt16}[(0x00000007, 0x0003, 0x0000), (0x00000008, 0x0003, 0x0000), (0x00000009, 0x0003, 0x0000), (0x00000001, 0x0004, 0x0000)])
Both arrays can grow quite large (~500,000,000+ elements), pushing the memory limits of my laptop. I don’t know if there are possibly subtle side effects from overextending my code? Or maybe I’m just overlooking something really stupid. Any feedback would be much appreciated.