y_petri 2.1.12 → 2.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 560a2b4dfb56e03a8f25838c01e90f65cf8dd32c
4
- data.tar.gz: 82ed555ff5037b6dacf58c820e7b202276933a68
3
+ metadata.gz: faa600d44898af726d1c1fa7fe8e7e1304713539
4
+ data.tar.gz: b9037c0ba92671423c1b7625b2d82a83a6411fb0
5
5
  SHA512:
6
- metadata.gz: b6e87c931b45e3e3a5dfe01ccfe35391bb83d8e3244580c32266e622281aa24d64cff7444f5966ca2a9fe98fb80a3e8f5ccb653bfb799f93c17f554fe480410d
7
- data.tar.gz: 4ce5e398fbe8e4cb580361e5ba4f0ebfb4c37e59829768cc5448026dd56aa295be119dcc86ecd5bc09f8e2f1c1c743da0d10f0a9c8a4dc99bf7b600a8db15784
6
+ metadata.gz: 6b7be8d04a04a33505f903d2b173e715621d0be2b9a0c136b22d8fccc7a47174cf5dbb09dcb1fb66f540ec600cebd95aef06d23c28fc7a043f18ebb8bf9ac3cb
7
+ data.tar.gz: e443882ed004b50a4b2e8727961a0ab0101ac9d21e29ec67a48bd8a009545f5ce08bf3878133a1c50ba04bace33fcb602ef59715847cf2610a5203cc53f6186c
@@ -213,7 +213,10 @@ class YPetri::Net::DataSet < Hash
213
213
  events = events()
214
214
  data_ss = series
215
215
  x_range = if time.nil? then
216
- "[#{events.first}:#{events.last}]"
216
+ from = events.first || 0
217
+ to = events.last && events.last > from ? events.last :
218
+ events.first + 1
219
+ "[#{from}:#{to}]"
217
220
  elsif time.is_a? Range then
218
221
  "[#{time.begin}:#{time.end}]"
219
222
  else
@@ -124,6 +124,6 @@ class YPetri::Net::State::Feature::Delta < YPetri::Net::State::Feature
124
124
  end
125
125
 
126
126
  def label
127
- "∂:#{place.name}:#{transitions.size}tt"
127
+ "Δ:#{place.name}:#{transitions.size}tt"
128
128
  end
129
129
  end # class YPetri::Net::State::Feature::Delta
@@ -57,6 +57,6 @@ class YPetri::Net::State::Feature::Firing < YPetri::Net::State::Feature
57
57
  end
58
58
 
59
59
  def label
60
- "f:#{transition.name}"
60
+ "F:#{transition.name}"
61
61
  end
62
62
  end # YPetri::Net::State::Feature::Firing
@@ -24,6 +24,7 @@ class YPetri::Net::State::Features::Record < Array
24
24
  # Outputs the record as a plain array.
25
25
  #
26
26
  def dump precision: nil
27
+ return features.map &method( :fetch ) if precision.nil?
27
28
  features.map { |f| fetch( f ).round( precision ) }
28
29
  end
29
30
 
@@ -1,4 +1,4 @@
1
- #encoding: utf-8
1
+ # encoding: utf-8
2
2
 
3
3
  # Place / transition collection mixin for parametrized classes of
4
4
  # YPetri::Simulation. Expects the module where it is included to define
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  # Basic elements of a simulation, a mixin intended for YPetri::Simulation.
4
- #
4
+ #
5
5
  class YPetri::Simulation
6
6
  class Elements < Array
7
7
  ★ Dependency
@@ -23,7 +23,7 @@ class YPetri::Simulation
23
23
  end
24
24
 
25
25
  # Creates a subset of this collection (of the same class).
26
- #
26
+ #
27
27
  def subset element_ids=nil, &block
28
28
  if block_given? then
29
29
  msg = "If block is given, arguments are not allowed!"
@@ -33,6 +33,15 @@ class YPetri::Simulation::MarkingVector
33
33
  places( ids ).names( true ) >> m( ids )
34
34
  end
35
35
  alias pn_m p_m
36
+
37
+ # Pretty prints marking of all places as hash with place names as keys.
38
+ # Takes optional list of place ids (ordered argument no. 1), and optional
39
+ # 2 named arguments (+:gap+ and +:precision+) as in
40
+ # +#pretty_print_numeric_values+.
41
+ #
42
+ def pm ids=nil, gap: 0, precision: 2
43
+ p_m( ids ).pretty_print_numeric_values gap: gap, precision: precision
44
+ end
36
45
  alias pm p_m
37
46
 
38
47
  # Modifies the marking vector. Takes one argument. If the argument is a hash
@@ -172,8 +172,7 @@ module YPetri::Simulation::Timed
172
172
  # for timed simulations.
