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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84c66959b6921cffc06d9cac3b5bf925cff4e05d
4
- data.tar.gz: c55fe4643b714ec9fb2e5a12e088c21576cc3b9c
3
+ metadata.gz: 271a9f006b9084c1217f28558119aec7a8d0f412
4
+ data.tar.gz: 40f2427cfda6ba58f77f92f5fcab155a84dcf9a4
5
5
  SHA512:
6
- metadata.gz: d2fafce619a3975a7836d6ee89bb26c486a7de41f36a5dfc6a0b8bc249ac3995976d860591c9de024a309f741b01dd76cea24705b6bacbd6475df26f74f200ee
7
- data.tar.gz: c861ce9af750be22f8071c21d0939576b9885a3f08292375090e3c03393094b94db7cef2d1f58e9e4b0105f5a9c5166c7dd5a22b49c2f47d06efbcf14863839a
6
+ metadata.gz: d5629757b14b9431935a9dc8042e5703e16ae5fd0c90eacfa49ffd3ff5c97ce66f06f42ab14dd4b095ec9a4463a8940e34018131d78f2a9dc76f81ff9774373a
7
+ data.tar.gz: 59087c6e94f32b69dff2c9efd13763548e6ff8c8cb37fe83d26ba8c620bd08ad13fd8a31db6b5a480e7745c3f02ca1fe139421e5817ab53fc3a01b2a360bd1a0
data/README.md CHANGED
@@ -52,4 +52,6 @@ results.each { |a| puts "#{a}" }
52
52
  * Send me a pull request. Bonus points for topic branches
53
53
 
54
54
  # Copyright
55
+ includes [dither-java](https://github.com/jesg/dither-java) Apache License, Version 2.0
56
+
55
57
  Copyright (c) 2015 Jason Gowan See LICENSE for details.
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
- s.files = `git ls-files`.split("\n")
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"]
@@ -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
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Dither
3
- VERSION = '0.0.7'
3
+ VERSION = '0.0.8'
4
4
  end
data/lib/dither.rb CHANGED
@@ -21,3 +21,10 @@ require 'dither/test_case'
21
21
  require 'dither/ipog_helper'
22
22
  require 'dither/ipog'
23
23
  require 'dither/mipog'
24
+
25
+ if RUBY_PLATFORM =~ /java/
26
+ require 'java'
27
+ require 'dither.jar'
28
+
29
+ require 'dither/java_ext/dither'
30
+ end
@@ -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.7
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-05-30 00:00:00.000000000 Z
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