y_petri 2.4.2 → 2.4.3

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: fb7a7b5033fa23e8fbdaee627d1864722a31f850
4
- data.tar.gz: b17971ab72080978c0877a281e6a22fd7dcef2df
3
+ metadata.gz: 06d8f9b1a6908fc67194dfd3191b23507f464902
4
+ data.tar.gz: 48003b2be2c2ec91037fff8da8af9105db5a2e1a
5
5
  SHA512:
6
- metadata.gz: df9453ff5bd03c744158b2d8f848c7700ea3cdc80f0c3eb6fb64c409a0436eb7bae5e7538ed86f96c3e759acd4b68c79d9b07cc0045bad0718d0ae7ea5d761ea
7
- data.tar.gz: dd0569b0b5a0b402a78b1130b7805d3d8202ccd8219ddcdb35a18c7a10f4c479d12b4e4216f1a6c8cce84ff314ce18d228ab803e2f89d785682719d517901c2e
6
+ metadata.gz: 36b5c04eba5b0890245f665d2275aa27668e8bec8080cf26b211e4b061302a7358bf7537b41d1acb9c81ea841680cb0b56075e170f79c78b34de77dbddffb88a
7
+ data.tar.gz: 7bed185007a8c5cbc55da85f8e654678a359c3f7d8157c8abe651f8d6735b1950e90e62bcbff2f1eb0323ebd747c487d7e6e4f60d7f94c0961c5eea55580a74a
data/lib/y_petri.rb CHANGED
@@ -6,10 +6,8 @@ require 'y_support/respond_to' # Symbol#~@ + RespondTo#===
6
6
  require 'y_support/name_magic' # naming by assignment & more
7
7
  require 'y_support/unicode' # ç means self.class
8
8
  require 'y_support/typing' # run-time assertions
9
- require 'y_support/try' # increased awareness in danger
10
9
  require 'y_support/core_ext' # core extensions
11
10
  require 'y_support/stdlib_ext/matrix' # matrix extensions
12
- require 'y_support/abstract_algebra' #
13
11
  require 'y_support/kde' # popup file with kioclient
14
12
 
15
13
  # ActiveSupport components:
@@ -153,7 +153,7 @@ module YPetri::Agent::PetriNetAspect
153
153
 
154
154
  # Sets the net point to a given net, or to world.Net::Top if none given.
155
155
  #
156
- def net_point_reset id=world.Net::Top
156
+ def net_point_reset id=world.Net.instance( :Top )
157
157
  @net_point = world.net( id )
158
158
  end
159
159
 
@@ -6,7 +6,7 @@ class YPetri::Place::Guard
6
6
  # Error message template.
7
7
  #
8
8
  ERRMSG = -> m, of, assert do
9
- "Marking #{m.insp}" +
9
+ "Marking #{m.y_inspect}" +
10
10
  if of then " of #{of.name || of}" else '' end +
11
11
  " #{assert}!"
12
12
  end
@@ -240,7 +240,12 @@ module YPetri::Simulation::Timed
240
240
  when Range then
241
241
  time_range = settings[:time]
242
242
  @initial_time, @target_time = time_range.begin, time_range.end
243
- @time_unit = initial_time.class.one
243
+ @time_unit = case initial_time
244
+ when Float then 1.0
245
+ when Integer then 1
246
+ else
247
+ initial_time.class.one
248
+ end
244
249
  else
245
250
  # TODO: When using simulation after some time, I found this behavior
246
251
  # surprising. I wanted to call simulation time: 100, expecting it
@@ -261,7 +266,12 @@ module YPetri::Simulation::Timed
261
266
  # users can always modify time later (simulation.time = something).
262
267
  #
263
268
  @initial_time = settings[:time]
264
- @time_unit = initial_time.class.one
269
+ @time_unit = case initial_time
270
+ when Float then 1.0
271
+ when Integer then 1
272
+ else
273
+ initial_time.class.one
274
+ end
265
275
  @target_time = time_unit * Float::INFINITY
266
276
  end
267
277
  else
@@ -269,7 +279,12 @@ module YPetri::Simulation::Timed
269
279
  msg = "The simulation is timed, but the constructor lacks any of the " +
