-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type-unstable similar
and copy
#356
Comments
I've around this and it seems the type-unstability resumes to line https://github.com/timholy/Images.jl/blob/master/src/core.jl#L14 , |
And this seems to be an upstream issue: type X{T}; end
f(x) = X{ndims(x)}()
code_warntype(f, (Array{Int,2},)) returns
Does anyone knows if this is something already discussed in Julia list or issues? |
It's due to this: julia> @inferred(deepcopy(img.properties))
ERROR: return type Dict{ASCIIString,Any} does not match inferred return type Any
in error at ./error.jl:21 which is used in Images' copy function. We use it because of this: julia> p = Dict{ASCIIString,Any}("Hi" => rand(2,2))
Dict{ASCIIString,Any} with 1 entry:
"Hi" => 2x2 Array{Float64,2}:…
julia> pointer(p["Hi"])
Ptr{Float64} @0x00007fbccb82b760
julia> pc = copy(p)
Dict{ASCIIString,Any} with 1 entry:
"Hi" => 2x2 Array{Float64,2}:…
julia> pointer(pc["Hi"])
Ptr{Float64} @0x00007fbccb82b760 |
There may be different causes for the issue at each method. For the There is a workaround for that, and I Image{T,N}(data::AbstractArray{T,N}, props::Dict) = Image{eltype(data),N,typeof(data)}(data,props) will fix |
Workaround JuliaLang/julia#13082. Trying to partially fix JuliaImages#356.
Circumvent type-instability of deepcopy. Fixes #356
For example, doing
code_warntype(copy, (Images.Image{Float64,2,Array{Float64,2}},))
, yields an abstract::Images.Image{T,N,A<:AbstractArray{T,N}}
return type.This also happens with the
similar
method, and seems to be due to a type-unstableImage
constructor.The text was updated successfully, but these errors were encountered: