snotskie / EpistemicNetworkAnalysis.jl

Native implementation of Epistemic Network Analysis written in the Julia programming language. Based on rENA 0.2.0.1.
https://snotskie.github.io/EpistemicNetworkAnalysis.jl/
GNU General Public License v3.0
6 stars 2 forks source link

One-convo models with convos=[] #54

Closed snotskie closed 7 months ago

snotskie commented 10 months ago

When conversations is an empty array [], the model should behind exactly as though we manually did [:All] instead, to have a model with a single large conversation

This may actually be the case as-is, but it needs to be confirmed and tweaked if needed

snotskie commented 9 months ago

staged in https://github.com/snotskie/EpistemicNetworkAnalysis.jl/commit/8011e48cb8b716ba9c2de0267e80dec29d9b2f5b

turns out, it was actually already possible, but I had to fix this infinite recursion problem:

# Wrapper constructor, accepts any type for codes etc.
function constructENA(
        ::Type{M},
        data::DataFrame,
        codes::Array{<:Any,1},
        conversations::Array{<:Any,1},
        units::Array{<:Any,1},
        rotation::AbstractENARotation;
        kwargs...
    ) where {R<:AbstractENARotation, M<:AbstractENAModel{R}}
    return constructENA(
        M,
        data,
        Symbol.(codes),
        Symbol.(conversations),
        Symbol.(units),
        rotation;
        kwargs...
    )
end

become

# Wrapper constructor, accepts any type for codes etc.
function constructENA(
        ::Type{M},
        data::DataFrame,
        codes::Array{<:Any,1},
        conversations::Array{<:Any,1},
        units::Array{<:Any,1},
        rotation::AbstractENARotation;
        kwargs...
    ) where {R<:AbstractENARotation, M<:AbstractENAModel{R}}
    return constructENA(
        M,
        data,
        convert(Array{Symbol}, Symbol.(codes)),
        convert(Array{Symbol}, Symbol.(conversations)),
        convert(Array{Symbol}, Symbol.(units)),
        rotation;
        kwargs...
    )
end

This is the method that converts whatever type you give the config arrays to Symbols. However, Symbol.([]) has type Array{Any}, so this method recurses infinitely. Also adding an explicit convert fixed the problem, and the resulting behavior for conversations=[] was exactly what we wanted