timholy / Grid.jl

Interpolation and related operations on grids
MIT License
47 stars 26 forks source link

Allow interpolation with units! #35

Closed mbauman closed 10 years ago

mbauman commented 10 years ago

This patch allows InterpIrregular grids to be unitful (from SIUnits). InterpIrregular grids now accept Numbers for both creation and indexing. Because getindex is defined for Real on AbstractArrays, Grid needs to define both getindex(..., ::Real) and getindex(..., ::Number) to avoid ambiguity.

Here's what this allows:

julia> InterpIrregular([1.s,2.s,3.s], big([2.,3.,4.]), 0., InterpLinear)[1.5s:2.5s]
2-element Array{BigFloat,1}:
 2.5e+00
 3.5e+00

Of course, if you have a unitful grid, you must index it with compatible units.

coveralls commented 10 years ago

Coverage Status

Coverage remained the same when pulling 06c4ff9182d3c49cbba0ac7c3e528cfdf9435405 on mbauman:siunits into ad2f1d79fcba47febd748bb6cf0364a3495d3364 on timholy:master.

timholy commented 10 years ago

Nice. In addition to SIUnits, this will make it easier to use DualNumbers when you want to check those derivatives.

The travis failure is odd: it seems to be trying to pull in Signals.jl, and that's what's failing. But I don't see anything in this that causes that behavior.

mbauman commented 10 years ago

Hah, pay no mind to that failure. That's the failure from a referenced commit within Signals.jl... which fails because it requires this patch. The Grid.jl tests passed just fine.

Great to hear this is more generally useful. I think it should be good to go.

timholy commented 10 years ago

Hah, I didn't even notice the context. No wonder I couldn't figure out where it was coming from.

timholy commented 10 years ago

Thanks again!

mbauman commented 10 years ago

Thanks!