Skip to content

Commit

Permalink
Fix method overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
Liozou committed Jan 19, 2024
1 parent 54f8de5 commit 6a7b334
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1137,19 +1137,15 @@ end
end

function Base.get(f::Union{Function,Type}, x::TopologyResult, c::_Clustering)
if x.attributions[Int(c)] == 0
i = x.attributions[Int(c)]
if i == 0
f()
else
x.results[x.attributions[Int(c)]]
x.results[i]
end
end
Base.get(x::TopologyResult, c::_Clustering, default) = get(Returns(default), x, c)

function Base.get(x::TopologyResult, c::_Clustering, default)
i = x.attributions[Int(c)]
i == 0 && return default
return x.results[i]
end
Base.get(x::TopologyResult, c::Symbol, default) = get(x, clustering_from_symb(c), default)
function Base.getindex(x::TopologyResult, c::_Clustering)
ret = get(x, c, nothing)
Expand Down Expand Up @@ -1434,3 +1430,16 @@ function Base.parse(::Type{InterpenetratedTopologyResult}, x::AbstractString)
topo1, nfold1 = parse_nfold_topologyresult(x)
return InterpenetratedTopologyResult([(topo1, nfold1, Int[])])
end

function one_topology(x::InterpenetratedTopologyResult, c::_Clustering)
result = nothing
for topo in x
newresult = get(topo[1], c, missing)
if result !== nothing
result == newresult || return nothing
else
result = newresult
end
end
return result
end

0 comments on commit 6a7b334

Please sign in to comment.