Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

join does not work for subobjects using ACSetTransformation #938

Open
slwu89 opened this issue Sep 14, 2024 · 0 comments
Open

join does not work for subobjects using ACSetTransformation #938

slwu89 opened this issue Sep 14, 2024 · 0 comments

Comments

@slwu89
Copy link
Member

slwu89 commented Sep 14, 2024

Based on the zulip discussion, on Catlab v0.16.17. Using join on a vector of subobjects does not work. Interestingly as well, join(subobjs) and join(subobjs, SubOpBoolean()) for some reason still dispatch to the Base.join that turns them into a string. Only join(subobjs, SubOpWithLimits()) dispatches correctly to the method defined in Catlab. The naive method of union-ing together the components of the subobjects of interest works.

using Catlab, StatsBase

@present SchMyGraph <: SchGraph begin
    (EAttr,VAttr)::AttrType
    vattr::Attr(V,VAttr)
    eattr::Attr(E,EAttr)
end

@acset_type MyGraph(SchMyGraph, index=[:src,:tgt]) <: AbstractGraph

mygraph = erdos_renyi(MyGraph{Float64,String}, 70, 0.15)

# to_graphviz(mygraph, prog="fdp")

mygraph[:, :vattr] = "v" .* string.(parts(mygraph, :V))
mygraph[:, :eattr] = rand(nparts(mygraph, :E))

# make many subobjects
subobjs = [
    let 
        v1, v2 = sample(parts(mygraph, :V), 2, replace=false)
        edg = edges(mygraph, v1, v2)
        Subobject(mygraph, (V=[v1,v2], E=collect(edg)))
    end
    for _ in 1:20
]

# do not work
join(subobjs)
join(subobjs, SubOpWithLimits())
join(subobjs, SubOpBoolean())

# works
glued_subobj = Subobject(
    mygraph,
    (
        V=unique(vcat(collect.(getindex.(components.(subobjs), :V))...)),
        E=unique(vcat(collect.(getindex.(components.(subobjs), :E))...))
    )
)

dom(hom(glued_subobj))

# to_graphviz(glued_subobj, prog="fdp")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants