-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from AlgebraicJulia/gatlab
Update for GATlab.jl and DataMigrations.jl
- Loading branch information
Showing
28 changed files
with
227 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name = "AlgebraicRewriting" | |
uuid = "725a01d3-f174-5bbd-84e1-b9417bad95d9" | ||
license = "MIT" | ||
authors = ["Kris Brown <[email protected]>"] | ||
version = "0.2.1" | ||
version = "0.3.0" | ||
|
||
[deps] | ||
ACSets = "227ef7b5-1206-438b-ac65-934d6da304b8" | ||
|
@@ -15,13 +15,16 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | |
|
||
[weakdeps] | ||
Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc" | ||
DataMigrations = "0c4ad18d-0c49-4bc2-90d5-5bca8f00d6ae" | ||
|
||
[extensions] | ||
AlgebraicRewritingLuxorExt = "Luxor" | ||
AlgebraicRewritingDataMigrationsExt = "DataMigrations" | ||
|
||
[compat] | ||
ACSets = "0.2.9" | ||
Catlab = "0.15.4, 0.16" | ||
Catlab = "0.16.1" | ||
DataMigrations = "0.0.2" | ||
DataStructures = "0.17, 0.18" | ||
Reexport = "^1" | ||
StructEquality = "2.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,7 @@ | ||
[deps] | ||
ACSets = "227ef7b5-1206-438b-ac65-934d6da304b8" | ||
AlgebraicPetri = "4f99eebe-17bf-4e98-b6a1-2c4f205a959b" | ||
AlgebraicRewriting = "725a01d3-f174-5bbd-84e1-b9417bad95d9" | ||
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" | ||
Catlab = "134e5e36-593f-5add-ad60-77f754baafbe" | ||
DataMigrations = "0c4ad18d-0c49-4bc2-90d5-5bca8f00d6ae" | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326" | ||
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589" | ||
Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc" | ||
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" | ||
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" | ||
StructEquality = "6ec83bb0-ed9f-11e9-3b4c-2b04cb4e219c" | ||
|
||
[compat] | ||
ACSets = "0.2.6" | ||
Catlab = "0.15.5" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
module Migration | ||
export yoneda_cache, SchRule, SchRulel, SchRuler, SchRule, SchPBPO | ||
|
||
using Catlab | ||
using ..Utils | ||
|
||
# Rule schemas | ||
############## | ||
|
||
@present SchRule_(FreeSchema) begin | ||
L::Ob # inputs | ||
R::Ob # outputs | ||
K::Ob # keep | ||
end | ||
|
||
@present SchRulel <: SchRule_ begin | ||
l::Hom(L, K) | ||
end | ||
@present SchRuler <: SchRule_ begin | ||
r::Hom(R, K) | ||
end | ||
|
||
@present SchRule <: SchRulel begin | ||
r::Hom(R, K) | ||
end | ||
|
||
@present SchPBPO <: SchRule begin | ||
(L′, K′)::Ob | ||
tₗ::Hom(L′,L) | ||
tₖ::Hom(K′,K) | ||
l′::Hom(L′,K′) | ||
end | ||
|
||
# Caching | ||
######### | ||
|
||
function yoneda_cache(T::Type,S=nothing; clear=false, cache="cache") | ||
S = isnothing(S) ? Presentation(T) : S | ||
tname = nameof(T) |> string | ||
cache_dict = Dict{Symbol,Tuple{T,Int}}(map(generators(S, :Ob)) do ob | ||
name = nameof(ob) | ||
cache_dir = mkpath(joinpath(cache, "$tname")) | ||
path, ipath = joinpath.(cache_dir, ["$name.json", "_id_$name.json"]) | ||
name => if !clear && isfile(path) | ||
(read_json_acset(T, path), parse(Int,open(io->read(io, String), ipath))) | ||
else | ||
@debug "Computing representable $name" | ||
rep, i = representable(T, S, name; return_unit_id=true) | ||
write_json_acset(rep, path) | ||
write(ipath, string(i)) | ||
(rep, i) | ||
end | ||
end) | ||
return yoneda(T; cache=cache_dict) | ||
end | ||
|
||
end # module |
Oops, something went wrong.