Skip to content

Commit 84d5b16

Browse files
authored
Document and export bounds (#353)
1 parent d994a14 commit 84d5b16

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/Interpolations.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export
55
interpolate!,
66
extrapolate,
77
scale,
8+
bounds,
89

910
AbstractInterpolation,
1011
AbstractExtrapolation,
@@ -107,6 +108,28 @@ axes(exp::AbstractExtrapolation) = axes(exp.itp)
107108

108109
twotuple(r::AbstractUnitRange) = (first(r), last(r))
109110
twotuple(x, y) = (x, y)
111+
112+
"""
113+
bounds(itp::AbstractInterpolation)
114+
115+
Return the `bounds` of the domain of `itp` as a tuple of `(min, max)` pairs for each coordinate. This is best explained by example:
116+
117+
```jldoctest
118+
julia> itp = interpolate([1 2 3; 4 5 6], BSpline(Linear()));
119+
120+
julia> bounds(itp)
121+
((1, 2), (1, 3))
122+
123+
julia> data = 1:3;
124+
125+
julia> knots = ([10, 11, 13.5],);
126+
127+
julia> itp = interpolate(knots, data, Gridded(Linear()));
128+
129+
julia> bounds(itp)
130+
((10.0, 13.5),)
131+
```
132+
"""
110133
bounds(itp::AbstractInterpolation) = map(twotuple, lbounds(itp), ubounds(itp))
111134
bounds(itp::AbstractInterpolation, d) = bounds(itp)[d]
112135

0 commit comments

Comments
 (0)