JuliaArrays / JuliaArrays/MappedArrays.jl
Domain error when inferring array type in 0-length degenerated case
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 88
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the mappedarray entry point in src/MappedArrays.jl:61 and reproduce the empty-array example using MappedArrays and sqrt(x-1). Determine how the result type is inferred for a zero-length array and whether the reported DomainError can be avoided without Base._return_type; done means the degenerate case is handled with an agreed result type and behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100