AlgebraicJulia / AlgebraicJulia/ACSets.jl
`copy` kwarg not being used in `incident`
- Vorherrschende Sprache
- Julia
- Sterne
- 36
- Forks
- 11
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Hi, reporting a bug here. When calling `incident` with the kwarg `copy=true`, I get a `MethodError` of the following form:
```julia
ERROR: MethodError: no method matching incident(::MyAcsetIdx, ::Int64, ::Symbol; copy::Bool)
This method may not support any kwargs.
```
It's necessary for this kwarg to work properly because naively working with the object returned from `incident` can cause the preimage cache to be silently corrupted, see the example below:
```julia
using Catlab
@present MySch(FreeSchema) begin
(A,B,C,D)::Ob
d_a::Hom(D,A)
b_d::Hom(B,D)
c_d::Hom(C,D)
end
@acset_type MyAcsetIdx(MySch, index=nameof.(generators(MySch, :Hom)))
acs_idx = @acset MyAcsetIdx begin
A=2
D=6
C=2
B=2
d_a=[1,1,1,2,2,2]
b_d=[1,4]
c_d=[2,5]
end
# this errors
# D_id = incident(acs_idx, 2, :d_a, copy=true)
D_id = incident(acs_idx, 2, :d_a) # is [4,5,6]
setdiff!(D_id, acs_idx[2, :b_d])
setdiff!(D_id, acs_idx[2, :c_d])
D_id = incident(acs_idx, 2, :d_a) # bug: is [6]
```
Peeking at the source for `incident` again, it looks like this probably only happens when using `incident` with no "chaining" or composition of homs: https://github.com/AlgebraicJulia/ACSets.jl/blob/f5f9a8337aba401c4357ad270f298d67b3e1e227/src/DenseACSets.jl#L573-L575
Would it simply be sufficient to add a version of that method with optional kwarg `copy` that deep copies the return of `preimage`?
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.