y_petri 2.1.49 → 2.1.50

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c5465498bf59a661b74aa844eefe5819f03e50e
4
- data.tar.gz: f10f11a40888ab580f4085a51ade994e3acb2a72
3
+ metadata.gz: 07695fc1b0877e3f17285581c526067846e37333
4
+ data.tar.gz: 7c7445c48f5803b021e7d1689f51d0eae2adfff2
5
5
  SHA512:
6
- metadata.gz: 0c4a841992fb937e28f71c27d3f83b89d97d730893935f3c3f32dc710106be7f6c0f9a7309e62ad459f39ca0596f6cd4d4a18facd7053340b4f5c6b1d1c1f6fb
7
- data.tar.gz: 47563d634cf328ce4460b1c5a3e26ced1ef8707afbaab7e884ca0948e6e86979284c1770ed2ecc8324d30519b4fda13778dac1f72ce9759b252240ea0d4a84f7
6
+ metadata.gz: 81b8ba81ab47a6782efdeef2e1add45ffebaec2112116aa3f85e0c1293b26521005ed3b7f394fb459e7a33c65172419170256da19c469a1693794a780d0e29d0
7
+ data.tar.gz: 79a23f7e0c5e6fe82c24b037a3d3f8b44fb26ed03c55fb6d678b0b52c3977c3e65227a3be8679d4556bb5013575886eeaacb9fd08ff56f21863bc8ce07d27c8d
@@ -21,9 +21,11 @@ module YPetri::Transition::ConstructionConvenience
21
21
  :downstream,
22
22
  :downstream_arcs, :downstream_places,
23
23
  :action_arcs ]