173
173
  #
174
174
  def init_core_and_recorder_subclasses
175
- param_class( { Core: YPetri::Core::Timed,
176
- Recorder: Recorder },
175
+ param_class( { Core: YPetri::Core::Timed, Recorder: Recorder },
177
176
  with: { simulation: self } )
178
177
  end
179
178
 
@@ -4,10 +4,7 @@
4
4
  #
5
5
  class YPetri::Simulation::Transitions
6
6
  module Type_A
7
- attr_reader :assignment_closure
8
-
9
7
  def initialize
10
- @assignment_closure = to_assignment_closure
11
8
  end
12
9
 
13
10
  # Assignment closures that directly affect the marking when called.
@@ -36,5 +33,6 @@ class YPetri::Simulation::Transitions
36
33
  closures = assignment_closures
37
34
  -> { closures.each &:call }
38
35
  end
36
+ alias assignment_closure to_assignment_closure
39
37
  end # Type_A
40
38
  end # class YPetri::Simulation::Transitions
@@ -7,12 +7,6 @@ class YPetri::Simulation::Transitions
7
7
  include Type_T
8
8
  include Type_S
9
9
 
10
- # Rate vector closure accessor.
11
- #
12
- def rate_closure
13
- @rate_closure ||= to_rate_closure
14
- end
15
-
16
10
  # Rate (flux, propensity) closures.
17
11
  #
18
12
  def rate_closures
@@ -53,5 +47,6 @@ class YPetri::Simulation::Transitions
53
47
  rc = rate_closures
54
48
  -> { rc.map( &:call ).to_column_vector }
55
49
  end
50
+ alias rate_closure to_rate_closure
56
51
  end # module Type_TS
57
52
  end # class YPetri::Simulation::Transitions
@@ -7,12 +7,6 @@ class YPetri::Simulation::Transitions
7
7
  include Type_T
8
8
  include Type_s
9
9
 
10
- # gradient closure accessor.
11
- #
12
- def gradient_closure
13
- @gradient_closure ||= to_gradient_closure
14
- end
15
-
16
10
  # Member gradient closures.
17
11
  #
18
12
  def gradient_closures
@@ -56,5 +50,6 @@ class YPetri::Simulation::Transitions
56
50
  LAMBDA
57
51
  eval λ
58
52
  end
53
+ alias gradient_closure to_gradient_closure
59
54
  end # module Type_Ts
60
55
  end # class YPetri::Simulation::Transitions
@@ -7,12 +7,6 @@ class YPetri::Simulation::Transitions
7
7
  include Type_t
8
8
  include Type_S
9
9
 
10
- # firing closure accessor.
11
- #
12
- def firing_closure
13
- @firing_closure ||= to_firing_closure
14
- end
15
-
16
10
  # tS transitions have firing closures.
17
11
  #
18
12
  def firing_closures
@@ -51,5 +45,6 @@ class YPetri::Simulation::Transitions
51
45
  closures = firing_closures
52
46
  -> { closures.map( &:call ).to_column_vector }
53
47
  end
48
+ alias firing_closure to_firing_closure
54
49
  end # module Type_tS
55
50
  end # class YPetri::Simulation::Transitions
@@ -7,12 +7,6 @@ class YPetri::Simulation::Transitions
7
7
  include Type_t
8
8
  include Type_s
9
9
 
10
- # Delta closure accessor.
11
- #
12
- def delta_closure
13
- @delta_closure ||= to_delta_closure
14
- end
15
-
16
10
  # ts transitions have action closures.
17
11
  #
18
12
  def delta_closures
@@ -54,5 +48,6 @@ class YPetri::Simulation::Transitions
54
48
  LAMBDA
55
49
  eval λ
56
50
  end
51
+ alias delta_closure to_delta_closure
57
52
  end
58
53
  end # class YPetri::Simulation::Transitions
@@ -1,4 +1,4 @@
1
1
  module YPetri
2
- VERSION = "2.1.12"
2
+ VERSION = "2.1.16"
3
3
  DEBUG = false
4
4
  end
@@ -252,7 +252,6 @@ describe YPetri::Simulation do
252
252
  end
253
253
  end
254
254
 
255
-
256
255
  describe "timeless simulation" do
257
256
  before do
258
257
  self.class.class_exec { include YPetri }
@@ -299,7 +298,6 @@ describe "timeless simulation" do
299
298
  end
300
299
  end
301
300
 
302
-
303
301
  describe "timed simulation" do
304
302
  before do
305
303
  self.class.class_exec { include YPetri }
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.12
4
+ version: 2.1.16
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-12 00:00:00.000000000 Z
11
+ date: 2013-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: y_support