Skip to content

Commit

Permalink
Fix bug in scaling ScaFTEdge for odd-sized arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
roflmaostc committed Apr 21, 2021
1 parent 6e1eb67 commit 67dabd2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/scaling_offset_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ get_scale(sz, ::Type{ScaNorm}) = 1 ./ (max.(sz .- 1, 1))
get_scale(sz, ::Type{ScaMid}) = 1 ./ (max.((sz .- 1)./2, 1)) # reaches 1.0 at the outermost pixel.
get_scale(sz, ::Type{ScaFT}) = 0.5 ./ (max.(sz ./ 2, 1))
# get_scale(size, ::Type{ScaRFT}) = 0.5 ./ (max.(Base.setindex(size./ 2,size[1]-1,1), 1)) # These scales are wrong! They need the information on the real-space size!
get_scale(sz, ::Type{ScaFTEdge}) = 1 ./ (max.(sz ./ 2, 1))
get_scale(sz, ::Type{ScaFTEdge}) = 1 ./ (max.(sz .÷ 2, 1))
# get_scale(size, ::Type{ScaRFTEdge}) = 1 ./ (max.(Base.setindex(size./ 2,size[1]-1,1), 1))
get_scale(sz, t::Number) = ntuple(i -> t, length(sz))
get_scale(dummy, t::NTuple) = t
Expand Down
2 changes: 1 addition & 1 deletion test/concrete_generators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
@test rr((10,), scale = ScaNorm) == [0.5555555555555556, 0.4444444444444444, 0.3333333333333333, 0.2222222222222222, 0.1111111111111111, 0.0, 0.1111111111111111, 0.2222222222222222, 0.3333333333333333, 0.4444444444444444]
@test rr((10,), scale = ScaFT) == [0.5, 0.4, 0.30000000000000004, 0.2, 0.1, 0.0, 0.1, 0.2, 0.30000000000000004, 0.4]

@test rr((11,), scale = ScaFTEdge) == [ 0.9090909090909092, 0.7272727272727273, 0.5454545454545454, 0.36363636363636365, 0.18181818181818182, 0.0, 0.18181818181818182, 0.36363636363636365, 0.5454545454545454, 0.7272727272727273, 0.9090909090909092]
@test rr((11,), scale = ScaFTEdge) == [1.0, 0.8, 0.6000000000000001, 0.4, 0.2, 0.0, 0.2, 0.4, 0.6000000000000001, 0.8, 1.0]
# 1.0, 0.8, 0.6000000000000001, 0.4, 0.2, 0.0, 0.2, 0.4, 0.6000000000000001, 0.8, 1.0]

@test rr((10,), scale = ScaFTEdge) == [1.0, 0.8, 0.6000000000000001, 0.4, 0.2, 0.0, 0.2, 0.4, 0.6000000000000001, 0.8]
Expand Down

2 comments on commit 67dabd2

@roflmaostc
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 register

Release notes:

  • Bugfix for ScaFTEdge
  • List as scale or offset is now possible

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Error while trying to register: "Tag with name v0.1.5 already exists and points to a different commit"

Please sign in to comment.