-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Description
Could we enhance the promotion of SimpleRatio so that it can work with FixedPointNumbers? Many images are encoded in FixedPointNumbers and this would be useful to apply Interpolations to them directly.
Minimum Working Example:
julia> using Ratios, FixedPointNumbers
julia> SimpleRatio(5,3) * 0.035N0f8
ERROR: promotion of types SimpleRatio{Int64} and N0f8 failed to change any arguments
Stacktrace:
[1] error(::String, ::String, ::String)
@ Base .\error.jl:42
[2] sametype_error(input::Tuple{SimpleRatio{Int64}, N0f8})
@ Base .\promotion.jl:316
[3] not_sametype(x::Tuple{SimpleRatio{Int64}, N0f8}, y::Tuple{SimpleRatio{Int64}, N0f8})
@ Base .\promotion.jl:310
[4] promote
@ .\promotion.jl:293 [inlined]
[5] *(x::SimpleRatio{Int64}, y::N0f8)
@ Base .\promotion.jl:322
[6] top-level scope
@ REPL[51]:1Motivating Example:
xref: JuliaMath/Interpolations.jl#413
cc: @johnnychen94
julia> using FixedPointNumbers, Interpolations
julia> r = reinterpret(N0f8,[0x73, 0x94, 0x66, 0x1e])
4-element reinterpret(N0f8, ::Vector{UInt8}):
0.451N0f8
0.58N0f8
0.4N0f8
0.118N0f8
julia> itp = interpolate(r, BSpline(Quadratic(Flat(OnGrid()))));
julia> itp
4-element interpolate(OffsetArray(::Array{N0f8,1}, 0:5), BSpline(Quadratic(Flat(OnGrid())))) with element type Float64:
Error showing value of type Interpolations.BSplineInterpolation{Float64, 1, OffsetArrays.OffsetVector{N0f8, Vector{N0f8}}, BSpline{Quadratic{Flat{OnGrid}}}, Tuple{Base.OneTo{Int64}}}:
ERROR: promotion of types Ratios.SimpleRatio{Int64} and N0f8 failed to change any arguments
Stacktrace:
[1] error(::String, ::String, ::String)
@ Base .\error.jl:42
[2] sametype_error(input::Tuple{Ratios.SimpleRatio{Int64}, N0f8})
@ Base .\promotion.jl:316
[3] not_sametype(x::Tuple{Ratios.SimpleRatio{Int64}, N0f8}, y::Tuple{Ratios.SimpleRatio{Int64}, N0f8})
@ Base .\promotion.jl:310
[4] promote
@ .\promotion.jl:293 [inlined]
[5] *(x::Ratios.SimpleRatio{Int64}, y::N0f8)
@ Base .\promotion.jl:322Metadata
Metadata
Assignees
Labels
No labels