Skip to content

Commit

Permalink
Fix constructor of acset from FinDomFunctor in varacset case (#917)
Browse files Browse the repository at this point in the history
* Correct constructor of acset from findomfunctor for varacset case

* Added test

---------

Co-authored-by: Kevin Arlin <[email protected]>
  • Loading branch information
KevinDCarlson and Kevin Arlin authored Jun 27, 2024
1 parent 24c981e commit 91f21a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/categorical_algebra/CSets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,13 @@ function ACSetInterface.copy_parts!(X::ACSet, F::FinDomFunctor)
set_subpart!(X, dom_parts, nameof(f), codom_parts[collect(hom_map(F, f))])
end
for f in generators(pres, :Attr)
cd = nameof(codom(f))
dom_parts = added[nameof(dom(f))]
set_subpart!(X, dom_parts, nameof(f), collect(hom_map(F, f)))
F_of_f = collect(hom_map(F,f))
n_attrvars_present = nparts(X, cd)
n_attrvars_needed = maximum(map(x->x.val,filter(x->x isa AttrVar,F_of_f)),init=0)
add_parts!(X,cd,n_attrvars_needed-n_attrvars_present)
set_subpart!(X, dom_parts, nameof(f), F_of_f)
end
added
end
Expand Down
5 changes: 5 additions & 0 deletions test/categorical_algebra/CSets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ end

@test VarFunction(A,:weight) == VarFunction{Bool}([AttrVar(1), true], FinSet(2))


f = ACSetTransformation(
Dict(:V=>[1],:E=>[1,2],:Weight=>[AttrVar(2), AttrVar(1)]), A, A
)
Expand All @@ -558,6 +559,10 @@ w1,w2,w3 = ws = [WG{x}() for x in [Symbol,Bool,Int]]
rem_part!(w1, :Weight, 1)
@test [nparts(w, :Weight) for w in ws] == [1,2,2]

A′ = WG{Bool}(FinDomFunctor(A))
rem_part!(A,:Weight,2)
@test is_isomorphic(A,A′)

# Construct Tight/Loose ACSet Transformations
#--------------------------------------------
f21 = LooseVarFunction{Bool,Symbol}([AttrVar(1),AttrVar(1)], x->Symbol(x), FinSet(1))
Expand Down

0 comments on commit 91f21a9

Please sign in to comment.