24
- nn.may_have :rate, syn!: [ :rate_closure, :propensity,
24
+ nn.may_have :rate, syn!: [ :rate_closure,
25
+ :propensity,
25
26
  :propensity_closure ]
26
27
  nn.may_have :action, syn!: :action_closure
28
+ nn.may_have :assignment, syn!: :assignment_closure
27
29
  nn.may_have :stoichiometry, syn!: [ :stoichio, :s ]
28
30
  nn.may_have :domain_guard
29
31
  nn.may_have :codomain_guard
@@ -34,6 +36,9 @@ module YPetri::Transition::ConstructionConvenience
34
36
  # If stoichiometry was given, the transition is stoichiometric:
35
37
  @stoichiometric = nn.has? :stoichiometry
36
38
 
39
+ # If the assignment closure was given, the transition is of A type:
40
+ @assignment_action = __assignment_action__( **nn )
41
+
37
42
  # Downstream description involves the codomain, and the stochiometry
38
43
  # (for stoichiometric transitions only):
39
44
  if stoichiometric? then
@@ -52,12 +57,13 @@ module YPetri::Transition::ConstructionConvenience
52
57
  if timed? then
53
58
  @domain, @rate_closure, @functional = __upstream_for_T__( **nn )
54
59
  else
55
- @domain, @action_closure, @functional = __upstream_for_t__( **nn )
60
+ if assignment_action? then
61
+ @domain, @action_closure, @functional = __upstream_for_A__( **nn )
62
+ else
63
+ @domain, @action_closure, @functional = __upstream_for_t__( **nn )
64
+ end
56
65
  end
57
66
 
58
- # Optional assignment action:
59
- @assignment_action = __assignment_action__( **nn )
60
-
61
67
  # Optional type guards for domain / codomain:
62
68
  @domain_guard, @codomain_guard = __guards__( **nn )
63
69
  end
@@ -139,7 +145,7 @@ module YPetri::Transition::ConstructionConvenience
139
145
  funct = true # "functional?"
140
146
  # Was action given explicitly?
141
147
  if nn.has? :action then
142
- λ = nn[:action].aT_is_a Proc, "supplied action named argument"
148
+ λ = nn[:action].aT_is_a Proc, "supplied :action argument"
143
149
  # Time to worry about the domain_missing, guess the user's intention:
144
150
  if dom == :missing then
145
151
  dom = λ.arity == 0 ? [] : codomain
@@ -156,6 +162,21 @@ module YPetri::Transition::ConstructionConvenience
156
162
  end
157
163
  return dom, λ, funct
158
164
  end
165
+
166
+ # Private method, part of the init process for assignment transitions.
167
+ #
168
+ def __upstream_for_A__( **nn )
169
+ dom = domain
170
+ funct = true
171
+ λ = nn[:assignment].aT_is_a Proc, "supplied :assigmnent argument"
172
+ if dom == :missing then
173
+ dom = λ.arity == 0 ? [] : codomain
174
+ else
175
+ msg = "Assignment closure arity (#{λ.arity}) > domain (#{dom.size})!"
176
+ fail TypeError, msg if λ.arity.abs > dom.size
177
+ end
178
+ return dom, λ, funct
179
+ end
159
180
 
160
181
  # Default rate closure for SR transitions whose rate is hinted as a number.
161
182
  #
@@ -214,13 +235,16 @@ module YPetri::Transition::ConstructionConvenience
214
235
  # Private method, part of #initialize argument checking-in.
215
236
  #
216
237
  def __assignment_action__( **oo )
217
- if oo.has? :assignment_action, syn!: [ :assignment, :assign, :A ] then
238
+ if oo.has? :assignment then
218
239
  if timed? then
219
240
  false.tap do
220
- msg = "Timed transitions may not have assignment action!"
221
- raise TypeError, msg if oo[:assignment_action]
241
+ fail TypeError, "Timed transitions may not have assignment action!"
242
+ end
243
+ elsif stoichiometric? then
244
+ false.tap do
245
+ fail TypeError, "S transitions may not have assignment action!"
222
246
  end
223
- else oo[:assignment_action] end # only timeless transitions are eligible
247
+ else true end # ts transition with assignment keyword
224
248
  else false end # the default value
225
249
  end
226
250
 
@@ -1,4 +1,4 @@
1
1
  module YPetri
2
- VERSION = "2.1.49"
2
+ VERSION = "2.1.50"
3
3
  DEBUG = false
4
4
  end
data/test/net_test.rb CHANGED
@@ -47,7 +47,7 @@ describe YPetri::Net do
47
47
 
48
48
  describe "net of 3 places and no transitions" do
49
49
  before do
50
- @net = @w.Net.of @p1, @p2, @p3
50
+ @net = @w.Net.of [ @p1, @p2, @p3 ]
51
51
  end
52
52
 
53
53
  it "should expose its elements" do
@@ -25,7 +25,7 @@ describe YPetri::Simulation do
25
25
  before do
26
26
  @p = @w.Place.send :new, name: :A, default_marking: 1
27
27
  @q = @w.Place.send :new, name: :B, default_marking: 2
28
- @net = @w.Net.of @p, @q
28
+ @net = @w.Net.of [ @p, @q ]
29
29
  end
30
30
 
31
31
  it "should allow to set up a simplistic simulation instance" do
@@ -104,7 +104,7 @@ describe YPetri::Simulation do
104
104
 
105
105
  describe "ts transition" do
106
106
  before do
107
- @net = @w.Net.of @p, @q, @ts
107
+ @net = @w.Net.of [ @p, @q, @ts ]
108
108
  end
109
109
 
110
110
  describe "no clamps" do
@@ -154,7 +154,7 @@ describe YPetri::Simulation do
154
154
 
155
155
  describe "tS transition" do
156
156
  before do
157
- @net = @w.Net.of @p, @q, @tS
157
+ @net = @w.Net.of [ @p, @q, @tS ]
158
158
  end
159
159
 
160
160
  describe "no clamps" do
@@ -184,7 +184,7 @@ describe YPetri::Simulation do
184
184
 
185
185
  describe "Ts transition" do
186
186
  before do
187
- @net = @w.Net.of @p, @q, @Ts
187
+ @net = @w.Net.of [ @p, @q, @Ts ]
188
188
  end
189
189
 
190
190
  describe "no clamps" do
@@ -219,7 +219,7 @@ describe YPetri::Simulation do
219
219
 
220
220
  describe "TS transition" do
221
221
  before do
222
- @net = @w.Net.of @p, @q, @TS
222
+ @net = @w.Net.of [ @p, @q, @TS ]
223
223
  end
224
224
 
225
225
  describe "no clamps" do
@@ -305,7 +305,7 @@ describe "timed simulation" do
305
305
  self.class.class_exec { include YPetri }
306
306
  A = Place m!: 0.5
307
307
  B = Place m!: 0.5
308
- A_pump = T s: { A: -1 } do 0.005 end
308
+ A_pump = TT s: { A: -1 } do 0.005 end
309
309
  B_decay = Transition s: { B: -1 }, rate: 0.05
310
310
  run!
311
311
  end
@@ -210,7 +210,7 @@ describe "upstream and downstream reference mτs of places and transitions" do
210
210
  describe "assignment action transitions" do
211
211
  before do
212
212
  @p = @pç.send :new, default_marking: 1.0
213
- @t = @tç.send :new, codomain: @p, action: -> { 1 }, assignment_action: true
213
+ @t = @tç.send :new, codomain: @p, assignment_closure: -> { 1 }
214
214
  end
215
215
 
216
216
  it "should work" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: y_petri
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.49
4
+ version: 2.1.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - boris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-27 00:00:00.000000000 Z
11
+ date: 2013-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: y_support