Skip to content

Commit

Permalink
fix copy_parts! that go between dynamic and struct acsets
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Brown committed Mar 6, 2024
1 parent 65fce13 commit d0f8bfb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/DenseACSets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function DynamicACSet(X::StructACSet{S, Ts, PT}) where {S, Ts, PT}
Y = DynamicACSet(string(typeof(X).name.name), Schema(S);
type_assignment=datatypes(X), index = indices(X),
unique_index = unique_indices(X), part_type=PT)
copy_parts!(Y,X, NamedTuple(Dict(k=>parts(X,k) for k in types(S))))
copy_parts!(Y, X)
Y

Check warning on line 301 in src/DenseACSets.jl

View check run for this annotation

Codecov / codecov/patch

src/DenseACSets.jl#L301

Added line #L301 was not covered by tests
end

Expand All @@ -306,7 +306,7 @@ function StructACSet(X::DynamicACSet{PT}) where PT
S = acset_schema(X)
Y = AnonACSet(Schema(S); type_assignment=datatypes(X), index = indices(X),
unique_index = unique_indices(X), part_type=PT)
copy_parts!(Y, X, NamedTuple(Dict(k=>parts(X,k) for k in types(S))))
copy_parts!(Y, X)
Y

Check warning on line 310 in src/DenseACSets.jl

View check run for this annotation

Codecov / codecov/patch

src/DenseACSets.jl#L310

Added line #L310 was not covered by tests
end

Expand Down Expand Up @@ -753,11 +753,13 @@ end
ACSetInterface.copy_parts!(to::StructACSet{S}, from::StructACSet{S′}) where {S,S′} =
copy_parts!(to, from, common_objects(Val{S}, Val{S′}))

ACSetInterface.copy_parts!(to::DynamicACSet, from::DynamicACSet) =
copy_parts!(to, from, runtime(common_objects, to.schema, from.schema))

ACSetInterface.copy_parts!(to::SimpleACSet, from::SimpleACSet; kw...) =
copy_parts!(to, from, (;kw...))
function ACSetInterface.copy_parts!(to::SimpleACSet, from::SimpleACSet; kw...)
if isempty(kw)
copy_parts!(to, from, runtime(common_objects, acset_schema(to), acset_schema(from)))
else
copy_parts!(to, from, (;kw...))
end
end

ACSetInterface.copy_parts!(to::SimpleACSet, from::SimpleACSet, obs::Tuple) =
copy_parts!(to, from, NamedTuple{obs}((:) for ob in obs))
Expand Down
1 change: 0 additions & 1 deletion test/ACSets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,6 @@ g = @acset MadDecGraph{String} begin
end

@test g isa StructACSet
@test nparts(g, :X) == 3

dyn_g = DynamicACSet(g)

Expand Down

0 comments on commit d0f8bfb

Please sign in to comment.