Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add upsample_nearest #269

Merged
merged 9 commits into from
Jan 20, 2021
Merged
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion src/upsample.jl
Original file line number Diff line number Diff line change
@@ -21,7 +21,10 @@ julia> upsample_nearest([1 2 3; 4 5 6], (2,3))
4 4 4 5 5 5 6 6 6
```
"""
upsample_nearest(x::AbstractArray, s::Integer) = upsample_nearest(x, ntuple(_->s, ndims(x)-2))
function upsample_nearest(x::AbstractArray, s::Integer)
ndims(x) > 2 || throw(ArgumentError("expected x with at least 3 dimensions"))
upsample_nearest(x, ntuple(_->s, ndims(x)-2))
end

function upsample_nearest(x::AbstractArray{T,N}, scales::NTuple{S, <:Integer}) where {T,N,S}
S in 1:N || throw(ArgumentError("can't upsample ndims(x)=$N with scale=$scales"))
1 change: 1 addition & 0 deletions test/upsample.jl
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@

@test_throws ArgumentError ∇upsample_nearest(y, (2,4))
@test_throws ArgumentError upsample_nearest(x, (1,2,3,4,5))
@test_throws ArgumentError upsample_nearest(upsample_nearest(rand(2,3),4), 5)
end

@testset "upsample_bilinear 2d" begin