I am extending a current framework (Persa), and adding some new functionality. As a matter of fact, i need to use the same types to benefit from the framework.
This is my current structure:
struct ContextRating{T <: Number} <: Persa.AbstractRating{T}
value::T
context::Dict{Symbol,Any}
ContextRating(x::T, preference::Persa.Preference{T}, context::Dict{Symbol,Any}) where T <: Number = new{T}(Persa.correct(x, preference), context)
end
struct DatasetContext{T <: Number} <: Persa.AbstractDataset{T}
ratings::SparseMatrixCSC{Persa.AbstractRating{T}, Int}
preference::Persa.Preference{T}
users::Int
items::Int
metaContext::Dict{Symbol,DataType}
end
Relevant Persa Structures:
abstract type AbstractDataset{T <: Number}
end
abstract type AbstractRating{T <: Number}
end
struct Dataset{T <: Number} <: AbstractDataset{T}
ratings::SparseMatrixCSC{AbstractRating{T}, Int}
preference::Preference{T}
users::Int
items::Int
end
The problem is i cant convert
Array{ContextCF.ContextRating{Int64},1}
to:
Array{Persa.AbstractRating{Int64},1}
The log of the error:
ERROR: LoadError: MethodError: no method matching ContextCF.DatasetContext(::SparseArrays.SparseMatrixCSC{ContextCF.ContextRating{Int64},Int64}, ::Persa.Preference{Int64}, ::Int64, ::Int64, ::Dict{Symbol,DataType})
Closest candidates are:
ContextCF.DatasetContext(::SparseArrays.SparseMatrixCSC{Persa.AbstractRating{T<:Number},Int64}, ::Persa.Preference{T<:Number}, ::Int64, ::Int64, ::Dict{Symbol,DataType}) where T<:Number at /Users/Equipe/.julia/dev/ContextCF/src/dataset.jl:2
Stacktrace:
[1] ContextCF.DatasetContext(::DataFrames.DataFrame, ::Persa.Dataset{Int64}, ::Dict{Symbol,DataType}) at /Users/Equipe/.julia/dev/ContextCF/src/dataset.jl:70
[2] ContextCF.DatasetContext(::DataFrames.DataFrame, ::Dict{Symbol,DataType}) at /Users/Equipe/.julia/dev/ContextCF/src/dataset.jl:21
[3] ContextCF.DatasetContext(::DataFrames.DataFrame) at /Users/Equipe/.julia/dev/ContextCF/src/dataset.jl:18
[4] top-level scope at none:0
[5] include_string(::Module, ::String, ::String) at ./loading.jl:1005
[6] (::getfield(Atom, Symbol("##129#135")){String,String,Module})() at /Users/Equipe/.julia/packages/Atom/7rQ1O/src/eval.jl:125
[7] withpath(::getfield(Atom, Symbol("##129#135")){String,String,Module}, ::String) at /Users/Equipe/.julia/packages/CodeTools/hB4Hy/src/utils.jl:30
[8] withpath at /Users/Equipe/.julia/packages/Atom/7rQ1O/src/eval.jl:46 [inlined]
[9] #128 at /Users/Equipe/.julia/packages/Atom/7rQ1O/src/eval.jl:122 [inlined]
[10] with_logstate(::getfield(Atom, Symbol("##128#134")){String,String,Module}, ::Base.CoreLogging.LogState) at ./logging.jl:397
[11] with_logger at ./logging.jl:493 [inlined]
[12] #127 at /Users/Equipe/.julia/packages/Atom/7rQ1O/src/eval.jl:121 [inlined]
[13] hideprompt(::getfield(Atom, Symbol("##127#133")){String,String,Module}) at /Users/Equipe/.julia/packages/Atom/7rQ1O/src/repl.jl:85
[14] macro expansion at /Users/Equipe/.julia/packages/Atom/7rQ1O/src/eval.jl:120 [inlined]
[15] (::getfield(Atom, Symbol("##126#132")){Dict{String,Any}})() at ./task.jl:85
in expression starting at /Users/Equipe/playground.jl/src/playground.jl.jl:8```
Even though they come from the same type. Is there a way to solve this?