Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
guo-yong-zhi committed Dec 21, 2021
1 parent 988dd96 commit 76f4ad8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/Stuffing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ function packing(mask, objs, args...; background=:auto, maskbackground=:auto, ka
end
function packing!(qts, args...; kargs...)
place!(qts)
ep, nc = fit!(qts, args...; kargs...)
@info "$ep epochs, $nc collections"
if nc != 0
nepoch, ncollection = fit!(qts, args...; kargs...)
@info "$nepoch epochs, $ncollection collections"
if ncollection != 0
colllist = first.(batchcollisions(qts))
get_text(i) = i > 1 ? "obj_$(i - 1)" : "#MASK#"
@warn "have $(length(colllist)) collisions:\n" *
string([(get_text(i), get_text(j)) for (i, j) in colllist])
end
qts
nepoch, ncollection
end
end
28 changes: 17 additions & 11 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,24 @@ include("test_fit.jl")
setshift!(qts[1], (-1000, -1000))
@test collision(qts[1], qts[2])[1] < 0

mask = fill(true, 500, 800) # can be any AbstractMatrix
objs = []
for i in 1:30
s = 20 + randexp() * 50
obj = fill(true, round(Int, s) + 1, round(Int, s * (0.5 + rand() / 2)) + 1) # Bool Matrix implied that background = false
push!(objs, obj)
ncollection = -1
nepoch = 0
while ncollection != 0 && nepoch < 10000
mask = fill(true, 500, 800) # can be any AbstractMatrix
objs = []
for i in 1:30
s = 20 + randexp() * 50
obj = fill(true, round(Int, s) + 1, round(Int, s * (0.5 + rand() / 2)) + 1) # Bool Matrix implied that background = false
push!(objs, obj)
end
sort!(objs, by=prod size, rev=true)
packing(mask, objs, 10)
qts = qtrees(objs, mask=mask);
setpositions!(qts, :, (200, 300))
ep, nc = packing!(qts, trainer=Trainer.trainepoch_P2!)
nepoch += ep
ncollection = nc
end
sort!(objs, by=prod size, rev=true)
packing(mask, objs, 10)
qts = qtrees(objs, mask=mask);
setpositions!(qts, :, (200, 300))
packing!(qts, trainer=Trainer.trainepoch_P2!)
getpositions(qts)
@test isempty(outofkernelbounds(qts[1], qts[2:end]))
@test isempty(outofbounds(qts[1], qts[2:end]))
Expand Down

0 comments on commit 76f4ad8

Please sign in to comment.