Skip to content

Commit 5c906aa

Browse files
committed
Fix eltype handling in output_arrays and add test for RGB pyramid
1 parent 19660b3 commit 5c906aa

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/PyramidScheme.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ If the array is smaller than 10e6 it is created on disk and otherwise as a tempo
280280
function gen_output(t,s; path=tempname())
281281
# This should be dispatching on the output type whether it is internal or external
282282
outsize = sizeof(t)*prod(s)
283-
z = Zeros(t, s...)
284283
if outsize > 100e6
285284
# This should be zgroup instead of zcreate, could use savedataset(skelton=true)
286285
# Dummy dataset with FillArrays with the shape of the pyramidlevel
@@ -383,8 +382,8 @@ function getpyramids(reducefunc, ras;recursive=true)
383382
end
384383
pyramid_sizes = [ceil.(Int, size(ras) ./ 2^i) for i in 1:n_level]
385384
pyramid_axes = [agg_axis.(input_axes,2^i) for i in 1:n_level]
386-
387-
outmin = output_arrays(pyramid_sizes, Float32)
385+
outtype = typeof(reducefunc(rand(eltype(ras),2,2)))
386+
outmin = output_arrays(pyramid_sizes, outtype)
388387
fill_pyramids(ras,outmin,reducefunc,recursive; threaded=true)
389388

390389
outmin, pyramid_axes

test/runtests.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ end
4343
@test parent(subpyramid) == data[1:10,1:10]
4444
fig, axis, h = plot(pyramid)
4545
end
46+
47+
@testitem "Pyramid building RGB eltype" begin
48+
using PyramidScheme: PyramidScheme as PS
49+
using Colors
50+
data = rand(RGB, 2000,2000)
51+
dd = DimArray(data, (X(1:2000), Y(1:2000)))
52+
pyramid = PS.Pyramid(dd)
53+
54+
55+
end
56+
4657
@testitem "Helper functions" begin
4758
using PyramidScheme: PyramidScheme as PS
4859
@test PS.compute_nlevels(zeros(1000)) == 2
@@ -107,6 +118,7 @@ end
107118

108119
end
109120

121+
110122
#=
111123
@testitem "Comparing zarr pyramid with tif pyramid" begin
112124
using PyramidScheme: PyramidScheme as PS

0 commit comments

Comments
 (0)