270
280
  "time-related arguments: :time, :step, or :sampling!"
271
281
  fail ArgumentError, msg unless anything
272
- @time_unit = anything.class.one
282
+ @time_unit = case anything
283
+ when Float then 1.0
284
+ when Integer then 1
285
+ else
286
+ anything.class.one
287
+ end
273
288
  @initial_time, @target_time = time_unit * 0, time_unit * Float::INFINITY
274
289
  end
275
290
  # Set up a parametrized subclas of the sampler for timed simulation.
@@ -19,15 +19,13 @@ module YPetri::Transition::Type_A
19
19
  # Assigns the action closure result to the codomain, regardless of cocking.
20
20
  #
21
21
  def fire!
22
- consciously "to #fire!" do
23
- act = note "action", is: Array( action )
24
- msg = "Wrong output arity of the action closure of #{self}"
25
- fail TypeError, msg if act.size != codomain.size
26
- codomain.each_with_index { |p, i|
27
- note "assigning action node no. #{i} to #{p}"
28
- p.marking = note "marking to assign", is: act.fetch( i )
29
- }
30
- end
22
+ act = Array( action )
23
+ fail TypeError, "Wrong output arity of the action " +
24
+ "closure of #{self}" if act.size != codomain.size
25
+ codomain.each_with_index { |place, index|
26
+ # assigning action node no. index to place
27
+ place.marking = act.fetch( index )
28
+ }
31
29
  return nil
32
30
  end
33
31
 
@@ -25,14 +25,12 @@ module YPetri::Transition::Type_T
25
25
  # Δt as an argument.
26
26
  #
27
27
  def fire! Δt
28
- consciously "call #fire method" do
29
- act = note "action", is: Array( action Δt )
30
- msg = "Wrong output arity of the action closure of #{self}!"
31
- fail TypeError, msg if act.size != codomain.size
32
- codomain.each_with_index do |p, i|
33
- note "adding action node no. #{i} to #{p}"
34
- p.add note( "marking change", is: act.fetch( i ) )
35
- end
28
+ action = Array( action Δt )
29
+ fail TypeError, "Wrong output arity of the action " +
30
+ "closure of #{self}!" if action.size != codomain.size
31
+ codomain.each_with_index do |place, index|
32
+ # Adding action place no. index to place"
33
+ place.add action.fetch( index )
36
34
  end
37
35
  return nil
38
36
  end
@@ -24,14 +24,12 @@ module YPetri::Transition::Type_t
24
24
  # Fires the transition regardless of cocking.
25
25
  #
26
26
  def fire!
27
- consciously "call #fire method" do
28
- act = Array( action )
29
- msg = "Wrong output arity of the action closure of #{self}!"
30
- fail TypeError, msg if act.size != codomain.size
31
- codomain.each_with_index do |p, i|
32
- note "adding action node no. #{i} to #{p}"
33
- p.add note( "marking change", is: act.fetch( i ) )
34
- end
27
+ act = Array( action )
28
+ fail TypeError, "Wrong output arity of the action " +
29
+ "closure of #{self}!" if act.size != codomain.size
30
+ codomain.each_with_index do |place, index|
31
+ # adding action node no. index to place
32
+ place.add act.fetch( index )
35
33
  end
36
34
  return nil
37
35
  end
@@ -1,4 +1,4 @@
1
1
  module YPetri
2
- VERSION = "2.4.2"
2
+ VERSION = "2.4.3"
3
3
  DEBUG = false
4
4
  end
@@ -282,7 +282,7 @@ module YPetri::World::SimulationAspect
282
282
  settings.may_have :cc, syn!: :clamp_collection
283
283
  settings.may_have :imc, syn!: :initial_marking_collection
284
284
  settings.may_have :ssc, syn!: :simulation_settings_collection
