flex-cartesian 1.1 → 1.2

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
  SHA256:
3
- metadata.gz: b89541266e2ac802592bc652ddbf2edffe1aea4e47ab1d732e2623ad2cc5835b
4
- data.tar.gz: d717084b70f95af0e3f5706a426731685cc0cc7ddcba038b15b662d2d3226b3b
3
+ metadata.gz: 7ffe9aa47d7a73dc2f4ab52cc4943d3bdec7ce709a0712b7e92cc4077f785f82
4
+ data.tar.gz: d788a54aee87646c8ab77e58762068dcb4c7d644fdae027365e2ee3446399f8d
5
5
  SHA512:
6
- metadata.gz: 26b83b8486d89c151ae8fbc23b7ed9c19f5417a582fd6843b9e654264f0e1deb2615686fe6872b053252c9059a843ca416c41a97ccbc546de3da32b0228b7c61
7
- data.tar.gz: aa43ccd2936336564a8b14e70a6142167a17db9b93e646ea56445f25b477cd95c8a219fdeac383801c71ea4a07210c00fb1ecbd67d51f18e97afe7ad7b01c8da
6
+ metadata.gz: be6655fc4acce24a97f2287ee81df181c2a7426fd70b52d0ba02bae3facb80e9720dc5116a9f1dd0afdc0adf412f48b558ee2e5ef154a178a5da5b45dc5e47de
7
+ data.tar.gz: 26210fc67b053bd01946d3ce052c13fe54c035235357ddc7778af98b8487c8485af927d092944dabf92a95c91f040da51bb546617772d6aed2246fe52b079120
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2 - 2025-07-23
4
+ ## Added
5
+ - Optional progress bar to the function command :run
6
+
7
+ ## 1.1 - 2025-07=22
8
+ ### Fixed
9
+ - Dependencies
10
+
3
11
  ## 1.0 - 2025-07-14
4
12
  ### Added
5
13
  - Optional flad for hiding function from output
data/README.md CHANGED
@@ -297,7 +297,7 @@ s.func(:add, :time) { |v| v.raw_ping[/min\/avg\/max\/(?:mdev|stddev) = [^\/]+\/(
297
297
  s.func(:add, :min) { |v| v.raw_ping[/min\/avg\/max\/(?:mdev|stddev) = ([^\/]+)/, 1]&.to_f } # fetch min time from result
298
298
  s.func(:add, :loss) { |v| v.raw_ping[/(\d+(?:\.\d+)?)% packet loss/, 1]&.to_f } # fetch ping loss from result
299
299
 
300
- s.func(:run) # Sweep analysis! Benchmark all possible combinations of parameters
300
+ s.func(:run, progress: true, title: "Pinging") # Sweep analysis! Benchmark all possible combinations of parameters
301
301
 
302
302
  s.output(format: :csv, file: './result.csv') # save benchmark result as CSV
303
303
 
@@ -374,7 +374,7 @@ s.cartesian { |v| puts "#{v.dim1} - #{v.dim2}" }
374
374
 
375
375
  ### Handling Functions
376
376
  ```ruby
377
- func(command = :print, name = nil, hide: false, &block)
377
+ func(command = :print, name = nil, hide: false, progress: false, title: "calculating functions", &block)
378
378
  ```
379
379
  - `command`: symbol, one of the following
380
380
  - `:add` to add function as a virtual dimension to Cartesian space
@@ -383,6 +383,8 @@ func(command = :print, name = nil, hide: false, &block)
383
383
  - `:run` to calculate all the functions defined for Cartesian space
384
384
  - `name`: symbol, name of the virtual dimension, e.g. `:my_function`
385
385
  - `hide`: flag that hides or shows the function in .output; it is useful to hide intermediate calculations
386
+ - `progress`: show progress bar during `:run`, useful for large Cartesian space
387
+ - `title`: title of the progress bar
386
388
  - `block`: a function that receives each vector and returns a computed value
387
389
 
388
390
  Functions show up in `.output` like additional (virtual) dimensions.
@@ -59,7 +59,7 @@ class FlexCartesian
59
59
  end
60
60
  end
61
61
 
62
- def func(command = :print, name = nil, hide: false, &block)
62
+ def func(command = :print, name = nil, hide: false, progress: false, title: "calculating functions", &block)
63
63
  case command
64
64
  when :add
65
65
  raise ArgumentError, "Function name and block required for :add" unless name && block_given?
@@ -86,12 +86,26 @@ def func(command = :print, name = nil, hide: false, &block)
86
86
 
87
87
  when :run
88
88
  @function_results = {}
89
+
90
+ if progress
91
+ bar = ProgressBar.create(title: title, total: size, format: '%t [%B] %p%% %e')
92
+
93
+ cartesian do |v|
94
+ @function_results[v] ||= {}
95
+ @derived.each do |fname, block|
96
+ @function_results[v][fname] = block.call(v)
97
+ end
98
+ bar.increment if progress
99
+ end
100
+
101
+ else
89
102
  cartesian do |v|
90
103
  @function_results[v] ||= {}
91
104
  @derived.each do |fname, block|
92
105
  @function_results[v][fname] = block.call(v)
93
106
  end
94
107
  end
108
+ end
95
109
 
96
110
  else
97
111
  raise ArgumentError, "Unknown command for function: #{command.inspect}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flex-cartesian
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: '1.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Rassokhin