Skip to content

Commit

Permalink
tiled_processing was slightly changed by removing the res_type argument
Browse files Browse the repository at this point in the history
  • Loading branch information
RainerHeintzmann committed Jul 13, 2021
1 parent c253475 commit 2b88cd7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 8 additions & 4 deletions src/TiledViews.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,11 @@ end


"""
tiled_processing(tiled_view::TiledView, fct; res_type = Float32, verbose=true, dtype=Float32, window_function=window_hanning)
tiled_processing(tiled_view::TiledView, fct; verbose=true, dtype=eltype(tiled_view.parent), window_function=window_hanning)
processes a raw dataset using tiled views by submitting each tile to the function `fct` and merging the results via the `window_function`.
"""
function tiled_processing(tiled_view::TiledView, fct; res_type = Float32, verbose=true, dtype=Float32, window_function=window_hanning)
@time res = zeros_like(tiled_view, res_type)
function tiled_processing(tiled_view::TiledView, fct; verbose=true, dtype=eltype(tiled_view.parent), window_function=window_hanning)
@time res = zeros_like(tiled_view, dtype)
res.parent .= zero(dtype)
@time win = get_window(tiled_view, window_function=window_function)
ttn = get_num_tiles(tiled_view)
Expand All @@ -404,7 +404,11 @@ function tiled_processing(tiled_view::TiledView, fct; res_type = Float32, verbos
return res
end

function tiled_processing(data, fct, tile_size, tile_overlap; verbose=true, dtype=nothing, keep_center=false, window_function=window_hanning)
"""
tiled_processing(data, fct; verbose=true, dtype=eltype(data), window_function=window_hanning)
processes a raw dataset using tiled views by submitting each tile to the function `fct` and merging the results via the `window_function`.
"""
function tiled_processing(data, fct, tile_size, tile_overlap; verbose=true, dtype=eltype(data), keep_center=false, window_function=window_hanning)
tiles = TiledView(data, tile_size, tile_overlap, keep_center=keep_center);
return tiled_processing(tiles,fct; verbose=verbose, dtype=dtype, window_function=window_function)
end
Expand Down
10 changes: 6 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ end
#tiles[:,:,:,:] .+= to_write[:,:,:,:] ; # why can one NOT use [:,:,:,:]?
tiles .+= to_write ; # why can one NOT use [:,:,:,:]?
@test sum(abs.(dest[50:end-50,50:end-50] .- 1.2)) < 1e-10
win2, mynorm = get_window(tiles, get_norm=true);
win2, mynorm = get_window(tiles, get_norm=true, verbose=true);
@test all(win .== win2)
tiles, win = TiledWindowView(dest, tile_size, rel_overlap=(1.0,1.0), get_norm=true);
@test all(win .== win2)
end

Expand All @@ -93,7 +95,7 @@ end
@testset "eachtile" begin
q = zeros(100,101);
a=TiledView(q, (80,91), (0,0));
for (t,tn,tc) in zip(eachtile(a),eachtilenumber(a),eachtilerelpos(a))
for (t,tn,tc,tc2) in zip(eachtile(a),eachtilenumber(a),eachtilerelpos(a),eachtilerelpos(a,2.0))
t[:] .+= tn[1];
end
@test q[end,end] == 2
Expand All @@ -102,8 +104,8 @@ end
@testset "tiled_processing" begin
q = ones(10,10,10);
a = TiledView(q, (4,4,4), (2,2,2));
fkt(a)=sin.(a)
res = tiled_processing(a,fkt);
fct(a)=sin.(a)
res = tiled_processing(q, fct, (4,4,4), (2,2,2))
@test maximum(res.parent) sin(1)
end

Expand Down

3 comments on commit 2b88cd7

@RainerHeintzmann
Copy link
Member Author

Choose a reason for hiding this comment

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

@RainerHeintzmann
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/40804

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.1.0 -m "<description of version>" 2b88cd73c6785c20c001e0ac3dcbf48584bd6231
git push origin v0.1.0

Please sign in to comment.