|
5 | 5 | ScaledInterpolation{T,ITPT,IT,GT,RT}(::Type{T}, N, itp::ITPT, ::Type{IT}, ::Type{GT}, ranges::RT) = |
6 | 6 | ScaledInterpolation{T,N,ITPT,IT,GT,RT}(itp, ranges) |
7 | 7 | function scale{T,N,IT,GT}(itp::AbstractInterpolation{T,N,IT,GT}, ranges::Range...) |
8 | | - length(ranges) == N || error("Must scale $N-dimensional interpolation object with exactly $N ranges (you used $(length(ranges)))") |
| 8 | + length(ranges) == N || throw(ArgumentError("Must scale $N-dimensional interpolation object with exactly $N ranges (you used $(length(ranges)))")) |
9 | 9 | for d in 1:N |
10 | 10 | if iextract(IT,d) != NoInterp |
11 | | - length(ranges[d]) == size(itp,d) || error("The length of the range in dimension $d ($(length(ranges[d]))) did not equal the size of the interpolation object in that direction ($(size(itp,d)))") |
| 11 | + length(ranges[d]) == size(itp,d) || throw(ArgumentError("The length of the range in dimension $d ($(length(ranges[d]))) did not equal the size of the interpolation object in that direction ($(size(itp,d)))")) |
12 | 12 | elseif ranges[d] != 1:size(itp,d) |
13 | | - error("NoInterp dimension $d must be scaled with unit range 1:$(size(itp,d))") |
| 13 | + throw(ArgumentError("NoInterp dimension $d must be scaled with unit range 1:$(size(itp,d))")) |
14 | 14 | end |
15 | 15 | end |
16 | 16 |
|
@@ -42,7 +42,7 @@ gradient{T,N}(sitp::ScaledInterpolation{T,N}, xs...) = gradient!(Array(T,N), sit |
42 | 42 | interp_indices = map(i -> interp_dimens[i] ? :(coordlookup(sitp.ranges[$i], xs[$i])) : :(xs[$i]), 1:N) |
43 | 43 |
|
44 | 44 | quote |
45 | | - length(g) == N || error(string("g must be a vector of length ", N, " (was ", length(g), ")")) |
| 45 | + length(g) == N || throw(ArgumentError(string("g must be a vector of length ", N, " (was ", length(g), ")"))) |
46 | 46 | gradient!(g, sitp.itp, $(interp_indices...)) |
47 | 47 | for i in eachindex(g) |
48 | 48 | g[i] = rescale_gradient(sitp.ranges[i], g[i]) |
|
0 commit comments