Skip to content

Commit

Permalink
clean up code, tests, remove temp file
Browse files Browse the repository at this point in the history
  • Loading branch information
slwu89 committed Sep 30, 2023
1 parent e4fbb26 commit bac94a0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 100 deletions.
7 changes: 2 additions & 5 deletions src/DenseACSets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,10 @@ ACSetInterface.rem_part!(acs::DynamicACSet, type::Symbol, part::Int) =
end

@ct_ctrl for f in [out_homs; out_attrs]
# clean up with rather messy logic somehow, too many branches
if haskey(acs.subparts[@ct f], last_part)
if haskey(acs.subparts[@ct f], last_part) && part != last_part
last_part_f = subpart(acs, last_part, @ct f)
clear_subpart!(acs, last_part, @ct f)
if part != last_part
set_subpart!(acs, part, (@ct f), last_part_f)
end
set_subpart!(acs, part, (@ct f), last_part_f)
else
clear_subpart!(acs, last_part, @ct f)
end
Expand Down
28 changes: 28 additions & 0 deletions test/ACSets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -628,4 +628,32 @@ map_noidx = cascading_rem_parts!(datanoidx, :Node, 1)
@test incident(datainj, 3, :src) == []
@test incident(datainj, 3, :tgt) == []

# attributes and an injective index
RecAttrSch = BasicSchema(
[:Thing,:Node,:Edge], [(:src,:Edge,:Node),(:tgt,:Edge,:Node),(:thing,:Thing,:Node)],
[:Attr1,:Attr2,:Attr3],[(:attr1,:Node,:Attr1),(:attr2,:Edge,:Attr2),(:attr3,:Thing,:Attr3)]
)

@acset_type RecAttrData(RecAttrSch, index=[:src,:tgt], unique_index=[:thing])

dataattr = @acset RecAttrData{String,Symbol,Float64} begin
Thing=3
Node=3
Edge=3
thing=[1,2,3]
src=[1,1,2]
tgt=[1,2,3]
attr1=["1","2","3"]
attr2=[:a,:b,:c]
attr3=[10.0,11.0,12.0]
end

map_attr = cascading_rem_parts!(dataattr, :Node, 1)

@test map_inj == map_attr

@test all(map(x -> x subpart(dataattr,:attr1), ["2","3"]))
@test only(subpart(dataattr,:attr2)) == :c
@test all(map(x -> x subpart(dataattr,:attr3), [12.0,11.0]))

end
95 changes: 0 additions & 95 deletions tmp.jl

This file was deleted.

0 comments on commit bac94a0

Please sign in to comment.