Skip to content

Commit

Permalink
more verbose names + comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Brown committed Jul 17, 2024
1 parent 66f1f40 commit 940ea04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/categorical_algebra/CSets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,14 @@ function coerce_components(S, components, X::ACSet{<:PT}, Y) where PT
return merge(ocomps, acomps)
end

# Enforces that function has a valid domain (but not necessarily codomain)
function coerce_component(ob::Symbol, f::FinFunction{Int,Int},
dom_size::Int, codom_size::Int; kw...)
if haskey(kw, :dom_parts)
!any(i -> f(i) == 0, kw[:dom_parts]) # check domain of mark as deleted
else
length(dom(f)) == dom_size # check domain of dense parts
end || error("Domain error in component $ob")
# length(codom(f)) == codom_size || error("Codomain error in component $ob")
return f
end

Expand All @@ -476,8 +476,8 @@ end
function coerce_attrvar_component(
ob::Symbol, f::VarFunction,::TypeSet{T},::TypeSet{T},
dom_size::Int, codom_size::Int; kw...) where {T}
# length(dom(f.fun)) == dom_size || error("Domain error in component $ob: $(dom(f.fun))!=$dom_size")
length(f.codom) == codom_size || error("Codomain error in component $ob: $(f.fun.codom)!=$codom_size")
length(f.codom) == codom_size || error(
"Codomain error in component $ob: $(f.fun.codom)!=$codom_size")
return f
end

Expand Down
9 changes: 5 additions & 4 deletions src/categorical_algebra/HomSearch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ homomorphisms exist, it is exactly as expensive.
homomorphisms(X::ACSet, Y::ACSet; alg=BacktrackingSearch(), kw...) =
homomorphisms(X, Y, alg; kw...)

"""
""" Find all homomorphisms between two attributed ``C``-sets via BackTracking Search.
take = number of homomorphisms requested (stop the search process early if this
number is reached)
max = throw an error if we take more than this many morphisms (e.g. set max=1 if
Expand Down Expand Up @@ -325,7 +326,7 @@ end

"""
Note: a successful search returns an *iterator* of solutions, rather than
a single solution. See `postprocess_res`.
a single solution. See `postprocess_search_results`.
"""
function backtracking_search(f, state::BacktrackingState, depth::Int;
random=false)
Expand All @@ -338,7 +339,7 @@ function backtracking_search(f, state::BacktrackingState, depth::Int;
state.assignment, state.type_components, state.dom, state.codom)])
else
m = Dict(k=>!isnothing(v) for (k,v) in pairs(state.inv_assignment))
return f(postprocess_res(state.dom, state.codom, state.assignment, m))
return f(postprocess_search_results(state.dom, state.codom, state.assignment, m))
end
elseif mrv == 0
# An element has no allowable assignment, so we must backtrack.
Expand Down Expand Up @@ -519,7 +520,7 @@ representables.
This function takes a result assignment from backtracking search and returns an
iterator of the implicit set of homomorphisms that it specifies.
"""
function postprocess_res(dom, codom, assgn, monic)
function postprocess_search_results(dom, codom, assgn, monic)
S = acset_schema(dom)
od = Dict{Symbol,Vector{Int}}(k=>(assgn[k]) for k in objects(S))

Expand Down

0 comments on commit 940ea04

Please sign in to comment.