dither 0.0.13 → 0.0.14

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: 9829bb305420c2e6fb9cbd6da97d6acdd2bed25f
4
- data.tar.gz: 6a8d1840275f51bc12248eeab6b1fc1b7f567373
3
+ metadata.gz: f2101991f7e2d91e73b8e8ceba02ac57bb040d02
4
+ data.tar.gz: e8db83997558c3553b76e0b7058aa95f2870553c
5
5
  SHA512:
6
- metadata.gz: 0953062cebd3d188febf90eec51f5007b64d37fb6ce37662dd0a9cde9cc41ba80457cbc9afbc3369ccfcb7ec251da6244390c2227da88bed64e7003cfed25bb3
7
- data.tar.gz: edc6ad4837848718ee1ff1f3c030aa5dcfcf08f7aeca64d25d6eb6f7734afb779b49025c6a913185d5f8516ad9667adaf3ae8652fa6a1b616c080a8602233080
6
+ metadata.gz: 200f11225a3af395164e40329b3f992833fc4da90f7357e3f2ff031bfcc95f0c9e24aa4da0181e8b702a2bba8c453c8f240474fc7e6ad61630fa33ea73aae7b3
7
+ data.tar.gz: 5f982c50511d7241f52af2c490746421024a53404ccf6f2ab2b71f8311db7556c89d3873c9a649e00611c0f84eb6e7bce94535f2a659a66ad5c07d6f7eefd2c0
data/dither.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  if RUBY_PLATFORM =~ /java/
24
24
  s.platform = "java"
25
25
  # compile dither-java on jdk 7
26
- files << "lib/dither.jar"
26
+ files << "lib/dither-0.0.3.jar"
27
27
  end
28
28
  s.files = files
29
29
 
@@ -41,22 +41,22 @@ module Dither
41
41
  end
42
42
  end
43
43
  @constraints = nil
44
- if opts[:constraints]
45
- @constraints = []
46
- opts[:constraints].each do |a|
47
- constraint = a.map { |k, v| pair_cache[k][v] }
48
- constraint.extend(Pairs)
49
- @constraints << constraint
50
- end
51
- end
44
+ if opts[:constraints]
45
+ @constraints = []
46
+ opts[:constraints].each do |a|
47
+ constraint = a.map { |k, v| pair_cache[k][v] }
48
+ constraint.extend(Pairs)
49
+ @constraints << constraint
50
+ end
51
+ end
52
52
  @comb = []
53
53
  @t = opts[:t]
54
54
  (0...params.length).to_a.combination(t).each do |a|
55
- car, *cdr = a.map { |b| pair_cache[b] }
56
- tmp = car.product(*cdr)
57
- tmp.each { |b| b.extend(Pairs) }
55
+ car, *cdr = a.map { |b| pair_cache[b] }
56
+ tmp = car.product(*cdr)
57
+ tmp.each { |b| b.extend(Pairs) }
58
58
  tmp.reject! { |b| constraints.any? { |c| c.all? { |d| b.include?(d)} } } if constraints
59
- @comb.push(*tmp)
59
+ @comb.push(*tmp)
60
60
  end
61
61
  end
62
62
 
@@ -68,14 +68,14 @@ module Dither
68
68
 
69
69
  def filter
70
70
  return unless constraints
71
- scratch.each_with_index do |e, i|
72
- scratch[i] = nil if constraints.any? { |a| a.in_test_case?(e) }
73
- end
71
+ scratch.each_with_index do |e, i|
72
+ scratch[i] = nil if constraints.any? { |a| a.in_test_case?(e) }
73
+ end
74
74
  end
75
75
 
76
76
  def best_fit
77
- max, _ = scratch.compact
78
- .map { |a| [a, comb.count { |b| b.in_test_case?(a) }] }
77
+ max, _ = scratch.compact
78
+ .map { |a| [a, comb.count { |b| b.in_test_case?(a) }] }
79
79
  .max { |a, b| a[1] <=> b[1] }
80
80
  comb.delete_if { |a| a.in_test_case?(max) }
81
81
  max
@@ -13,6 +13,19 @@ module Dither
13
13
  raise Dither::Error.new(e.message)
14
14
  end
15
15
 
16
+ def self.ateg(params, opts = {})
17
+ opts = DEFUALT_OPTS.dup.merge(opts)
18
+ constraints = constraints_to_java(params.length, opts[:constraints])
19
+ com.github.jesg.dither.Dither.ateg(
20
+ opts[:t].to_java(:int),
21
+ opts[:seed].to_java(:Integer),
22
+ params.map(&:to_java).to_java,
23
+ constraints,
24
+ (opts[:previously_tested] || []).map(&:to_java).to_java).to_a
25
+ rescue com.github.jesg.dither.DitherError => e
26
+ raise Dither::Error.new(e.message)
27
+ end
28
+
16
29
  private
17
30
 
18
31
  def self.constraints_to_java(param_length, constraints)
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Dither
3
- VERSION = '0.0.13'
3
+ VERSION = '0.0.14'
4
4
  end
data/lib/dither.rb CHANGED
@@ -44,7 +44,7 @@ require 'dither/ateg_pairwise'
44
44
 
45
45
  if RUBY_PLATFORM =~ /java/
46
46
  require 'java'
47
- require 'dither.jar'
47
+ require 'dither-0.0.3.jar'
48
48
 
49
49
  require 'dither/java_ext/dither'
50
50
  end
@@ -174,7 +174,7 @@ describe Dither do
174
174
  it 'can run 4-way ateg with seed' do
175
175
  params = [(0...2).to_a, (0...2).to_a, (0...2).to_a, (0..3).to_a]
176
176
  expect(Dither.ateg(params, :t => 4, :seed => 0, :constraints => [
177
- { 0 => 1, 1 => 1, 2 => 1, 3 => 1 },
178
- ], :previously_tested => [[1,1,1,2]]).length).to eq 30
177
+ { 0 => 1, 1 => 1, 2 => 1, 3 => 1 },
178
+ ], :previously_tested => [[1,1,1,2]]).length).to eq 30
179
179
  end
180
180
  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.13
4
+ version: 0.0.14
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-09-19 00:00:00.000000000 Z
11
+ date: 2015-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec