-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Output type handling (fixes #17) #19
Conversation
Hm. The error message included above is not as informative as the one you get if you add a simple
I still don't understand why it happens, though. |
This now handles |
9bb7ec1
to
35a9342
Compare
@timholy, When trying to loosen the type constraints on
which is basically paramount to using the approach you suggested in #17, where we convert index arguments to I've tried to define a bunch of more specific versions, but I keep hitting ambiguity warnings with methods defined for either |
35a9342
to
c320606
Compare
Almost there! As shown in the tests added in 876b439, we now handle the following very nicely: julia> begin
using Interpolations
A = Float32[sin(x) for x in 1:10]
itp = Interpolation(A, Quadratic(Free(),OnCell()), ExtrapNaN())
typeof(itp[3.5]
end
Float32 When doing similar things with julia> using Interpolations
julia> begin
A = Rational{Int}[x^3/10 for x in 1:10]
itp = Interpolation(A, Quadratic(Free(),OnCell()), ExtrapNaN())
typeof(itp[1.1]
end
Rational{Int64} (constructor with 1 method)
# but
julia> itp[1.2]
ERROR: InexactError()
in convert at rational.jl:55
in getindex at /home/tlycken/.julia/v0.3/Interpolations/src/Interpolations.jl:41
in getindex at no file (The line number is bogus - I suspect the stack trace is confused by all the macros.) I'm inclined to think that the I also haven't been able to get it working with julia> using SIUnits
julia> A = rand(10) * Meter
10-element Array{SIQuantity{Float64,m,kg,s,A,K,mol,cd},1}:
0.5183854583783836 m
0.8765064944858227 m
0.4192598255113509 m
0.9242719465967721 m
0.17465399083656008 m
0.8607878925114967 m
0.569900709139 m
0.36160720059717244 m
0.38120696026732115 m
0.9492328404669232 m
julia> itpSI = Interpolation(A, Quadratic(Free(), OnCell()), ExtrapNaN())
WARNING: For performance reasons, consider using an array of a concrete type T (eltype(A) == SIQuantity{Float64,m,kg,s,A,K,mol,cd})
ERROR: Unit mismatch. Got () + (m )
in error at error.jl:21
in + at /home/tlycken/.julia/v0.3/SIUnits/src/SIUnits.jl:156
in + at array.jl:721
in prefilter at /home/tlycken/.julia/v0.3/Interpolations/src/Interpolations.jl:235
in Interpolation at /home/tlycken/.julia/v0.3/Interpolations/src/Interpolations.jl:73
in Interpolation at /home/tlycken/.julia/v0.3/Interpolations/src/Interpolations.jl:75 The problem seems to be that although all elements of Any suggestions on how to approach these two problems ( |
I'm looking into the errors. But one immediate comment: one problem with insisting on |
Support quadratic interpolation of Rational types
Given Jeff's comment jere, I think we can come to the following conclusions:
|
Yep, I agree we're good to go. But on 0.4 we don't need to write any code to implement iteration, since 0.4 supports multidimensional iteration. |
@timholy I was hoping you'd say that ;) I'll see if I can cook up something final for this PR later today. |
Some re-structuring of the ngenerate calls will be done in later commits, so this one won't build...
Huzza! This now works with
|
Hooray! I'm all in favor of merging. |
WIP: Output type handling (fixes #17)
This is a first attempt at a solution to #17, but it doesn't work quite yet:
The line in question is
which happens to be the first time the interpolation object is indexed into with an
Int
- all previous versions calls have indexed with a float...However, from what I can tell there should be a suitable indexing method defined - I thought I did so here. Also,
methods
seems a little confused - shouldn'tx
be anNTuple
here?