Skip to content

Commit

Permalink
Merge pull request #26 from AlgebraicJulia/compat_catlab
Browse files Browse the repository at this point in the history
compat catlab 15.3
  • Loading branch information
kris-brown committed Aug 8, 2023
2 parents 73c800f + 3c934de commit 83971af
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "AlgebraicRewriting"
uuid = "725a01d3-f174-5bbd-84e1-b9417bad95d9"
license = "MIT"
authors = ["Kris Brown <kris@topos.institute>"]
version = "0.2.0"
version = "0.2.1"

[deps]
ACSets = "227ef7b5-1206-438b-ac65-934d6da304b8"
Expand All @@ -21,7 +21,7 @@ AlgebraicRewritingLuxorExt = "Luxor"

[compat]
ACSets = "0.2.3"
Catlab = "0.15.1"
Catlab = "0.15.4"
DataStructures = "0.17, 0.18"
Reexport = "^1"
StructEquality = "2.1"
Expand Down
2 changes: 2 additions & 0 deletions docs/src/lotka_volterra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ i1 = initialize(2,.5,.5)
# RULES
#######
yLV = yoneda_cache(LV; clear=true);
yLV = yoneda_cache(LV; clear=false);

# Empty agent type
I = LV()
# Generic sheep agent
Expand Down
11 changes: 6 additions & 5 deletions src/rewrite/Representable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ end
function yoneda_cache(T::Type,S=nothing; clear=false, cache="cache")
S = isnothing(S) ? Presentation(T) : S
tname = nameof(T) |> string
cache_dict = Dict(Iterators.map(generators(S, :Ob)) do ob
cache_dict = Dict{Symbol,Tuple{T,Int}}(Iterators.map(generators(S, :Ob)) do ob
name = nameof(ob)
cache_dir = mkpath(joinpath(cache, "$tname"))
path = joinpath(cache_dir, "$name.json")
path, ipath = joinpath.(cache_dir, ["$name.json", "_id_$name.json"])
name => if !clear && isfile(path)
read_json_acset(T, path)
(read_json_acset(T, path), parse(Int,open(io->read(io, String), ipath)))
else
@debug "Computing representable $name"
rep = representable(T, S, name)
rep, i = representable(T, S, name; return_unit_id=true)
write_json_acset(rep, path)
rep
write(ipath, string(i))
(rep, i)
end
end)
return yoneda(T; cache=cache_dict)
Expand Down

0 comments on commit 83971af

Please sign in to comment.