dither 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/dither.gemspec +9 -1
- data/lib/dither/ipog_helper.rb +2 -1
- data/lib/dither/java_ext/dither.rb +29 -0
- data/lib/dither/version.rb +1 -1
- data/lib/dither.rb +7 -0
- data/spec/dither/dither_spec.rb +8 -8
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 271a9f006b9084c1217f28558119aec7a8d0f412
|
4
|
+
data.tar.gz: 40f2427cfda6ba58f77f92f5fcab155a84dcf9a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5629757b14b9431935a9dc8042e5703e16ae5fd0c90eacfa49ffd3ff5c97ce66f06f42ab14dd4b095ec9a4463a8940e34018131d78f2a9dc76f81ff9774373a
|
7
|
+
data.tar.gz: 59087c6e94f32b69dff2c9efd13763548e6ff8c8cb37fe83d26ba8c620bd08ad13fd8a31db6b5a480e7745c3f02ca1fe139421e5817ab53fc3a01b2a360bd1a0
|
data/README.md
CHANGED
data/dither.gemspec
CHANGED
@@ -18,7 +18,15 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_development_dependency "rake", "~> 0.9.2"
|
19
19
|
s.add_development_dependency "coveralls"
|
20
20
|
|
21
|
-
|
21
|
+
files = `git ls-files`.split("\n")
|
22
|
+
|
23
|
+
if RUBY_PLATFORM =~ /java/
|
24
|
+
s.platform = "java"
|
25
|
+
# compile dither-java on jdk 7
|
26
|
+
files << "lib/dither.jar"
|
27
|
+
end
|
28
|
+
s.files = files
|
29
|
+
|
22
30
|
s.test_files = `git ls-files -- {test,spec}/*`.split("\n")
|
23
31
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
32
|
s.require_paths = ["lib"]
|
data/lib/dither/ipog_helper.rb
CHANGED
@@ -64,8 +64,8 @@ module Dither
|
|
64
64
|
test_case.delete(current_param)
|
65
65
|
end
|
66
66
|
|
67
|
-
test_case << params[i][current_max_j]
|
68
67
|
return nil if violates_constraints?(test_case)
|
68
|
+
test_case << params[i][current_max_j]
|
69
69
|
|
70
70
|
current_matches
|
71
71
|
end
|
@@ -127,6 +127,7 @@ module Dither
|
|
127
127
|
next
|
128
128
|
else
|
129
129
|
arr[i] = orig_param[j]
|
130
|
+
break
|
130
131
|
end
|
131
132
|
end
|
132
133
|
return nil if arr[i].nil?
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
module Dither
|
3
|
+
|
4
|
+
def self.all_pairs(params, t = 2, opts = {})
|
5
|
+
constraints = constraints_to_java(params.length, opts[:constraints])
|
6
|
+
com.github.jesg.dither.Dither.ipog(
|
7
|
+
t.to_java(:int),
|
8
|
+
params.map(&:to_java).to_java,
|
9
|
+
constraints).to_a
|
10
|
+
rescue com.github.jesg.dither.DitherError => e
|
11
|
+
raise Dither::Error.new(e.message)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def self.constraints_to_java(param_length, constraints)
|
17
|
+
return [].to_java if constraints.nil?
|
18
|
+
result = []
|
19
|
+
constraints.each do |constraint|
|
20
|
+
new_constraint = Array.new(param_length)
|
21
|
+
constraint.each do |k, v|
|
22
|
+
new_constraint[k] = v
|
23
|
+
puts "#{k} => #{v}"
|
24
|
+
end
|
25
|
+
result << new_constraint
|
26
|
+
end
|
27
|
+
result.map { |a| a.to_java(java.lang.Integer) }.to_java
|
28
|
+
end
|
29
|
+
end
|
data/lib/dither/version.rb
CHANGED
data/lib/dither.rb
CHANGED
data/spec/dither/dither_spec.rb
CHANGED
@@ -54,7 +54,7 @@ describe Dither do
|
|
54
54
|
|
55
55
|
it 'can compute 2-way mipog using symbols' do
|
56
56
|
params = [[:a, :b, :c], [:d, :e, :f], [:h, :i]]
|
57
|
-
expect(Dither.mipog(params)).to eq([[:a, :d, :h],
|
57
|
+
expect(Dither.mipog(params).to_set).to eq([[:a, :d, :h],
|
58
58
|
[:a, :e, :i],
|
59
59
|
[:a, :f, :h],
|
60
60
|
[:b, :d, :i],
|
@@ -62,7 +62,7 @@ describe Dither do
|
|
62
62
|
[:b, :f, :i],
|
63
63
|
[:c, :d, :h],
|
64
64
|
[:c, :e, :i],
|
65
|
-
[:c, :f, :h]])
|
65
|
+
[:c, :f, :h]].to_set)
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'can compute 2-way mipog' do
|
@@ -95,7 +95,7 @@ describe Dither do
|
|
95
95
|
|
96
96
|
it 'can compute 3-way ipog' do
|
97
97
|
params = [(0...2).to_a, (0...2).to_a, (0..3).to_a]
|
98
|
-
expect(Dither.all_pairs(params, 3)).to eq([[0, 0, 0],
|
98
|
+
expect(Dither.all_pairs(params, 3).to_set).to eq([[0, 0, 0],
|
99
99
|
[1, 0, 0],
|
100
100
|
[0, 1, 0],
|
101
101
|
[1, 1, 0],
|
@@ -111,7 +111,7 @@ describe Dither do
|
|
111
111
|
[1, 0, 3],
|
112
112
|
[0, 1, 3],
|
113
113
|
[1, 1, 3],
|
114
|
-
])
|
114
|
+
].to_set)
|
115
115
|
end
|
116
116
|
|
117
117
|
it 'can compute 3-way ipog with constraints' do
|
@@ -123,7 +123,7 @@ describe Dither do
|
|
123
123
|
{0 => 0,
|
124
124
|
1 => 1,
|
125
125
|
2 => 0}
|
126
|
-
])).to eq([[0, 0, 0],
|
126
|
+
]).to_set).to eq([[0, 0, 0],
|
127
127
|
[1, 0, 0],
|
128
128
|
[1, 1, 0],
|
129
129
|
[0, 0, 1],
|
@@ -136,7 +136,7 @@ describe Dither do
|
|
136
136
|
[1, 0, 3],
|
137
137
|
[0, 1, 3],
|
138
138
|
[1, 1, 3],
|
139
|
-
])
|
139
|
+
].to_set)
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'another 3-way ipog with constraints' do
|
@@ -146,7 +146,7 @@ describe Dither do
|
|
146
146
|
{0 => 0,
|
147
147
|
1 => 1,
|
148
148
|
2 => 0}
|
149
|
-
])).to eq([[0, 0, 0, 0],
|
149
|
+
]).to_set).to eq([[0, 0, 0, 0],
|
150
150
|
[1, 1, 0, 0],
|
151
151
|
[1, 0, 1, 0],
|
152
152
|
[0, 1, 1, 0],
|
@@ -163,7 +163,7 @@ describe Dither do
|
|
163
163
|
[1, 0, 1, 3],
|
164
164
|
[0, 1, 1, 3],
|
165
165
|
[0, 0, 0, 1],
|
166
|
-
[0, 1, 1, 1]])
|
166
|
+
[0, 1, 1, 1]].to_set)
|
167
167
|
|
168
168
|
# results = Dither.all_pairs([
|
169
169
|
# (0...10).to_a,
|
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.
|
4
|
+
version: 0.0.8
|
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-
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/dither.rb
|
72
72
|
- lib/dither/ipog.rb
|
73
73
|
- lib/dither/ipog_helper.rb
|
74
|
+
- lib/dither/java_ext/dither.rb
|
74
75
|
- lib/dither/mipog.rb
|
75
76
|
- lib/dither/param.rb
|
76
77
|
- lib/dither/test_case.rb
|