Skip to content

Commit

Permalink
Revert "clear parts before assigning in case of injective cache"
Browse files Browse the repository at this point in the history
This reverts commit f1c5dee.
  • Loading branch information
slwu89 committed Sep 30, 2023
1 parent 80a4d68 commit e4fbb26
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 20 deletions.
4 changes: 0 additions & 4 deletions src/ACSetInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ using Tables
using PrettyTables: pretty_table

using ..ColumnImplementations: AttrVar
using ..PreimageCaches: is_injective

using ..Schemas: types, attrs, attrtypes

Expand Down Expand Up @@ -251,9 +250,6 @@ function set_subpart! end
# Inlined for the same reason as `subpart`.

@inline function set_subpart!(acs::ACSet , parts::Union{AbstractVector{Int}, AbstractSet{Int}}, name, vals)
if is_injective(acs.subparts[name])
clear_subpart!(acs, parts, name)
end
broadcast(parts, vals) do part, val
set_subpart!(acs, part, name, val)
end
Expand Down
4 changes: 1 addition & 3 deletions src/Columns.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using Reexport
@reexport using ..PreimageCaches

import ..Mappings: view_with_default
import ..PreimageCaches: preimage, preimage_multi, is_injective
import ..PreimageCaches: preimage, preimage_multi

# Columns
#########
Expand Down Expand Up @@ -94,6 +94,4 @@ view_with_default(c::Column, xs, def) = ColumnView(c, xs, def)

Base.size(c::ColumnView) = size(c.indices)

is_injective(c::Column) = is_injective(c.pc)

end
11 changes: 0 additions & 11 deletions src/PreimageCaches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ performance implications.
- [`preimage`](@ref)
- [`assign!`](@ref)
- [`unassign!`](@ref)
- [`is_injective`](@ref) (defaults to false if not implemented)
"""
abstract type PreimageCache{S,T} end

Expand Down Expand Up @@ -95,14 +94,6 @@ Remove `x` from the preimage of `y`.
"""
function unassign! end

"""
Whether or not the cache imposes an injectivity constraint. (default: false)
"""
is_injective(::PreimageCache)::Bool = false

# Caches
########

"""
The trivial preimage mapping. It just computes preimages on the fly, and the
operations for updating it are noops
Expand Down Expand Up @@ -212,6 +203,4 @@ function unassign!(pc::InjectiveCache{S,T}, y::T, x::S) where {S,T}
delete!(pc.inverse, y)
end

is_injective(::InjectiveCache)::Bool = true

end
2 changes: 0 additions & 2 deletions test/ACSets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,6 @@ for lset_maker in lset_makers
@test isempty(incident(lset, :foo, :label))

@test_throws Exception set_subpart!(lset, 1, :label, :bar)
set_subpart!(lset, :, :label, [:bar, :foo])
@test subpart(lset, :, :label) == [:bar, :foo]
end

SchDecGraph = BasicSchema([:E,:V], [(:src,:E,:V),(:tgt,:E,:V)],
Expand Down

0 comments on commit e4fbb26

Please sign in to comment.