Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/PyramidSchemeMakieExt.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module PyramidSchemeMakieExt
using Makie: Axis, Colorbar, DataAspect, Figure, FigureAxisPlot, Observable, Relative
using Makie: Makie, Axis, Colorbar, DataAspect, Figure, FigureAxisPlot, Observable, Relative, Point2f, Rect3f
using Makie: on, heatmap!, map!
using Makie.ComputePipeline: add_input!
using Makie
using Makie: Heatmap, Image, Contour, Contourf, Contour3d, Spy, Surface

using PyramidScheme: Pyramid, switchkeys, levels, selectlevel, xkey, ykey
using DimensionalData: DimensionalData as DD
Expand Down
17 changes: 14 additions & 3 deletions src/PyramidScheme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and the `buildpyramids` function to generate the aggregation layers for an exist
"""
module PyramidScheme

using DiskArrayEngine: DiskArrayEngine, GMDWop, InputArray, LocalRunner, MovingWindow, RegularWindows
using DiskArrayEngine: DiskArrayEngine, GMDWop, InputArray, LocalRunner, RegularWindows
using DiskArrayEngine: create_outwindows, engine
using DiskArrays: DiskArrays
#using YAXArrays: savecube
Expand All @@ -18,8 +18,8 @@ using DimensionalData: DimensionalData as DD
using DimensionalData.Dimensions: XDim, YDim
using Extents: Extent, extent, intersects
using FillArrays: Zeros
using Proj
using OffsetArrays
using Proj: Proj
using OffsetArrays: OffsetArray

using Statistics: mean

Expand Down Expand Up @@ -89,6 +89,17 @@ Return the number of levels of the `pyramid`
nlevels(pyramid::Pyramid) = length(levels(pyramid)) - 1
Base.parent(pyramid::Pyramid) = pyramid.base
Base.size(pyramid::Pyramid) = size(parent(pyramid))
function Base.isequal(pyrA::Pyramid, pyrB::Pyramid)
nlevela = nlevels(pyrA)
nlevelb = nlevels(pyrB)
nlevela != nlevelb && return false
for i in nlevela:-1:1
isequal(pyrA.levels[i], pyrB.levels[i]) || return false
end
return isequal(pyrA.base, pyrB.base)
end

# all(isequal.(reverse(PyramidScheme.levels(pyrA)), reverse(PyramidScheme.levels(pyrB))))

DD.name(pyramid::Pyramid) = DD.name(parent(pyramid))
DD.refdims(pyramid::Pyramid) = DD.refdims(parent(pyramid))
Expand Down
22 changes: 22 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ end
using DimensionalData
pyr1 = Pyramid(fill(1,X(1:128),Y(1:128)), tilesize=16)
pyr2 = Pyramid(fill(1, X(1:128),Y(1:128)), tilesize=16, resampling_method=sum)

pyr1_neg = map(x-> x-1, pyr1)
@test all(all.(iszero, pyr1_neg.levels))
@test iszero(pyr1_neg.base)
Expand Down Expand Up @@ -196,6 +197,27 @@ end
limits!(ax, 200,300, 200, 300)
@test cb.limits[] == [-0.5, 0.5]
end

@testitem "isequal of two pyramids" begin
using DimensionalData
pyr1 = Pyramid(fill(1, X(1:128),Y(1:128)), tilesize=16)
pyr2 = Pyramid(fill(1, X(1:128),Y(1:128)), tilesize=16, resampling_method=sum)
@test !isequal(pyr1, pyr2)

a = fill(1, 100,100)
a[1:2:end, 1:2:end] .= 2
a[2:2:end, 2:2:end] .= 2
dda = DimArray(a, (X(1:100), Y(1:100)))
pyra = Pyramid(dda, tilesize=25)

b = fill(2, 100,100)
b[1:2:end, 1:2:end] .= 1
b[2:2:end, 2:2:end] .= 1
ddb = DimArray(b, (X(1:100), Y(1:100)))
pyrb = Pyramid(ddb, tilesize=25)
@test !isequal(pyra, pyrb)
@test !isequal(pyra, pyr1)
end
#=
@testitem "Comparing zarr pyramid with tif pyramid" begin
using PyramidScheme: PyramidScheme as PS
Expand Down
Loading