AlgebraicJulia / Catlab.jl

A framework for applied category theory in the Julia language
https://www.algebraicjulia.org
MIT License
608 stars 58 forks source link

Cannot take `pullback` on acsettransformations of acsets with attributes of type `Dict` #804

Open p-stokes opened 1 year ago

p-stokes commented 1 year ago

Taking the pullback of "typed" PropertyLabelledPetriNets (i.e., ACSetTransformations of ACSets with properties) errors.

An example occurs in petrinet/scripts/julia/test2.jl of the PR at https://github.com/DARPA-ASKEM/Model-Representations/pull/27.

mehalter commented 1 year ago

Here is a much more succinct example of recreating this error:

using Catlab
# Create two property graphs
g0 = Catlab.Graphs.PropertyGraphs._PropertyGraph{String}()
add_vertex!(g0, vprops=Dict(:name=>"foo"))
add_vertex!(g0, vprops=Dict(:name=>"bar"))
add_edges!(g0, 1:2, 1:2)
g = Catlab.Graphs.PropertyGraphs._PropertyGraph{String}()
add_vertex!(g, vprops=Dict(:name=>"foobar"))
add_vertex!(g, vprops=Dict(:name=>"barfoo"))
add_vertex!(g, vprops=Dict(:name=>"oobarf"))
add_vertex!(g, vprops=Dict(:name=>"arfoob"))
add_edges!(g, [1,3], [2,4])
# Create two ACSetTransformations
ϕ = LooseACSetTransformation((V=[1,1,2,2], E=[1,2]),(Props=x->nothing,), g, g0)
ψ = LooseACSetTransformation((V=[2,2,1,1], E=[2,1]), (Props=x->nothing,),g, g0)
# Make sure both are natural
@assert is_natural(ϕ)
@assert is_natural(ψ)
# Run pullback, get error
pullback(ϕ, ψ; product_attrs=true)