Skip to content

Commit

Permalink
Loop only through vars to infer
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeR227 committed Jun 21, 2024
1 parent a92b40e commit 5fa05a6
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/acset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,31 @@ function safe_modifytype!(d::SummationDecapode, var_idx::Int, new_type::Symbol)
return modify
end

"""
filterfor_forms(types::AbstractVector{Symbol})
Return any form type symbols.
"""
function filterfor_forms(types::AbstractVector{Symbol})
conditions = x -> x != :Literal && x != :Constant && x != :Parameter && x != :infer
filter(conditions, types)
end

# ! Warning: This is changing types to :Constant when they weren't originally.
"""
filterfor_forms(types::AbstractVector{Symbol})
Return the indices of any variables with form types.
"""
function filterfor_forms(d::SummationDecapode, type_idxs::AbstractVector{Int})
conditions = x -> d[x, :type] != :Literal &&
d[x, :type] != :Constant &&
d[x, :type] != :Parameter &&
d[x, :type] != :infer

filter(conditions, type_idxs)
end


function infer_summands_and_summations!(d::SummationDecapode)
# Note that we are not doing any type checking here for users!
# i.e. We are not checking the underlying types of Constant or Parameter
Expand All @@ -377,9 +396,9 @@ function infer_summands_and_summations!(d::SummationDecapode)
for Σ_idx in parts(d, )
summands = d[incident(d, Σ_idx, :summation), :summand]
sum = d[Σ_idx, :sum]
idxs = [summands; sum]
idxs = filterfor_forms(d, [summands; sum])

forms = unique(filterfor_forms(d[idxs, :type]))
forms = unique(d[idxs, :type])

form = @match length(forms) begin
0 => continue # We need not infer, We can not infer
Expand Down

0 comments on commit 5fa05a6

Please sign in to comment.