Skip to content

Commit

Permalink
rename symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
guo-yong-zhi committed Jun 5, 2023
1 parent 56af8c2 commit 336aca1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Stuffing"
uuid = "4175e07e-e5b7-423e-8796-3ea7f6d48281"
authors = ["guoyongzhi <[email protected]>"]
version = "0.9.0"
version = "0.10.0"

[deps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
24 changes: 12 additions & 12 deletions src/Stuffing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,27 @@ end
QTrees.overlap!(qtrees::AbstractVector{<:ShiftedQTree}; karg...) = QTrees.overlap!(qtrees[1], qtrees[2:end]; karg...)
QTrees.overlap(qtrees::AbstractVector{<:ShiftedQTree}; karg...) = QTrees.overlap!(deepcopy(qtrees[1]), qtrees[2:end]; karg...)

function getpositions(mask::ShiftedQTree, qtrees::AbstractVector, inds=:; type=getshift)
function getpositions(mask::ShiftedQTree, qtrees::AbstractVector, inds=:; mode=getshift)
msy, msx = getshift(mask)
pos = type.(qtrees[inds])
pos = mode.(qtrees[inds])
eltype(pos) <: Number && (pos = Ref(pos))
Broadcast.broadcast(p -> (p[2] - msx + 1, p[1] - msy + 1), pos) # 左上角重合时返回(1,1)
end
function getpositions(qtrees::AbstractVector{<:ShiftedQTree}, inds=:; type=getshift)
function getpositions(qtrees::AbstractVector{<:ShiftedQTree}, inds=:; mode=getshift)
@assert length(qtrees) >= 1
getpositions(qtrees[1], @view(qtrees[2:end]), inds, type=type)
getpositions(qtrees[1], @view(qtrees[2:end]), inds, mode=mode)
end
function setpositions!(mask::ShiftedQTree, qtrees::AbstractVector, inds, x_y; type=setshift!)
function setpositions!(mask::ShiftedQTree, qtrees::AbstractVector, inds, x_y; mode=setshift!)
msy, msx = getshift(mask)
eltype(x_y) <: Number && (x_y = Ref(x_y))
Broadcast.broadcast(qtrees[inds], x_y) do qt, p
type(qt, (p[2] - 1 + msy, p[1] - 1 + msx))
mode(qt, (p[2] - 1 + msy, p[1] - 1 + msx))
end
x_y
end
function setpositions!(qtrees::AbstractVector{<:ShiftedQTree}, inds, x_y; type=setshift!)
function setpositions!(qtrees::AbstractVector{<:ShiftedQTree}, inds, x_y; mode=setshift!)
@assert length(qtrees) >= 1
setpositions!(qtrees[1], @view(qtrees[2:end]), inds, x_y, type=type)
setpositions!(qtrees[1], @view(qtrees[2:end]), inds, x_y, mode=mode)
end

function packing(mask, objs, args...; background=:auto, maskbackground=:auto, kargs...)
Expand All @@ -105,14 +105,14 @@ function packing(mask, objs, args...; background=:auto, maskbackground=:auto, ka
end
function packing!(qts, args...; kargs...)
place!(qts)
epochs, ncollection = fit!(qts, args...; kargs...)
@debug "$epochs epochs, $ncollection collections"
if ncollection != 0
epochs, collisions = fit!(qts, args...; kargs...)
@debug "$epochs epochs, $collisions collisions"
if collisions != 0
colllist = first.(totalcollisions(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
epochs, ncollection
epochs, collisions
end
end
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ include("test_fit.jl")
setshift!(qts[1], (-1000, -1000))
@test collision(qts[1], qts[2])[1] < 0

ncollection = -1
collisions = -1
epochs = 0
while ncollection != 0 && epochs < 10000
while collisions != 0 && epochs < 10000
mask = fill(true, 500, 800) # can be any AbstractMatrix
objs = []
for i in 1:30
Expand All @@ -61,7 +61,7 @@ include("test_fit.jl")
setpositions!(qts, :, (200, 300))
ep, nc = packing!(qts, trainer=Trainer.trainepoch_P2!)
epochs += ep
ncollection = nc
collisions = nc
end
getpositions(qts)
@test isempty(outofkernelbounds(qts[1], qts[2:end]))
Expand Down

2 comments on commit 336aca1

@guo-yong-zhi
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/85837

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.0 -m "<description of version>" 336aca1443b47d047b386b99b3556f71605e4c68
git push origin v0.10.0

Please sign in to comment.