Im trying to extend some functionality on the framework Persa and got stuck in conversion wich i dont know if its supposed to happen on creating my SparseMatrix. Example code:
abstract type AbstractRating{T <: Number}
end
##df is a dataframe wich is loaded previously and with no missings, the columns are of the right type as well, and consists of user, ratings and items, all of them are Int64
users = maximum(df[:user])
items = maximum(df[:item])
preference = Persa.Preference(df[:rating])
ratings = Persa.convert(df[:rating], preference)
# returns 14175-element Array{Persa.AbstractRating{Int64},1}
sparse(df[:user], df[:item], ratings, users, items)
ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type Persa.AbstractRating{Int64}
Closest candidates are:
convert(::Type{S}, ::T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R)) where {S, T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R)} at /Users/pauloxavier/.julia/packages/CategoricalArrays/rQrLR/src/value.jl:86
convert(::Type{T}, ::T) where T at essentials.jl:154
Stacktrace:
[1] setindex!(::Array{Persa.AbstractRating{Int64},1}, ::Int64, ::Int64) at ./array.jl:769
[2] sparse!(::Array{Int64,1}, ::Array{Int64,1}, ::Array{Persa.AbstractRating{Int64},1}, ::Int64, ::Int64, ::typeof(+),::Array{Int64,1}, ::Array{Int64,1}, ::Array{Int64,1}, ::Array{Persa.AbstractRating{Int64},1}, ::Array{Int64,1}, ::Array{Int64,1}, ::Array{Persa.AbstractRating{Int64},1}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/SparseArrays/src/sparsematrix.jl:692
[3] sparse(::Array{Int64,1}, ::Array{Int64,1}, ::Array{Persa.AbstractRating{Int64},1}, ::Int64, ::Int64, ::Function) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/SparseArrays/src/sparsematrix.jl:570
[4] sparse(::Array{Int64,1}, ::Array{Int64,1}, ::Array{Persa.AbstractRating{Int64},1}, ::Int64, ::Int64) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/SparseArrays/src/sparsematrix.jl:754
[5] top-level scope at none:0
When i try to build the sparse array, i get this conversion error. I want an Array{Persa.AbstractRating{Int64},1}
.
As a matter of fact, this structure is the step by step used by Persa, wich pass the exact same parameters and datatypes.