-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no direct dependency on OffsetArrays
- Loading branch information
1 parent
014a6e6
commit 99bb822
Showing
5 changed files
with
25 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# Requires OffsetArrays v1.9 | ||
# https://github.com/JuliaArrays/OffsetArrays.jl/pull/242 | ||
# Originally from ImageFiltering https://github.com/JuliaImages/ImageFiltering.jl/pull/214 | ||
OffsetArrays.centered(ax::Axis{name}) where name = Axis{name}(OffsetArrays.centered(ax.val)) | ||
OffsetArrays.centered(a::AxisArray) = AxisArray(OffsetArrays.centered(a.data), OffsetArrays.centered.(AxisArrays.axes(a))) | ||
if isdefined(OffsetArrays, :centered) | ||
# Requires OffsetArrays v1.9 | ||
# https://github.com/JuliaArrays/OffsetArrays.jl/pull/242 | ||
# Originally from ImageFiltering https://github.com/JuliaImages/ImageFiltering.jl/pull/214 | ||
OffsetArrays.centered(ax::Axis{name}) where name = Axis{name}(OffsetArrays.centered(ax.val)) | ||
OffsetArrays.centered(a::AxisArray) = AxisArray(OffsetArrays.centered(a.data), OffsetArrays.centered.(AxisArrays.axes(a))) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
@testset "centered" begin | ||
check_range(r, f, l) = (@test first(r) == f; @test last(r) == l) | ||
check_range_axes(r, f, l) = check_range(Base.axes(r)[1], f, l) | ||
if isdefined(OffsetArrays, :centered) # OffsetArrays v1.9 | ||
check_range(r, f, l) = (@test first(r) == f; @test last(r) == l) | ||
check_range_axes(r, f, l) = check_range(Base.axes(r)[1], f, l) | ||
|
||
check_range(Base.axes(OffsetArrays.centered(1:3))[1], -1, 1) | ||
a = AxisArray(rand(3, 3), Axis{:y}(0.1:0.1:0.3), Axis{:x}(1:3)) | ||
check_range(Base.axes(OffsetArrays.centered(1:3))[1], -1, 1) | ||
a = AxisArray(rand(3, 3), Axis{:y}(0.1:0.1:0.3), Axis{:x}(1:3)) | ||
|
||
ca = OffsetArrays.centered(a) | ||
axs = Base.axes(ca) | ||
check_range(axs[1], -1, 1) | ||
check_range(axs[2], -1, 1) | ||
@test ca[OffsetArrays.center(ca)...] == a[OffsetArrays.center(a)...] | ||
ca = OffsetArrays.centered(a) | ||
axs = Base.axes(ca) | ||
check_range(axs[1], -1, 1) | ||
check_range(axs[2], -1, 1) | ||
@test ca[OffsetArrays.center(ca)...] == a[OffsetArrays.center(a)...] | ||
|
||
axs = AxisArrays.axes(ca) | ||
check_range(axs[1].val, 0.1, 0.3) | ||
check_range(axs[2].val, 1, 3) | ||
check_range_axes(axs[1].val, -1, 1) | ||
check_range_axes(axs[1].val, -1, 1) | ||
axs = AxisArrays.axes(ca) | ||
check_range(axs[1].val, 0.1, 0.3) | ||
check_range(axs[2].val, 1, 3) | ||
check_range_axes(axs[1].val, -1, 1) | ||
check_range_axes(axs[1].val, -1, 1) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters