Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: add package extension documentation #165

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
AlgebraicPetri = "4f99eebe-17bf-4e98-b6a1-2c4f205a959b"
Catalyst = "479239e8-5488-4da2-87a7-35f2df7eef83"
Catlab = "134e5e36-593f-5add-ad60-77f754baafbe"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
DisplayAs = "0b91fe84-8a4c-11e9-3e1d-67c38462b6d6"
Expand All @@ -8,6 +9,7 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
LabelledArrays = "2ee39098-c373-598a-b85f-a56591580800"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
10 changes: 9 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const generated_dir = joinpath(@__DIR__, "src", "generated")

@info "Loading AlgebraicPetri"
using AlgebraicPetri
using Catalyst
using ModelingToolkit
using OrdinaryDiffEq

const no_literate = "--no-literate" in ARGS
if !no_literate
Expand All @@ -30,11 +33,16 @@ if !no_literate
end
end
end
else
@info "Literate.jl: skipped"
end

extensions = ["Catalyst", "ModelingToolkit", "OrdinaryDiffEq"]
extension_modules = [Base.get_extension(AlgebraicPetri, Symbol("AlgebraicPetri"*ext*"Ext")) for ext in extensions]

@info "Building Documenter.jl docs"
makedocs(
modules = [AlgebraicPetri],
modules = vcat([AlgebraicPetri], extension_modules),
format = Documenter.HTML(
assets = ["assets/analytics.js"],
),
Expand Down
54 changes: 53 additions & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,57 @@
# Library Reference

## `AlgebraicPetri`

```@autodocs
Modules = [AlgebraicPetri]
```

## `AlgebraicPetri.BilayerNetworks`

```@autodocs
Modules = [AlgebraicPetri.BilayerNetworks]
```

## `AlgebraicPetri.Epidemiology`

```@autodocs
Modules = [AlgebraicPetri.Epidemiology]
```

## `AlgebraicPetri.ModelComparison`

```@autodocs
Modules = [AlgebraicPetri, AlgebraicPetri.Epidemiology, AlgebraicPetri.OpenTransitions]
Modules = [AlgebraicPetri.ModelComparison]
```

## `AlgebraicPetri.OpenTransitions`

```@autodocs
Modules = [AlgebraicPetri.OpenTransitions]
```

## `AlgebraicPetri.TypedPetri`

```@autodocs
Modules = [AlgebraicPetri.TypedPetri]
```

## Package Extensions

### [Catalyst.jl](https://github.com/SciML/Catalyst.jl)

```@docs
Catalyst.ReactionSystem
```

### [ModelngToolkit.jl](https://github.com/SciML/ModelingToolkit.jl)

```@docs
ModelingToolkit.ODESystem
```

### [OrdinaryDiffEq.jl](https://github.com/SciML/OrdinaryDiffEq.jl)

```@docs
OrdinaryDiffEq.ODEProblem
```
3 changes: 2 additions & 1 deletion ext/AlgebraicPetriCatalystExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import Catalyst: ReactionSystem

counter(a) = [count(==(i),a) for i in unique(a)]

""" Convert a general PetriNet to a ReactionSystem
""" ReactionSystem(pn::AbstractPetriNet)

Convert a general PetriNet to a ReactionSystem
This conversion forgets any labels or rates provided, and converts all
parameters and variables into symbols. It does preserve the ordering of
transitions and states though (Transition 1 has a rate of k[1], state 1 has a
Expand Down
5 changes: 4 additions & 1 deletion ext/AlgebraicPetriModelingToolkitExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ using ModelingToolkit
import ModelingToolkit: ODESystem


""" Convert a general PetriNet to an ODESystem
"""
ODESystem(p::AbstractPetriNet; name=:PetriNet, kws...)

Convert a general PetriNet to an ODESystem
This conversion forgets any labels or rates provided, and converts all
parameters and variables into symbols. It does preserve the ordering of
transitions and states though (Transition 1 has a rate of k[1], state 1 has a
Expand Down
12 changes: 12 additions & 0 deletions ext/AlgebraicPetriOrdinaryDiffEqExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ module AlgebraicPetriOrdinaryDiffEqExt
using AlgebraicPetri
import OrdinaryDiffEq: ODEProblem

""" ODEProblem(m::AbstractPetriNet, u0, tspan, β)

Convert a general PetriNet to an ODEProblem
This takes the initial conditions and rates as parameters and will ignore
any initial conditions and rates embedded in the Petri Net if they exist.
"""
ODEProblem(m::AbstractPetriNet, u0, tspan, β) = ODEProblem(vectorfield(m), u0, tspan, β)

""" ODEProblem(m::AbstractPetriNet, tspan)

Convert a general PetriNet to an ODEProblem
This assumes the concentrations and weights are embedded in the Petri Net.
"""
ODEProblem(m::AbstractPetriNet, tspan) = ODEProblem(vectorfield(m), concentrations(m), tspan, rates(m))

end