Skip to content

Commit

Permalink
Handle empty inner range (#40)
Browse files Browse the repository at this point in the history
When the inner range is empty, all points in the outer range are part
of the edge. Previously, however, the iterator would hang, causing
timeouts for ImageFiltering's test suite.
  • Loading branch information
timholy authored Dec 29, 2022
1 parent 07a8825 commit e17daf5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TiledIteration"
uuid = "06e1c1a7-607b-532d-9fad-de7d9aa2abac"
author = ["Tim Holy <[email protected]>"]
version = "0.4.1"
version = "0.4.2"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
2 changes: 1 addition & 1 deletion src/TiledIteration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Find the next index in `outer` that is not in `inner` if `I` is not an edge site
# If all of (I2, ..., IN) are in inner, then we can skip iterating I1 ∈ inner1
# and jump ahead to I1 = last(inner1). On the other hand if any of (I2, ..., IN)
# are not in inner we keep iterating over I1 ∈ inner1.
while I.I[1] == first(iter.inner)[1] && all(map(in, tail(I.I), tail(iter.inner.indices)))
while I.I[1] iter.inner.indices[1] && all(map(in, tail(I.I), tail(iter.inner.indices)))
state = (last(iter.inner)[1], tail(I.I)...)
I = CartesianIndex(_inc(state, iter.outer))
end
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ end
for it in iter
@test it iter.outer
end

# empty inner
iter = EdgeIterator((1:4,), (3:2,))
@test collect(iter) == [CartesianIndex(1),
CartesianIndex(2),
CartesianIndex(3),
CartesianIndex(4),
]
end

@testset "padded sizes" begin
Expand Down

2 comments on commit e17daf5

@timholy
Copy link
Member Author

Choose a reason for hiding this comment

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

@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/74774

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.4.2 -m "<description of version>" e17daf5bc6bed3549374e1b0572086211baa6ae2
git push origin v0.4.2

Please sign in to comment.