latticerb 0.3.0 → 0.4.0

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.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: latticerb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Klose
@@ -23,28 +23,50 @@ dependencies:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: '3.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rb_sys
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.9'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.9'
26
40
  description: Lattice generates deterministic pairwise/t-way covering arrays from a
27
41
  constrained schema of parameters and values. Use it as a library in test suites
28
- (RSpec, Minitest, Rails fixtures) or via the bundled `lattice` CLI. Output is row-for-row
29
- identical to the Python lattice-cli package for the same schema and seed.
42
+ (RSpec, Minitest, Rails fixtures) or via the bundled `lattice` CLI. Generation runs
43
+ in a Rust engine shared with the Python lattice-cli package, so both give identical
44
+ rows for the same schema and seed.
30
45
  email:
31
46
  - tylerklose@gmail.com
32
47
  executables:
33
48
  - lattice
34
- extensions: []
49
+ extensions:
50
+ - ext/lattice_native/extconf.rb
35
51
  extra_rdoc_files: []
36
52
  files:
53
+ - Cargo.lock
54
+ - Cargo.toml
37
55
  - LICENSE
38
56
  - README.md
39
57
  - exe/lattice
58
+ - ext/lattice_native/Cargo.toml
59
+ - ext/lattice_native/extconf.rb
60
+ - ext/lattice_native/rustfmt.toml
61
+ - ext/lattice_native/src/lib.rs
40
62
  - lib/lattice.rb
41
63
  - lib/lattice/agent.rb
42
64
  - lib/lattice/cli.rb
43
65
  - lib/lattice/constraints.rb
44
66
  - lib/lattice/formatters.rb
45
67
  - lib/lattice/ipog.rb
46
- - lib/lattice/mersenne_twister.rb
47
68
  - lib/lattice/model.rb
69
+ - lib/lattice/native.rb
48
70
  - lib/lattice/parser.rb
49
71
  - lib/lattice/resources/claude/lattice-workflow/SKILL.md
50
72
  - lib/lattice/resources/claude/lattice-workflow/references/modeling-rules.md
@@ -1,102 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Lattice
4
- # MT19937 matching CPython's `random.Random` bit-for-bit — same integer
5
- # seeding (init_by_array over 32-bit words), same 53-bit `random`, same
6
- # little-endian word order for `getrandbits` — so a given seed produces
7
- # identical covering arrays here and in the Python implementation.
8
- class MersenneTwister
9
- N = 624
10
- M = 397
11
- MATRIX_A = 0x9908b0df
12
- UPPER_MASK = 0x80000000
13
- LOWER_MASK = 0x7fffffff
14
- MASK32 = 0xffffffff
15
-
16
- def initialize(seed)
17
- seed = seed.abs
18
- key = []
19
- while seed.positive?
20
- key << (seed & MASK32)
21
- seed >>= 32
22
- end
23
- key << 0 if key.empty?
24
- init_by_array(key)
25
- end
26
-
27
- def random
28
- a = genrand_uint32 >> 5
29
- b = genrand_uint32 >> 6
30
- (a * 67_108_864.0 + b) * (1.0 / 9_007_199_254_740_992.0)
31
- end
32
-
33
- def getrandbits(bits)
34
- result = 0
35
- shift = 0
36
- while bits.positive?
37
- word = genrand_uint32
38
- word >>= (32 - bits) if bits < 32
39
- result |= word << shift
40
- shift += 32
41
- bits -= 32
42
- end
43
- result
44
- end
45
-
46
- private
47
-
48
- def init_genrand(seed)
49
- @mt = Array.new(N)
50
- @mt[0] = seed & MASK32
51
- (1...N).each do |i|
52
- @mt[i] = (1_812_433_253 * (@mt[i - 1] ^ (@mt[i - 1] >> 30)) + i) & MASK32
53
- end
54
- @mti = N
55
- end
56
-
57
- def init_by_array(key)
58
- init_genrand(19_650_218)
59
- i = 1
60
- j = 0
61
- count = [N, key.length].max
62
- while count.positive?
63
- @mt[i] = ((@mt[i] ^ ((@mt[i - 1] ^ (@mt[i - 1] >> 30)) * 1_664_525)) + key[j] + j) & MASK32
64
- i += 1
65
- j += 1
66
- if i >= N
67
- @mt[0] = @mt[N - 1]
68
- i = 1
69
- end
70
- j = 0 if j >= key.length
71
- count -= 1
72
- end
73
- count = N - 1
74
- while count.positive?
75
- @mt[i] = ((@mt[i] ^ ((@mt[i - 1] ^ (@mt[i - 1] >> 30)) * 1_566_083_941)) - i) & MASK32
76
- i += 1
77
- if i >= N
78
- @mt[0] = @mt[N - 1]
79
- i = 1
80
- end
81
- count -= 1
82
- end
83
- @mt[0] = 0x80000000
84
- end
85
-
86
- def genrand_uint32
87
- if @mti >= N
88
- (0...N).each do |kk|
89
- y = (@mt[kk] & UPPER_MASK) | (@mt[(kk + 1) % N] & LOWER_MASK)
90
- @mt[kk] = @mt[(kk + M) % N] ^ (y >> 1) ^ (y.odd? ? MATRIX_A : 0)
91
- end
92
- @mti = 0
93
- end
94
- y = @mt[@mti]
95
- @mti += 1
96
- y ^= (y >> 11)
97
- y = (y ^ ((y << 7) & 0x9d2c5680)) & MASK32
98
- y = (y ^ ((y << 15) & 0xefc60000)) & MASK32
99
- y ^ (y >> 18)
100
- end
101
- end
102
- end