Skip to content

Commit

Permalink
allow partially defined metadata dictionaries in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Apr 6, 2023
1 parent 32d906f commit 63e5d06
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/AlgebraicPetri.jl
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,18 @@ function (::Type{T})(pn::AbstractPetriNet, sprops, tprops) where T <: AbstractPr
pn′
end

(::Type{T})(pn::AbstractPetriNet, sprops::AbstractDict, tprops::AbstractDict) where T <: AbstractPropertyPetriNet =
T(pn, [sprops[sname(pn, s)] for s in 1:ns(pn)], [tprops[tname(pn, t)] for t in 1:nt(pn)])
function (::Type{T})(pn::AbstractPetriNet, sprops::AbstractDict, tprops::AbstractDict) where T <: AbstractPropertyPetriNet
pn′ = T(pn)
species = Dict(sname(pn, s)=>s for s in 1:ns(pn))
for (name, prop) in sprops
set_subpart!(pn′, species[name], :sprop, prop)
end
transitions = Dict(tname(pn, t)=>t for t in 1:nt(pn))
for (name, prop) in tprops
set_subpart!(pn′, transitions[name], :tprop, prop)
end
pn′
end

""" ACSet definition for a LabelledPetriNet with properties on transitions and states.
Expand Down

2 comments on commit 63e5d06

@mehalter
Copy link
Member 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/81165

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.8.7 -m "<description of version>" 63e5d066f311a0294568ba3ee31853dfb1076c6d
git push origin v0.8.7

Please sign in to comment.