You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found this error while working with integer data, it seems to occur with every type of integer.
using MultivariateStats
int_matrix =rand(Int, (2, 2))
fit(PCA, int_matrix)
Error:
ERROR: TypeError:in typeassert, expected Array{Int8,1}, got Array{Float64,1}
Stacktrace:
[1] preprocess_mean(::Array{Int8,2}, ::Nothing) at /home/heladioac/.julia/packages/MultivariateStats/BYMwD/src/common.jl:25
[2] #fit#10(::Symbol, ::Int64, ::Float64, ::Nothing, ::Function, ::Type{PCA}, ::Array{Int8,2}) at /home/heladioac/.julia/packages/MultivariateStats/BYMwD/src/pca.jl:148
[3] fit(::Type{PCA}, ::Array{Int8,2}) at /home/heladioac/.julia/packages/MultivariateStats/BYMwD/src/pca.jl:138
[4] top-level scope at none:0
The problem seems to come specifically from preprocess_mean trying to return a Vector{Int} when X contains integers, while the expression vec(mean(X, dims=2)) always returns an array of type Float64 in my computer.
preprocess_mean(X::AbstractMatrix{T}, m) where T<:Real=
(m ==nothing?vec(mean(X, dims=2)) : m ==0? T[] : m)::Vector{T}
The text was updated successfully, but these errors were encountered:
Can you try removing ::Vector{T} and see whether it works? Replacing == nothing with === nothing should allow the compiler to infer the type correctly without this.
wildart
added a commit
to wildart/MultivariateStats.jl
that referenced
this issue
Mar 3, 2020
I found this error while working with integer data, it seems to occur with every type of integer.
Error:
The problem seems to come specifically from
preprocess_mean
trying to return aVector{Int}
whenX
contains integers, while the expressionvec(mean(X, dims=2))
always returns an array of type Float64 in my computer.The text was updated successfully, but these errors were encountered: