Skip to content

mean(img) type instability when img is of eltype Gray{N0f8} #134

@johnnychen94

Description

@johnnychen94
julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 8

julia> using ImageCore, Statistics

julia> x = rand(Gray{N0f8}, 4, 4);

julia> @code_warntype mean(x)

Variables
  #self#::Core.Compiler.Const(Statistics.mean, false)
  A::Array{Gray{Normed{UInt8,8}},2}

Body::Union{}
1 ─     Statistics.:(var"#mean#2")(Statistics.:(:), #self#, A)
└──     Core.Compiler.Const(:(return %1), false)

which is good, but once I load ColorVectorSpace, it isn't anymore:

julia> using ColorVectorSpace

julia> @code_warntype mean(x)
Variables
  #self#::Core.Compiler.Const(Statistics.mean, false)
  A::Array{Gray{Normed{UInt8,8}},2}

Body::Union{Gray{Float32}, Gray{Float64}}
1%1 = Statistics.:(var"#mean#2")(Statistics.:(:), #self#, A)::Union{Gray{Float32}, Gray{Float64}}
└──      return %1

Both Gray{Float32} and N0f8 are good here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions