Skip to content

Commit 18cc592

Browse files
committed
Merge branch 'ras/showarg0.7a' of https://github.com/RalphAS/Interpolations.jl into RalphAS-ras/showarg0.7a
2 parents 6e48e07 + 57109c9 commit 18cc592

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

src/io.jl

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# after this, functionality was incorporated into Base
2+
if VERSION < v"0.7.0-DEV.1790"
13
using ShowItLikeYouBuildIt
24

35
Base.summary(A::AbstractInterpolation) = summary_build(A)
@@ -53,6 +55,78 @@ function ShowItLikeYouBuildIt.showarg(io::IO, A::FilledExtrapolation{T,N,TI,IT,G
5355
print(io, ", ", A.fillvalue, ')')
5456
end
5557

58+
else
59+
60+
function Base.showarg(io::IO, A::BSplineInterpolation{T,N,TW,ST,GT}, toplevel) where {T,N,TW,ST,GT}
61+
print(io, "interpolate(")
62+
Base.showarg(io, A.coefs, false)
63+
print(io, ", ")
64+
_showtypeparam(io, ST)
65+
print(io, ", ")
66+
_showtypeparam(io, GT)
67+
if toplevel
68+
print(io, ") with element type ",T)
69+
else
70+
print(io, ')')
71+
end
72+
end
73+
74+
function Base.showarg(io::IO, A::GriddedInterpolation{T,N,TC,ST,K}, toplevel) where {T,N,TC,ST,K}
75+
print(io, "interpolate(")
76+
_showknots(io, A.knots)
77+
print(io, ", ")
78+
Base.showarg(io, A.coefs, false)
79+
print(io, ", ")
80+
_showtypeparam(io, ST)
81+
if toplevel
82+
print(io, ") with element type ",T)
83+
else
84+
print(io, ')')
85+
end
86+
end
87+
88+
_showknots(io, A) = Base.showarg(io, A, false)
89+
function _showknots(io, tup::NTuple{N,Any}) where N
90+
print(io, '(')
91+
for (i, A) in enumerate(tup)
92+
Base.showarg(io, A, false)
93+
i < N && print(io, ',')
94+
end
95+
N == 1 && print(io, ',')
96+
print(io, ')')
97+
end
98+
99+
function Base.showarg(io::IO, A::ScaledInterpolation{T}, toplevel) where {T}
100+
print(io, "scale(")
101+
Base.showarg(io, A.itp, false)
102+
print(io, ", ", A.ranges, ')')
103+
if toplevel
104+
print(io, " with element type ",T)
105+
end
106+
end
107+
108+
function Base.showarg(io::IO, A::Extrapolation{T,N,TI,IT,GT,ET}, toplevel) where {T,N,TI,IT,GT,ET}
109+
print(io, "extrapolate(")
110+
Base.showarg(io, A.itp, false)
111+
print(io, ", ")
112+
_showtypeparam(io, ET)
113+
print(io, ')')
114+
if toplevel
115+
print(io, " with element type ",T)
116+
end
117+
end
118+
119+
function Base.showarg(io::IO, A::FilledExtrapolation{T,N,TI,IT,GT}, toplevel) where {T,N,TI,IT,GT}
120+
print(io, "extrapolate(")
121+
Base.showarg(io, A.itp, false)
122+
print(io, ", ", A.fillvalue, ')')
123+
if toplevel
124+
print(io, " with element type ",T)
125+
end
126+
end
127+
128+
end
129+
56130
_showtypeparam(io, ::Type{T}) where {T} =
57131
print(io, T.name.name, "()")
58132
_showtypeparam(io, ::Type{Quadratic{T}}) where {T} =

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ include("typing.jl")
2727

2828
include("issues/runtests.jl")
2929

30-
# include("io.jl")
30+
include("io.jl")
3131
include("convenience-constructors.jl")
3232
include("readme-examples.jl")
3333

0 commit comments

Comments
 (0)