Skip to content

only irrationals from MathConstants are supported #225

@tpapp

Description

@tpapp

With the MWE

using StatsFuns, IntervalArithmetic, IntervalRootFinding
function interval_solver_internal(Cm::T, Dm::T, Cf::T, Df::T) where T
    f(p) = normcdf(Cm + Dm * normcdf(Cf + Df * p)) - p
    roots(f, interval(0.0, 1.0))
end

I run into the stack trace

ERROR: ArgumentError: only irrationals from MathConstants are supported
Stacktrace:
  [1] _round(::Type{Float64}, ::IrrationalConstants.Invsqrt2π, ::RoundingMode{:Down})
    @ IntervalArithmetic ~/.julia/packages/IntervalArithmetic/0gLWz/src/intervals/construction.jl:90
  [2] _unsafe_bareinterval(::Type{Float64}, a::IrrationalConstants.Invsqrt2π, b::IrrationalConstants.Invsqrt2π)
    @ IntervalArithmetic ~/.julia/packages/IntervalArithmetic/0gLWz/src/intervals/construction.jl:77
  [3] _interval_infsup(::Type{…}, a::IrrationalConstants.Invsqrt2π, b::IrrationalConstants.Invsqrt2π, d::IntervalArithmetic.Decoration)
    @ IntervalArithmetic ~/.julia/packages/IntervalArithmetic/0gLWz/src/intervals/construction.jl:420
  [4] #interval#3
    @ ~/.julia/packages/IntervalArithmetic/0gLWz/src/intervals/construction.jl:389 [inlined]
  [5] interval(::Type{Float64}, a::IrrationalConstants.Invsqrt2π, d::IntervalArithmetic.Decoration)
    @ IntervalArithmetic ~/.julia/packages/IntervalArithmetic/0gLWz/src/intervals/construction.jl:388
  [6] interval(::Type{Float64}, a::IrrationalConstants.Invsqrt2π)
    @ IntervalArithmetic ~/.julia/packages/IntervalArithmetic/0gLWz/src/intervals/construction.jl:388
  [7] convert(::Type{Interval{Float64}}, x::IrrationalConstants.Invsqrt2π)
    @ IntervalArithmetic ~/.julia/packages/IntervalArithmetic/0gLWz/src/intervals/construction.jl:558
  [8] _promote
    @ ./promotion.jl:375 [inlined]
  [9] promote
    @ ./promotion.jl:400 [inlined]
 [10] *(x::Interval{Float64}, y::IrrationalConstants.Invsqrt2π)
    @ Base ./promotion.jl:430
 [11] normpdf(z::Interval{Float64})
    @ StatsFuns ~/.julia/packages/StatsFuns/gSNRw/src/distrs/norm.jl:13

I understand the logic of the error message, but I am wondering what would be the best way to go forward here. Add a _round method for these types, maybe loaded conditionally?

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