dither 0.0.6 → 0.0.7

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: 1615f95c32d97e471ea43d8714dee5a9c9e4f1ad
4
- data.tar.gz: 2284c90542966f2487969b68d35c30d372493a6c
3
+ metadata.gz: 84c66959b6921cffc06d9cac3b5bf925cff4e05d
4
+ data.tar.gz: c55fe4643b714ec9fb2e5a12e088c21576cc3b9c
5
5
  SHA512:
6
- metadata.gz: 9f548f30dc8de6d28276fe42284451f01408bd1b86c4e627bd7f40651e62a2cddc872940007b840cf2653dfafeb3d92597726a587f2210e31f9be1cf7eb975d8
7
- data.tar.gz: 5c8fb0bb33f372328275e2090821ffdfa8bba20dd7c20e054ae696acecffa114fb2b3416faceeb3985c971418c3269e394ee2f56b271fcc3f660b02fb2001ee0
6
+ metadata.gz: d2fafce619a3975a7836d6ee89bb26c486a7de41f36a5dfc6a0b8bc249ac3995976d860591c9de024a309f741b01dd76cea24705b6bacbd6475df26f74f200ee
7
+ data.tar.gz: c861ce9af750be22f8071c21d0939576b9885a3f08292375090e3c03393094b94db7cef2d1f58e9e4b0105f5a9c5166c7dd5a22b49c2f47d06efbcf14863839a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dither (0.0.5)
4
+ dither (0.0.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -45,6 +45,7 @@ GEM
45
45
  tins (1.3.3)
46
46
 
47
47
  PLATFORMS
48
+ java
48
49
  ruby
49
50
 
50
51
  DEPENDENCIES
@@ -14,10 +14,10 @@ module Dither
14
14
  .map(&:to_set)
15
15
  end
16
16
 
17
- raise 't must be >= 2' if t < 2
18
- raise 't must be <= params.length' if t > params.length
17
+ raise Dither::Error, 't must be >= 2' if t < 2
18
+ raise Dither::Error, 't must be <= params.length' if t > params.length
19
19
  params.each do |param|
20
- raise 'param length must be > 1' if param.length < 2
20
+ raise Dither::Error, 'param length must be > 1' if param.length < 2
21
21
  end
22
22
  end
23
23
 
@@ -103,7 +103,7 @@ module Dither
103
103
  .map(&:flatten)
104
104
  .map { |a| TestCase.create(params, unbound_param_pool, a) }
105
105
  end
106
- result
106
+ result.to_set
107
107
  end
108
108
 
109
109
 
@@ -46,18 +46,6 @@ module Dither
46
46
  arr
47
47
  end
48
48
 
49
- def self.from_array(arr)
50
- test_case = TestCase.new
51
- arr.each_with_index do |i, e|
52
- if e.nil?
53
- test_case << unbound_param_pool[i]
54
- else
55
- test_case << bound_param_pool[i][e]
56
- end
57
- end
58
- test_case
59
- end
60
-
61
49
  # return nil if there is a conflict
62
50
  # return self if no conflict
63
51
  def merge_without_conflict(i, test_case, &block)
@@ -66,9 +54,10 @@ module Dither
66
54
  .each_with_index do |arr, a|
67
55
  first, second = arr
68
56
 
69
- next if (first == second) || second.nil?
70
57
  if first.nil? && second.nil?
71
58
  new_elements << unbound_param_pool[a]
59
+ elsif (first == second) || second.nil?
60
+ next
72
61
  elsif first.nil?
73
62
  new_elements << bound_param_pool[a][second]
74
63
  else
@@ -81,7 +70,10 @@ module Dither
81
70
 
82
71
  return nil if block_given? && block.call(new_self)
83
72
 
84
- new_elements.each { |a| self << a }
73
+ new_elements.each do |a|
74
+ self.delete(unbound_param_pool[a.i]) unless a.unbound?
75
+ self << a
76
+ end
85
77
  self
86
78
  end
87
79
  end # TestCase
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Dither
3
- VERSION = '0.0.6'
3
+ VERSION = '0.0.7'
4
4
  end
data/lib/dither.rb CHANGED
@@ -3,11 +3,14 @@ require 'set'
3
3
 
4
4
  module Dither
5
5
 
6
+ class Error < StandardError; end
7
+
6
8
  def self.all_pairs(params, t = 2, opts = {})
7
9
  IPOG.new(params, t, opts).run
8
10
  end
9
11
 
10
12
  def self.mipog(params, t = 2, opts = {})
13
+ raise Error, 'mipog does not support constraints' if opts.key?(:constraints)
11
14
  MIPOG.new(params, t, opts).run
12
15
  end
13
16
  end # Dither
@@ -2,16 +2,20 @@ require File.expand_path('../../spec_helper.rb', __FILE__)
2
2
 
3
3
  describe Dither do
4
4
 
5
+ it 'mipog does not support constraints' do
6
+ expect { Dither.mipog([[1,1],[1,2]], 2, :constraints => []) }.to raise_error(Dither::Error, 'mipog does not support constraints')
7
+ end
8
+
5
9
  it 't must be >= 2' do
6
- expect { Dither.all_pairs([], 0) }.to raise_error('t must be >= 2')
10
+ expect { Dither.all_pairs([], 0) }.to raise_error(Dither::Error, 't must be >= 2')
7
11
  end
8
12
 
9
13
  it 't must be <= params.length' do
10
- expect { Dither.all_pairs([(0...3).to_a], 4) }.to raise_error('t must be <= params.length')
14
+ expect { Dither.all_pairs([(0...3).to_a], 4) }.to raise_error(Dither::Error,'t must be <= params.length')
11
15
  end
12
16
 
13
17
  it 'param length must be > 1' do
14
- expect { Dither.all_pairs([[], []], 2) }.to raise_error('param length must be > 1')
18
+ expect { Dither.all_pairs([[], []], 2) }.to raise_error(Dither::Error,'param length must be > 1')
15
19
  end
16
20
 
17
21
  it 'can compute 2-way ipog using symbols' do
@@ -158,6 +162,61 @@ describe Dither do
158
162
  [1, 1, 0, 3],
159
163
  [1, 0, 1, 3],
160
164
  [0, 1, 1, 3],
161
- [0, 0, 0, 1]])
165
+ [0, 0, 0, 1],
166
+ [0, 1, 1, 1]])
167
+
168
+ # results = Dither.all_pairs([
169
+ # (0...10).to_a,
170
+ # (0...10).to_a,
171
+ # (0...4).to_a,
172
+ # (0...3).to_a,
173
+ # (0...3).to_a,
174
+ # (0...2).to_a,
175
+ # (0...2).to_a,
176
+ # (0...2).to_a,
177
+ # (0...2).to_a,
178
+ # (0...2).to_a,
179
+ # (0...2).to_a,
180
+ # (0...2).to_a,
181
+ # ], 4)
182
+
183
+ # results = Dither.all_pairs([
184
+ # (0...4).to_a,
185
+ # (0...4).to_a,
186
+ # (0...4).to_a,
187
+ # (0...4).to_a,
188
+ # (0...4).to_a,
189
+ # (0...3).to_a,
190
+ # (0...3).to_a,
191
+ # (0...3).to_a,
192
+ # (0...3).to_a,
193
+ # ], 2)
194
+
195
+
196
+ results = Dither.all_pairs([
197
+ (0...2).to_a, # user type
198
+ (0...2).to_a, # exists?
199
+ (0...2).to_a, # seats
200
+ (0...2).to_a, # seats
201
+ (0...3).to_a, # user region
202
+ (0...3).to_a, # currency
203
+ (0...3).to_a,
204
+ (0...4).to_a, # payment
205
+ (0...6).to_a, # delivery
206
+ (0...6).to_a,
207
+ ], 3)
208
+
209
+ # mipog 2-way 36... ipog 36
210
+ # mipog 3-way 156... ipog 151
211
+ # mipog 4-way 592... ipog 511
212
+
213
+ # results = Dither.all_pairs( [[1,2],
214
+ # ['1','2'],
215
+ # [1.0,2.0],
216
+ # [true, false, 3]],3)
217
+ require 'csv'
218
+ results.each { |a| puts a.to_csv }
219
+ puts results.count
220
+
162
221
  end
163
222
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dither
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Gowan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-24 00:00:00.000000000 Z
11
+ date: 2015-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec