Skip to content

Commit

Permalink
Updated Petri and Catlab APIs (#252)
Browse files Browse the repository at this point in the history
* Updated Petri and Catlab APIs

* Added compat entries and version bump for final release

* Removed v1.0 test
  • Loading branch information
mehalter authored Jul 27, 2020
1 parent f772bef commit ec65e7e
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
julia-version: ['1.0', '1.3', '1.4']
julia-version: ['1.3', '1.4']
os: [ubuntu-latest]

steps:
Expand Down
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SemanticModels"
uuid = "f5ac2a72-33c7-5caf-b863-f02fefdcf428"
authors = ["James Fairbanks <[email protected]>", "Micah Halter <[email protected]>"]
version = "0.3.0"
version = "0.4.0"

[deps]
Catlab = "134e5e36-593f-5add-ad60-77f754baafbe"
Expand All @@ -10,6 +10,10 @@ MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Petri = "4259d249-1051-49fa-8328-3f8ab9391c33"

[compat]
Catlab = "^0.7.0"
LightGraphs = "^1.3.3"
MacroTools = "^0.5.5"
Petri = "^1.0.0"
julia = "1.0"

[extras]
Expand Down
2 changes: 1 addition & 1 deletion src/CategoryTheory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module CategoryTheory

using SemanticModels
import Catlab.Doctrines: dom, codom
import Catlab.Theories: dom, codom
import Base: append!, push!, deleteat!, delete!

export , AbstractMorph, FinSetMorph, dom, codom, verify, func, Decorated, decorations, undecorate, AbstractSpan, leftob, rightob, apexob, Span, left, right, DoublePushout, AbstractCospan, Cospan, pushout
Expand Down
4 changes: 2 additions & 2 deletions src/OpenPetris.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import SemanticModels.PetriModels: PetriModel
import SemanticModels.OpenModels: OpenModel
using ModelingToolkit
import ModelingToolkit: Constant
using Catlab.Doctrines
import Catlab.Doctrines: , compose, otimes
using Catlab.Theories
import Catlab.Theories: , compose, otimes

export OpenPetri, eye,

Expand Down
22 changes: 11 additions & 11 deletions src/PetriCospans.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module PetriCospans

using Catlab
using Catlab.Doctrines
using Catlab.Theories
using Catlab.WiringDiagrams
# using Catlab.Programs
import Base: (==), length, show
Expand All @@ -10,7 +10,7 @@ using ..PetriModels
using ..CategoryTheory
import ..CategoryTheory: undecorate,

import Catlab.Doctrines:
import Catlab.Theories:
Ob, Hom, dom, codom, compose, , , id, oplus, otimes, , , munit, mzero, braid,
dagger, dunit, dcounit, mcopy, Δ, delete, ◊, mmerge, ∇, create, □,
plus, zero, coplus, cozero, meet, top, join, bottom
Expand All @@ -25,11 +25,11 @@ export Epidemiology, FreeEpidemiology, spontaneous, exposure, death,
death(A)::Hom(A, munit()) A::Ob
end

spontaneous(A::Ports, B::Ports) = singleton_diagram(Epidemiology.Hom, Box(:, A, B))
exposure(A::Ports, B::Ports, C::Ports) = singleton_diagram(Epidemiology.Hom, Box(:exposure, AB, CB))
death(A::Ports) = singleton_diagram(Epidemiology.Hom, Box(:𝗫, A, Ports([])))
mcopy(A::Ports{Epidemiology.Hom}, Symbol) = implicit_mcopy(A, 2)
mmerge(A::Ports{Epidemiology.Hom}, Symbol) = implicit_mmerge(A, 2)
spontaneous(A::Ports, B::Ports) = singleton_diagram(Box(:, A, B))
exposure(A::Ports, B::Ports, C::Ports) = singleton_diagram(Box(:exposure, AB, CB))
death(A::Ports) = singleton_diagram(Box(:𝗫, A, Ports([])))
mcopy(A::Ports{Epidemiology}, Symbol) = implicit_mcopy(A, 2)
mmerge(A::Ports{Epidemiology}, Symbol) = implicit_mmerge(A, 2)


@syntax FreeEpidemiology(ObExpr, HomExpr) Epidemiology begin
Expand All @@ -41,8 +41,8 @@ mmerge(A::Ports{Epidemiology.Hom}, Symbol) = implicit_mmerge(A, 2)
copair(f::Hom, g::Hom) = (f g) (codom(f))
proj1(A::Ob, B::Ob) = id(A) (B)
proj2(A::Ob, B::Ob) = (A) id(B)
incl1(A::Ob, B::Ob) = id(A) (B)
incl2(A::Ob, B::Ob) = (A) id(B)
coproj1(A::Ob, B::Ob) = id(A) (B)
coproj2(A::Ob, B::Ob) = (A) id(B)
otimes(A::Ob, B::Ob) = associate_unit(new(A,B), munit)
otimes(f::Hom, g::Hom) = associate(new(f,g))
end
Expand Down Expand Up @@ -221,8 +221,8 @@ end
proj1(A::FinSet,B::FinSet) = otimes(id(A), delete(B))
proj2(A::FinSet,B::FinSet) = otimes(delete(A), id(B))

incl1(A::FinSet,B::FinSet) = otimes(id(A), create(B))
incl2(A::FinSet,B::FinSet) = otimes(create(A), id(B))
coproj1(A::FinSet,B::FinSet) = otimes(id(A), create(B))
coproj2(A::FinSet,B::FinSet) = otimes(create(A), id(B))

spontaneous(A::FinSet, B::FinSet) = begin
M, N = length(A), length(B)
Expand Down
4 changes: 2 additions & 2 deletions src/RelOlogModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module RelOlogModels
using Catlab
using Catlab.Syntax
using Catlab.WiringDiagrams
using Catlab.Doctrines
import Catlab.Doctrines.⊗
using Catlab.Theories
import Catlab.Theories.⊗

using SemanticModels
import SemanticModels: model
Expand Down
2 changes: 1 addition & 1 deletion src/WiringDiagrams.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module WiringDiagrams

using Catlab.WiringDiagrams
using Catlab.Doctrines
using Catlab.Theories
using Catlab.Graphics
using Catlab.Graphics.Graphviz
using MacroTools
Expand Down
6 changes: 3 additions & 3 deletions test/epidemics.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module TestEpidemics
using Catlab
using Catlab.Doctrines
using Catlab.Theories
using Catlab.Graphics
using Catlab.WiringDiagrams
using Catlab.Programs
Expand All @@ -18,7 +18,7 @@ import SemanticModels.PetriCospans: otimes_ipm, compose_pushout

println("Done Importing SemanticModels")

import Catlab.Doctrines:
import Catlab.Theories:
Ob, Hom, dom, codom, compose, , , id, oplus, otimes, , , munit, mzero, braid,
dagger, dunit, dcounit, mcopy, Δ, delete, ◊, mmerge, ∇, create, □,
plus, zero, coplus, cozero, meet, top, join, bottom
Expand Down Expand Up @@ -199,7 +199,7 @@ Pseird = PetriModel(
([3],[2]), # onset
([2],[4]), # recovery
([2],[5]), # death
], missing, missing))
]))
inputs = FinSetMorph(1:5, [1,2,3])
outputs = FinSetMorph(1:5, [1,2,3])
Fcityd = PetriCospan(Cospan(Decorated(inputs, Pseird),
Expand Down
6 changes: 3 additions & 3 deletions test/petricospans.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module TestPetriCospans

using Catlab
using Catlab.Doctrines
using Catlab.Theories
using Catlab.WiringDiagrams
using Catlab.Programs
import Base.Multimedia: display
Expand All @@ -14,7 +14,7 @@ using SemanticModels.PetriModels
using SemanticModels.PetriCospans
import SemanticModels.PetriCospans: otimes_ipm, compose_pushout

import Catlab.Doctrines:
import Catlab.Theories:
Ob, Hom, dom, codom, compose, , , id, oplus, otimes, , , munit, mzero, braid,
dagger, dunit, dcounit, mcopy, Δ, delete, ◊, mmerge, ∇, create, □,
plus, zero, coplus, cozero, meet, top, join, bottom
Expand All @@ -28,7 +28,7 @@ Cospan(f,g), Cospan(f′, g′)
pushout(Span(g,f′))


spon = PetriModel(Petri.Model([1,2], [([1], [2])], missing, missing))
spon = PetriModel(Petri.Model([1,2], [([1], [2])]))
f = Decorated(FinSetMorph(1:2, [2]), [spon])
g = Decorated(FinSetMorph(1:2, [1]), [spon])
s = Span(g,f)
Expand Down

2 comments on commit ec65e7e

@mehalter
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/18534

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.0 -m "<description of version>" ec65e7efc56ae83bbb013722af508e4d2d87683b
git push origin v0.4.0

Please sign in to comment.