flex-cartesian 0.1.1 → 0.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.
Files changed (2) hide show
  1. checksums.yaml +4 -4
  2. metadata +50 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d73abd940b2c4356ae5f9e141d7484e4ee414d40d22221c937e7dddab22ae4f7
4
- data.tar.gz: 1db898cc1ffa469f7e24aaba7e3a1ff5d7f88cd3d413a94c94b0860524210cf1
3
+ metadata.gz: 96675f38efe3e792ac84749a93c495b5770de5b0b918331274b9f53999940a7a
4
+ data.tar.gz: 0313d03ed02f6e568a803403628fdf1dedf5af9b883575d702b15a12dbf166dd
5
5
  SHA512:
6
- metadata.gz: e7bd37da1886e40fadf6212876191e63bd900a44ec9b1243698eabe8c735fea365991e57e060926642181f3e2100707ad93de3b0b5bda1a28f9f108876d51d7a
7
- data.tar.gz: 307aafce5e79d6b14ce6bece25ed50e4156274ae1e49539621a00f2dcf227ee567fc200a945f95b906d604498bcce9981e6663b17557a71cf17cafe6382d3446
6
+ metadata.gz: 6bd8c8a7dca528707bb800b7f2fed94c6fe0fbcd1fcc2e114eb00d66505f8928a0afd88e7e38794d21cbe1c2be3813d9d43d7232b3e1d37583d0d19910ff1694
7
+ data.tar.gz: 16049ce389e509ca7264ea1b5752c6bd539270d63f211cf95e08a386bf9a3f6d67ba5615cb6fc4efca9033a01a70b1bd631b083f2f2ad6614f29850d2fe68ea7
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: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Rassokhin
@@ -66,9 +66,55 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Flexible and human-friendly Cartesian product enumerator for Ruby. Supports
70
- dimension-agnostic iteration, named dimensions, structured output, lazy/eager evaluation,
71
- progress bar, JSON/YAML loading, and export to Markdown/CSV.
69
+ description: |
70
+ Flexible and human-friendly Cartesian product enumerator for Ruby.
71
+ Supports dimension-agnostic iteration, named dimensions, structured output,
72
+ lazy/eager evaluation, progress bar, JSON/YAML loading, and export to Markdown/CSV.
73
+
74
+ Example:
75
+
76
+ require 'flex-cartesian'
77
+
78
+ # Define Cartesian space with named dimensions:
79
+ example = {
80
+ dim1: [1, 2],
81
+ dim2: ['x', 'y'],
82
+ dim3: [true, false]
83
+ }
84
+ s = FlexCartesian.new(example)
85
+
86
+ # Iterate over all combinations and calculate function on each combination:
87
+ s.cartesian { |v| puts "#{v.dim1}-#{v.dim2}" if v.dim3 }
88
+
89
+ # Get number of Cartesian combinations:
90
+ puts "Total size: #{s.size}"
91
+
92
+ # Convert Cartesian space to array of combinations
93
+ array = s.to_a(limit: 3)
94
+ puts array.inspect
95
+
96
+ def do_something(v)
97
+ end
98
+
99
+ # Display progress bar (useful for large Cartesian spaces)
100
+ s.progress_each { |v| do_something(v) }
101
+
102
+ # Print Cartesian space as table
103
+ s.output(align: true)
104
+
105
+ # Lazy evaluation without materializing entire Cartesian product in memory:
106
+ s.cartesian(lazy: true).take(2).each { |v| puts v.inspect }
107
+
108
+ # Load from JSON or YAML
109
+ File.write('example.json', JSON.pretty_generate(example))
110
+ s = FlexCartesian.from_json('example.json')
111
+ s.output
112
+
113
+ # Export to Markdown
114
+ s.output(format: :markdown, align: true)
115
+
116
+ # Export to CSV
117
+ s.output(format: :csv)
72
118
  email:
73
119
  - yuri.rassokhin@gmail.com
74
120
  executables: []