Skip to content

Commit fce96c7

Browse files
committed
added compat req and dimensionality checks
1 parent d9cb028 commit fce96c7

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Project.toml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1313

1414
[compat]
1515
StaticArrays = "0.5, 0.6, 0.7, 0.8, 0.9, 0.10, 0.11, 0.12, 1.0"
16+
Interpolations = "0.13.4"
1617
julia = "1"
1718

1819
[extras]

src/frebin.jl

+6-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Shrink or expand the size of an array an arbitrary amount using interpolation
106106
107107
### Arguments ###
108108
109-
* `image`: the array representing the image to be rebinned.
109+
* `image`: the array representing the 1D or 2D image to be rebinned.
110110
* `nsout`: number of samples in the output image, numeric scalar.
111111
* `nlout` (optional): number of lines in the output image, numeric scalar (default = 1).
112112
* `total` (optional boolean keyword): if true, the output pixels will be the
@@ -167,5 +167,10 @@ Improve speed by addressing arrays in memory order W.Landsman Dec/Jan 2001
167167
Code of this function is based on IDL Astronomy User's Library.
168168
"""
169169
function frebin(image::AbstractArray{R}, nsout::Real, nlout::Real=1; total::Bool=false) where {R<:Real}
170+
171+
# check that the image dimensions are either 1D or 2D
172+
nd = ndims(image)
173+
@assert nd in (1,2) "The input image must be either 1D or 2D!"
174+
170175
_frebin(float(image), promote(floor(Int, nsout), floor(Int, nlout))..., total)
171176
end

src/fshift.jl

+4
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,9 @@ Code of this function is based on IDL Astronomy User's Library.
8181
8282
"""
8383
function fshift(image::AbstractArray{R}, Δx::Real, Δy::Real) where {R<:Real}
84+
# check that the image dimensions are 2D
85+
nd = ndims(image)
86+
@assert nd == 2 "The input image must be 2D!"
87+
8488
_fshift(float(image), promote(float(Δx), float(Δy))...)
8589
end

0 commit comments

Comments
 (0)