Skip to content

Commit

Permalink
BUILD: Compat with Catlab v0.16 and CombinatorialSpaces v0.6. (#158)
Browse files Browse the repository at this point in the history
Also, add compat entries for Julia standard libraries.
  • Loading branch information
epatters authored Oct 29, 2023
1 parent c204376 commit a7e102b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 49 deletions.
16 changes: 5 additions & 11 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
name = "Decapodes"
uuid = "679ab3ea-c928-4fe6-8d59-fd451142d391"
authors = [
"James Fairbanks",
"Andrew Baas",
"Evan Patterson",
"Luke Morris",
"George Rauta",
]
authors = ["James Fairbanks", "Andrew Baas", "Evan Patterson", "Luke Morris", "George Rauta"]
version = "0.4.0"

[deps]
AlgebraicRewriting = "725a01d3-f174-5bbd-84e1-b9417bad95d9"
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
Catlab = "134e5e36-593f-5add-ad60-77f754baafbe"
CombinatorialSpaces = "b1c52339-7909-45ad-8b6a-6e388f7c67f2"
Expand All @@ -30,21 +23,22 @@ Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[compat]
AlgebraicRewriting = "0.2"
Catlab = "0.15"
CombinatorialSpaces = "0.5"
Catlab = "0.15, 0.16"
CombinatorialSpaces = "0.5, 0.6"
DataStructures = "0.18.13"
Distributions = "0.25"
FileIO = "1.16"
GLMakie = "0.8"
GeometryBasics = "0.4.2"
JLD2 = "0.4"
JSON = "0.21"
LinearAlgebra = "1.9"
MLStyle = "0.4.17"
MultiScaleArrays = "1.10"
OrdinaryDiffEq = "6.47"
PreallocationTools = "0.4"
Requires = "1.3"
Unicode = "1.9"
julia = "1.9"

[extras]
Expand Down
5 changes: 3 additions & 2 deletions src/Decapodes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export normalize_unicode, DerivOp, append_dot, unicode!, vec_to_dec!,
AbstractMeshKey, loadmesh, Icosphere, Rectangle_30x10, Torus_30x10, Point_Map,
Open, OpenSummationDecapodeOb, OpenSummationDecapode, unique_by, unique_by!, oapply,
CartesianPoint, SpherePoint, r, theta, phi, TangentBasis, θhat, ϕhat,
average_rewrite, recursive_delete_parents, contract_operators,
#average_rewrite,
recursive_delete_parents, contract_operators,
default_dec_matrix_generate, default_dec_generate,
@decapode

Expand All @@ -38,6 +39,6 @@ include("coordinates.jl")
include("visualization.jl")
include("simulation.jl")
include("meshes.jl")
include("rewrite.jl")
#include("rewrite.jl")

end
33 changes: 33 additions & 0 deletions src/decapodeacset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,39 @@ function find_chains(d::SummationDecapode)
return chains
end

#""" function get_valid_op1s(deca_source::SummationDecapode, varID)
#Searches SummationDecapode, deca_source, at the request varID
#and returns all op1s which are allowed to be averaged. Returns
#an array of indices of valid op1 sources.
#
#Namely this is meant to exclude ∂ₜ from being included in an average.
#"""
function get_valid_op1s(deca_source::SummationDecapode, varID)
# skip_ops = Set([:∂ₜ])
indices = incident(deca_source, varID, :tgt)
return filter!(x -> deca_source[x, :op1] != :∂ₜ, indices)
end

#""" function is_tgt_of_many_ops(d::SummationDecapode, var)
#Return true if there are two or more distinct operations leading
#into Var var (not counting ∂ₜ).
#"""
function is_tgt_of_many_ops(d::SummationDecapode, var)
op1Count = length(get_valid_op1s(d, var))
op2Count = length(incident(d, var, :res))
sumCount = length(incident(d, var, :sum))

op1Count + op2Count + sumCount >= 2
end

#""" function find_tgts_of_many_ops(d::SummationDecapode)
#Searches SummationDecapode, d, for all Vars which have two or
#more distinct operations leading into the same variable.
#"""
function find_tgts_of_many_ops(d::SummationDecapode)
filter(var -> is_tgt_of_many_ops(d, var), parts(d, :Var))
end

function add_constant!(d::AbstractNamedDecapode, k::Symbol)
return add_part!(d, :Var, type=:Constant, name=k)
end
Expand Down
33 changes: 0 additions & 33 deletions src/rewrite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,6 @@ using Catlab
using AlgebraicRewriting
using AlgebraicRewriting: rewrite

#""" function get_valid_op1s(deca_source::SummationDecapode, varID)
#Searches SummationDecapode, deca_source, at the request varID
#and returns all op1s which are allowed to be averaged. Returns
#an array of indices of valid op1 sources.
#
#Namely this is meant to exclude ∂ₜ from being included in an average.
#"""
function get_valid_op1s(deca_source::SummationDecapode, varID)
# skip_ops = Set([:∂ₜ])
indices = incident(deca_source, varID, :tgt)
return filter!(x -> deca_source[x, :op1] != :∂ₜ, indices)
end

#""" function is_tgt_of_many_ops(d::SummationDecapode, var)
#Return true if there are two or more distinct operations leading
#into Var var (not counting ∂ₜ).
#"""
function is_tgt_of_many_ops(d::SummationDecapode, var)
op1Count = length(get_valid_op1s(d, var))
op2Count = length(incident(d, var, :res))
sumCount = length(incident(d, var, :sum))

op1Count + op2Count + sumCount >= 2
end

#""" function find_tgts_of_many_ops(d::SummationDecapode)
#Searches SummationDecapode, d, for all Vars which have two or
#more distinct operations leading into the same variable.
#"""
function find_tgts_of_many_ops(d::SummationDecapode)
filter(var -> is_tgt_of_many_ops(d, var), parts(d, :Var))
end

#""" function get_preprocess_indices(deca_source::SummationDecapode)
#Searches SummationDecapode, deca_source, for all Vars which are
#valid for average rewriting preprocessing. Namely this just includes
Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ end
include("multiscalearrays.jl")
end

@testset "Average Rewriting" begin
include("rewrite.jl")
end
#@testset "Average Rewriting" begin
# include("rewrite.jl")
#end

@testset "Simulation" begin
include("simulation.jl")
Expand Down

0 comments on commit a7e102b

Please sign in to comment.