285
- { net: net( settings[:net] || self.Net::Top ), # the key
285
+ { net: net( settings[:net] || self.Net.instance( :Top ) ), # the key
286
286
  cc: settings[:cc] || :Base,
287
287
  imc: settings[:imc] || :Base,
288
288
  ssc: settings[:ssc] || :Base }
data/test/agent_test.rb CHANGED
@@ -15,7 +15,7 @@ describe YPetri::Agent do
15
15
  # --- net point related assets ---
16
16
  @m.net_point_reset
17
17
  @m.net_point_reset @m.world.net( :Top )
18
- @m.net.must_equal @m.world.Net::Top
18
+ @m.net.must_equal @m.world.Net.instance( :Top )
19
19
  # --- simulation point related assets ---
20
20
  @m.simulation_point.reset
21
21
  @m.simulation.must_equal nil
data/test/net_test.rb CHANGED
@@ -89,9 +89,9 @@ describe YPetri::Net do
89
89
 
90
90
  describe "plus 1 stoichio. transition with rate" do
91
91
  before do
92
- @t1 = @w.Transition.avid( ɴ: "T1",
93
- s: { @p1 => 1, @p2 => -1, @p3 => -1 },
94
- rate: 0.01 )
92
+ @t1 = @w.Transition.new( ɴ: "T1", avid: true,
93
+ s: { @p1 => 1, @p2 => -1, @p3 => -1 },
94
+ rate: 0.01 )
95
95
  @net.include_transition @t1
96
96
  end
97
97
 
data/test/place_test.rb CHANGED
@@ -67,7 +67,7 @@ describe YPetri::Place do
67
67
  g = p.common_guard_closure
68
68
  -> { g.( 11.1 ) }.must_raise YPetri::GuardError
69
69
  begin; p.marking = -1.11; rescue YPetri::GuardError => err
70
- err.message.must_equal 'Marking -1.11:Float of P1 should not be negative!'
70
+ err.message.must_equal 'Marking Float:-1.11 of P1 should not be negative!'
71
71
  end
72
72
  end
73
73
  end
data/test/world_test.rb CHANGED
@@ -12,16 +12,18 @@ include Pyper if require 'pyper'
12
12
  describe YPetri::World do
13
13
  before do
14
14
  @w = YPetri::World.new
15
- a = @w.Place.avid( default_marking: 1.0, name: "AA" )
16
- b = @w.Place.avid( default_marking: 2.0, name: "BB" )
17
- c = @w.Place.avid( ɴ: "CC", default_marking: 3.0 )
18
- t1 = @w.Transition.avid s: { a => -1, b => -1, c => 1 },
19
- rate: 0.1,
20
- ɴ: "AA_BB_assembly"
21
- t2 = @w.Transition.avid ɴ: "AA_appearing",
22
- codomain: a,
23
- rate: -> { 0.1 },
24
- stoichiometry: 1
15
+ a = @w.Place.new( default_marking: 1.0, name: "AA", avid: true )
16
+ b = @w.Place.new( default_marking: 2.0, name: "BB", avid: true )
17
+ c = @w.Place.new( ɴ: "CC", avid: true, default_marking: 3.0 )
18
+ t1 = @w.Transition.new s: { a => -1, b => -1, c => 1 },
19
+ rate: 0.1,
20
+ ɴ: "AA_BB_assembly",
21
+ avid: true
22
+ t2 = @w.Transition.new ɴ: "AA_appearing",
23
+ avid: true,
24
+ codomain: a,
25
+ rate: -> { 0.1 },
26
+ stoichiometry: 1
25
27
  @pp, @tt = [a, b, c], [t1, t2]
26
28
  @f_name = "test_output.csv"
27
29
  @w.set_imc @pp >> @pp.map( &:default_marking )
@@ -32,7 +34,7 @@ describe YPetri::World do
32
34
  end
33
35
 
34
36
  it "should present places, transitions, nets, simulations" do
35
- assert_kind_of YPetri::Net, @w.Net::Top
37
+ assert_kind_of YPetri::Net, @w.Net.instance( :Top )
36
38
  assert_equal @pp[0], @w.place( "AA" )
37
39
  assert_equal @tt[0], @w.transition( "AA_BB_assembly" )
38
40
  assert_equal @pp, @w.places
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.4.2
4
+ version: 2.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - boris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-11 00:00:00.000000000 Z
11
+ date: 2016-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler