Skip to content

scaling using a LinRange unsupported #293

@danmackinlay

Description

@danmackinlay

Two nearly-equivalent ranges used for scaling produce different behavior:
The one using StepRangeLen works fine.

> using Interpolations
> s= [x^2 for x in 1:5]
> ts = StepRangeLen(0, 0.5, 5)
> itp = interpolate(s, (BSpline(Cubic(Line(OnGrid())))))
> sitp = scale(itp, ts)
5-element scale(interpolate(OffsetArray(::Array{Float64,1}, 0:6), BSpline(Cubic(Line(OnGrid())))), (0.0:0.5:2.0,)) with element type Float64:
  0.9999999999999999
  4.0               
  8.999999999999998 
 15.999999999999998 
 24.999999999999996 

However, using LinRange produces an error

> using Interpolations
> s= [x^2 for x in 1:5]
> ts = LinRange(0, 2.0, 5)
> itp = interpolate(s, (BSpline(Cubic(Line(OnGrid())))))
> sitp = scale(itp, ts)
MethodError: no method matching coordlookup(::LinRange{Float64}, ::Float64)
Closest candidates are:
  coordlookup(!Matched::NoInterp, ::Any, !Matched::Any) at /home/danmackinlay/.julia/dev/Interpolations/src/scaling/scaling.jl:88
  coordlookup(!Matched::Interpolations.Flag, ::Any, !Matched::Any) at /home/danmackinlay/.julia/dev/Interpolations/src/scaling/scaling.jl:89
  coordlookup(!Matched::UnitRange, ::Any) at /home/danmackinlay/.julia/dev/Interpolations/src/scaling/scaling.jl:91
  ...

I wish to avoid StepRangeLen, as it uses TwicePrecision number internally, and these have irritating properties when using ForwardDiff.

Possibly related: #165

This looks fixable; in fact I'm stuck on understanding the test suite which stubbornly refuses to fail for me when I try to insert a test for this, which is probably due to a case of foolishness on my part

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions