Skip to content

Domain error when inferring array type in 0-length degenerated case #29

@fverdugo

Description

@fverdugo

Hi!

do you plan to support degenerated cases like the one below in the future?

Just for curiosity, how would you fix this in the library? Is it possible to fix it without calling something like Base._return_type?

Thanks for the help!

julia> using MappedArrays

julia> a = fill(1,0)
0-element Array{Int64,1}

julia> f(x) = sqrt(x-1)
f (generic function with 1 method)

julia> mappedarray(f,a)
ERROR: DomainError with -1.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
Stacktrace:
 [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31
 [2] sqrt at ./math.jl:493 [inlined]
 [3] sqrt at ./math.jl:519 [inlined]
 [4] f at ./REPL[3]:1 [inlined]
 [5] mappedarray(::typeof(f), ::Array{Int64,1}) at /home/fverdugo/.julia/packages/MappedArrays/8HESW/src/MappedArrays.jl:61
 [6] top-level scope at REPL[4]:1

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