morphological_metrics 1.2.0 → 1.3.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.
@@ -1,168 +1,160 @@
1
- require 'minitest/autorun'
2
-
3
- require 'mm/metric'
4
-
5
- class TestMM < Minitest::Test; end
6
-
7
- class TestMM::TestMetric < Minitest::Test
8
- def setup
9
- @ordered ||= true
10
- @pair ||= :linear
11
- @scale ||= :none
12
- @intra_delta ||= :abs
13
- @inter_delta ||= :abs
14
- @metric = MM::Metric.new(ordered: @ordered, pair: @pair, scale: @scale, intra_delta: @intra_delta, inter_delta: @inter_delta)
15
-
16
- # Setting up the sample vectors for many of the examples
17
- @v1 = [1, 6, 2, 5, 11]
18
- @v2 = [3, 15, 13, 2, 9]
19
- end
20
-
21
- def test_creates_new_metric
22
- assert @metric.is_a? MM::Metric
23
- end
24
-
25
- def test_metric_responds_to_call
26
- assert_respond_to @metric, :call
27
- end
28
-
29
- class TestGetPairs < self
30
- class TestLinearPairs < self
31
- def test_gets_linear_pairs
32
- exp = [
33
- [[1, 6], [6, 2], [2, 5], [5, 11]],
34
- [[3, 15], [15, 13], [13, 2], [2, 9]]
35
- ]
36
- assert_equal exp, @metric.send(:get_pairs, @v1, @v2)
37
- end
38
- end
39
-
40
- class TestCombinatorialPairs < self
41
- def setup
42
- @pair = :combinatorial
43
- super
44
- end
45
- def test_gets_combinatorial_pairs
46
- exp = [
47
- [[1, 6], [1, 2], [1, 5], [1, 11], [6, 2], [6, 5],
48
- [6, 11], [2, 5], [2, 11], [5, 11]],
49
- [[3, 15], [3, 13], [3, 2], [3, 9], [15, 13], [15, 2],
50
- [15, 9], [13, 2], [13, 9], [2, 9]]
51
- ]
52
- assert_equal exp, @metric.send(:get_pairs, @v1, @v2)
53
- end
54
- end
55
- end
56
-
57
- class TestDeltas < self
58
- class TestIntraDelta < self
59
- def test_gets_intra_delta
60
- pairs = [
61
- [[1, 6], [6, 2], [2, 5], [5, 11]],
62
- [[3, 15], [15, 13], [13, 2], [2, 9]]
63
- ]
64
- exp = [
65
- [5, 4, 3, 6],
66
- [12, 2, 11, 7]
67
- ]
68
- assert_equal exp, @metric.send(:intra_delta, pairs)
69
- end
70
- def test_intra_delta_proc
71
- @metric.intra_delta = ->(*vp) {nil}
72
- assert_instance_of Proc, @metric.instance_variable_get(:@intra_delta)
73
- end
74
- end
75
-
76
- class TestInterDelta < self
77
- def setup
78
- super
79
- @diffs = [
80
- [5, 4, 3, 6],
81
- [12, 2, 11, 7]
82
- ]
83
- end
84
- def test_gets_inter_delta_ordered
85
- exp = 4.5
86
- assert_equal exp, @metric.send(:inter_delta, @diffs)
87
- end
88
- def test_inter_delta_proc
89
- @metric.inter_delta = ->(*diffs) {nil}
90
- assert_instance_of Proc, @metric.instance_variable_get(:@inter_delta)
91
- end
92
- end
93
- end
94
-
95
- class TestScaling < self
96
- def setup
97
- super
98
- @unscaled = [
99
- [5, 4, 3, 6],
100
- [12, 2, 11, 7]
101
- ]
102
- end
103
-
104
- def test_assigns_scaling_proc
105
- @metric.scale = ->(pairs) {}
106
- scale = @metric.instance_variable_get :@scale
107
- assert_equal Proc, scale.class
108
- end
109
-
110
- def test_no_scaling
111
- assert_equal @unscaled, @metric.send(:scale, @unscaled)
112
- end
113
-
114
- # TODO: This is a complicated test and I don't like it
115
- def test_absolute_scaling
116
- @metric.scale = :absolute
117
- @exp = [
118
- [0.417, 0.333, 0.25, 0.5],
119
- [1.0, 0.167, 0.917, 0.583]
120
- ]
121
- actual = @metric.send :scale, @unscaled
122
- actual.each_with_index do |v, i|
123
- v.each_with_index do |w, j|
124
- assert_in_delta @exp[i][j], w, 0.001
125
- end
126
- end
127
- end
128
-
129
- def test_relative_scaling
130
- @metric.scale = :relative
131
- @exp = [
132
- [0.833, 0.667, 0.5, 1.0],
133
- [1.0, 0.167, 0.917, 0.583]
134
- ]
135
- actual = @metric.send :scale, @unscaled
136
- actual.each_with_index do |v, i|
137
- v.each_with_index do |w, j|
138
- assert_in_delta @exp[i][j], w, 0.001
139
- end
140
- end
141
- end
142
- end
143
-
144
- class TestMagnitudeMetric < self
145
- # Definitions of expected results
146
- @exp = {
147
- :olm => {:scale_none => 4.5, :scale_absolute => 0.375},
148
- :ocm => {:scale_none => 5.2, :scale_absolute => 0.4},
149
- :ulm => {:scale_none => 3.5, :scale_absolute => 0.29167},
150
- :ucm => {:scale_none => 2.4, :scale_absolute => 0.1846},
151
- :old => {:scale_none => 0.25},
152
- :ocd => {:scale_none => 0.4},
153
- :uld => {:scale_none => 0.25},
154
- :ucd => {:scale_none => 0.4}
155
- }
156
-
157
- @exp.each do |metric, expected|
158
- expected.each do |scaling, e|
159
- define_method "test_#{metric}_#{scaling}" do
160
- m = ::MM::Metric.send(metric)
161
- m.scale = /_(.*)$/.match(scaling)[1].to_sym
162
- assert_in_delta e, m.call(@v1, @v2), 0.001
163
- end
164
- end
165
- end
166
- end
167
- end
168
-
1
+ require 'minitest/autorun'
2
+
3
+ require 'mm/metric'
4
+
5
+ class TestMM < Minitest::Test; end
6
+
7
+ class TestMM::TestMetric < Minitest::Test
8
+ def setup
9
+ @ordered ||= true
10
+ @pair ||= :linear
11
+ @scale ||= :none
12
+ @intra_delta ||= :abs
13
+ @inter_delta ||= :abs
14
+ @metric = MM::Metric.new(ordered: @ordered, pair: @pair, scale: @scale, intra_delta: @intra_delta, inter_delta: @inter_delta)
15
+
16
+ # Setting up the sample vectors for many of the examples
17
+ @v1 = [1, 6, 2, 5, 11]
18
+ @v2 = [3, 15, 13, 2, 9]
19
+ end
20
+
21
+ def test_creates_new_metric
22
+ assert @metric.is_a? MM::Metric
23
+ end
24
+
25
+ def test_metric_responds_to_call
26
+ assert_respond_to @metric, :call
27
+ end
28
+
29
+ class TestGetPairs < self
30
+ class TestLinearPairs < self
31
+ def test_gets_linear_pairs
32
+ exp = [
33
+ [[1, 6], [6, 2], [2, 5], [5, 11]],
34
+ [[3, 15], [15, 13], [13, 2], [2, 9]]
35
+ ]
36
+ assert_equal exp, @metric.send(:get_pairs, @v1, @v2)
37
+ end
38
+ end
39
+
40
+ class TestCombinatorialPairs < self
41
+ def setup
42
+ @pair = :combinatorial
43
+ super
44
+ end
45
+ def test_gets_combinatorial_pairs
46
+ exp = [
47
+ [[1, 6], [1, 2], [1, 5], [1, 11], [6, 2], [6, 5],
48
+ [6, 11], [2, 5], [2, 11], [5, 11]],
49
+ [[3, 15], [3, 13], [3, 2], [3, 9], [15, 13], [15, 2],
50
+ [15, 9], [13, 2], [13, 9], [2, 9]]
51
+ ]
52
+ assert_equal exp, @metric.send(:get_pairs, @v1, @v2)
53
+ end
54
+ end
55
+ end
56
+
57
+ class TestDeltas < self
58
+ class TestIntraDelta < self
59
+ def test_gets_intra_delta
60
+ pairs = [
61
+ [[1, 6], [6, 2], [2, 5], [5, 11]],
62
+ [[3, 15], [15, 13], [13, 2], [2, 9]]
63
+ ]
64
+ exp = [
65
+ [5, 4, 3, 6],
66
+ [12, 2, 11, 7]
67
+ ]
68
+ assert_equal exp, @metric.send(:intra_delta, pairs)
69
+ end
70
+ def test_intra_delta_proc
71
+ @metric.intra_delta = ->(*vp) {nil}
72
+ assert_instance_of Proc, @metric.instance_variable_get(:@intra_delta)
73
+ end
74
+ end
75
+
76
+ class TestInterDelta < self
77
+ def setup
78
+ super
79
+ @diffs = [
80
+ [5, 4, 3, 6],
81
+ [12, 2, 11, 7]
82
+ ]
83
+ end
84
+ def test_gets_inter_delta_ordered
85
+ exp = 4.5
86
+ assert_equal exp, @metric.send(:inter_delta, @diffs)
87
+ end
88
+ def test_inter_delta_proc
89
+ @metric.inter_delta = ->(*diffs) {nil}
90
+ assert_instance_of Proc, @metric.instance_variable_get(:@inter_delta)
91
+ end
92
+ end
93
+ end
94
+
95
+ class TestScaling < self
96
+ def setup
97
+ super
98
+ @unscaled = [
99
+ [5, 4, 3, 6],
100
+ [12, 2, 11, 7]
101
+ ]
102
+ end
103
+
104
+ def test_assigns_scaling_proc
105
+ @metric.scale = ->(pairs) {}
106
+ scale = @metric.instance_variable_get :@scale
107
+ assert_equal Proc, scale.class
108
+ end
109
+
110
+ def test_no_scaling
111
+ assert_equal @unscaled, @metric.send(:scale, @unscaled)
112
+ end
113
+
114
+ # TODO: This is a complicated test and I don't like it
115
+ def test_absolute_scaling
116
+ @metric.scale = :absolute
117
+ @exp = [
118
+ [0.417, 0.333, 0.25, 0.5],
119
+ [1.0, 0.167, 0.917, 0.583]
120
+ ]
121
+ actual = @metric.send :scale, @unscaled
122
+ actual.each_with_index do |v, i|
123
+ v.each_with_index do |w, j|
124
+ assert_in_delta @exp[i][j], w, 0.001
125
+ end
126
+ end
127
+ end
128
+
129
+ def test_relative_scaling
130
+ @metric.scale = :relative
131
+ @exp = [
132
+ [0.833, 0.667, 0.5, 1.0],
133
+ [1.0, 0.167, 0.917, 0.583]
134
+ ]
135
+ actual = @metric.send :scale, @unscaled
136
+ actual.each_with_index do |v, i|
137
+ v.each_with_index do |w, j|
138
+ assert_in_delta @exp[i][j], w, 0.001
139
+ end
140
+ end
141
+ end
142
+ end
143
+
144
+ class TestMagnitudeMetric < self
145
+ # Definitions of expected results
146
+ @exp = {
147
+ :olm => {:scale_none => 4.5, :scale_absolute => 0.375},
148
+ :ocm => {:scale_none => 5.2, :scale_absolute => 0.4},
149
+ :ulm => {:scale_none => 3.5, :scale_absolute => 0.29167},
150
+ :ucm => {:scale_none => 2.4, :scale_absolute => 0.1846},
151
+ :old => {:scale_none => 0.25},
152
+ :ocd => {:scale_none => 0.4},
153
+ :uld => {:scale_none => 0.25},
154
+ :ucd => {:scale_none => 0.4}
155
+ }
156
+
157
+ @exp.each do |metric, expected|
158
+ expected.each do |scaling, e|
159
+ define_method "test_#{metric}_#{scaling}" do
160
+ m = ::MM::Metric.se
data/test/mm/test_mm.rb CHANGED
@@ -1,6 +1,5 @@
1
- require "minitest/autorun"
2
- require "mm"
3
-
4
- class TestMM < Minitest::Test
5
-
6
- end
1
+ require "minitest/autorun"
2
+ require "mm"
3
+
4
+ class TestMM < Minitest::Test
5
+
@@ -1,27 +1,24 @@
1
- # require "minitest/autorun"
2
- require "mm/pairs"
3
-
4
- class TestMM < Minitest::Test; end
5
-
6
- class TestMM::TestPairs < Minitest::Test
7
- def setup
8
- @pairs = MM::Pairs.new
9
- end
10
-
11
- def test_linear_flat_array
12
- assert_equal [[0, 1], [1, 2], [2, 3]], @pairs.linear([0, 1, 2, 3])
13
- end
14
-
15
- def test_linear_nested_array
16
- assert_equal [[[0, 1], [2, 3]], [[2, 3], [4, 5]]], @pairs.linear([[0, 1], [2, 3], [4, 5]])
17
- end
18
-
19
- def test_combinatorial_flat_array
20
- assert_equal [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]], @pairs.combinatorial([0, 1, 2, 3])
21
- end
22
-
23
- def test_combinatorial_nested_array
24
- assert_equal [[[0, 1], [2, 3]], [[0, 1], [4, 5]], [[2, 3], [4, 5]]], @pairs.combinatorial([[0, 1], [2, 3], [4, 5]])
25
- end
26
- end
27
-
1
+ # require "minitest/autorun"
2
+ require "mm/pairs"
3
+
4
+ class TestMM < Minitest::Test; end
5
+
6
+ class TestMM::TestPairs < Minitest::Test
7
+ def setup
8
+ @pairs = MM::Pairs.new
9
+ end
10
+
11
+ def test_linear_flat_array
12
+ assert_equal [[0, 1], [1, 2], [2, 3]], @pairs.linear([0, 1, 2, 3])
13
+ end
14
+
15
+ def test_linear_nested_array
16
+ assert_equal [[[0, 1], [2, 3]], [[2, 3], [4, 5]]], @pairs.linear([[0, 1], [2, 3], [4, 5]])
17
+ end
18
+
19
+ def test_combinatorial_flat_array
20
+ assert_equal [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]], @pairs.combinatorial([0, 1, 2, 3])
21
+ end
22
+
23
+ def test_combinatorial_nested_array
24
+ assert_equal [[[0, 1], [2, 3]], [[0, 1], [4, 5]], [[2, 3], [4, 5]]], @pairs.combinatorial([[0, 1], [2, 3
@@ -1,132 +1,130 @@
1
- require 'mm/ratio'
2
-
3
- class TestMM < Minitest::Test; end
4
-
5
- class TestMM::TestRatio < Minitest::Test
6
- def setup
7
- @ratio = MM::Ratio.new(3,2)
8
- end
9
-
10
- def test_numerator
11
- assert_equal 3, @ratio.numerator
12
- end
13
-
14
- def test_denominator
15
- assert_equal 2, @ratio.denominator
16
- end
17
-
18
- def test_multiplication
19
- mul = @ratio * MM::Ratio.new(5,4)
20
- assert_equal MM::Ratio.new(15,8), mul
21
- end
22
-
23
- def test_multiplication_reduces
24
- mul = @ratio * MM::Ratio.new(10,9)
25
- assert_equal MM::Ratio.new(5,3), mul
26
- end
27
-
28
- def test_division
29
- div = @ratio / MM::Ratio.new(5,4)
30
- assert_equal MM::Ratio.new(6,5), div
31
- end
32
-
33
- def test_from_s_single
34
- assert_equal @ratio, MM::Ratio.from_s("3/2")
35
- end
36
-
37
- def test_from_s_array
38
- assert_equal [@ratio, @ratio], MM::Ratio.from_s(%w(3/2 3/2))
39
- end
40
-
41
- def test_from_s_list
42
- assert_equal [@ratio, @ratio], MM::Ratio.from_s("3/2 3/2")
43
- end
44
-
45
- def test_from_s_multi_digit
46
- assert_equal MM::Ratio.new(10,9), MM::Ratio.from_s("10/9")
47
- end
48
-
49
- def test_to_f
50
- assert_equal 1.5, @ratio.to_f
51
- end
52
-
53
- def test_to_s
54
- assert_equal "3/2", @ratio.to_s
55
- end
56
-
57
- def test_eql
58
- assert @ratio.eql?(MM::Ratio.new(3,2))
59
- end
60
-
61
- def test_uniq
62
- assert_equal [MM::Ratio.new(3,2)], [MM::Ratio.new(3,2), @ratio].uniq
63
- end
64
-
65
- def test_plus
66
- assert_equal MM::Ratio.new(3,1), @ratio + @ratio
67
- end
68
-
69
- def test_minus
70
- assert_equal MM::Ratio.new(5,6), @ratio - @ratio.reciprocal
71
- end
72
-
73
- def test_reciprocal
74
- assert_equal MM::Ratio.new(2,3), @ratio.reciprocal
75
- end
76
-
77
- def test_cents
78
- assert_in_delta 701.955, @ratio.cents
79
- end
80
-
81
- def test_reads_ratios_from_yaml
82
- ratios = MM::Ratio.from_yaml(<<-YAML)
83
- - 1/1
84
- - 10/9
85
- - 5/4
86
- YAML
87
- exp = [MM::Ratio.new(1,1), MM::Ratio.new(10,9), MM::Ratio.new(5,4)]
88
- assert_equal exp, ratios
89
- end
90
-
91
- def test_to_vector
92
- point = [MM::Ratio.new(1,1), MM::Ratio.new(3,2), MM::Ratio.new(5,4)]
93
- exp = [MM::Ratio.new(2,3), MM::Ratio.new(6,5)]
94
- assert_equal exp, MM::Ratio.to_vector(point)
95
- end
96
-
97
- def test_from_vector
98
- vector = [MM::Ratio.new(2,3), MM::Ratio.new(6,5)]
99
- exp = [MM::Ratio.new(1,1), MM::Ratio.new(3,2), MM::Ratio.new(5,4)]
100
- assert_equal exp, MM::Ratio.from_vector(vector)
101
- end
102
-
103
- def test_change_interval
104
- point = [MM::Ratio.new(1,1), MM::Ratio.new(3,2), MM::Ratio.new(5,4)]
105
- exp = [MM::Ratio.new(1,1), MM::Ratio.new(4,3), MM::Ratio.new(10,9)]
106
- assert_equal exp, MM::Ratio.change_interval(point, 0, MM::Ratio.new(3,4))
107
- end
108
-
109
- def test_change_interval_reciprocal
110
- point = [MM::Ratio.new(1,1), MM::Ratio.new(3,2), MM::Ratio.new(5,4)]
111
- exp = [MM::Ratio.new(1,1), MM::Ratio.new(2,3), MM::Ratio.new(5,9)]
112
- assert_equal exp, MM::Ratio.change_interval(point, 0, :reciprocal)
113
- end
114
-
115
- def test_factors
116
- assert_equal [[2, -1], [3, 1]], MM::Ratio.new(3,2).factors
117
- assert_equal [[2, -1], [3, -1], [5, 1]], MM::Ratio.new(5,6).factors
118
- end
119
-
120
- def test_each
121
- enumerator = MM::Ratio.new(3,2).each
122
- assert_kind_of Enumerator, enumerator
123
- assert_equal 3, enumerator.next
124
- assert_equal 2, enumerator.next
125
- end
126
-
127
- def test_prime_limit
128
- assert_equal 13, MM::Ratio.new(26,5).prime_limit
129
- assert_equal nil, MM::Ratio.new(1,1).prime_limit
130
- end
131
- end
132
-
1
+ require 'mm/ratio'
2
+
3
+ class TestMM < Minitest::Test; end
4
+
5
+ class TestMM::TestRatio < Minitest::Test
6
+ def setup
7
+ @ratio = MM::Ratio.new(3,2)
8
+ end
9
+
10
+ def test_numerator
11
+ assert_equal 3, @ratio.numerator
12
+ end
13
+
14
+ def test_denominator
15
+ assert_equal 2, @ratio.denominator
16
+ end
17
+
18
+ def test_multiplication
19
+ mul = @ratio * MM::Ratio.new(5,4)
20
+ assert_equal MM::Ratio.new(15,8), mul
21
+ end
22
+
23
+ def test_multiplication_reduces
24
+ mul = @ratio * MM::Ratio.new(10,9)
25
+ assert_equal MM::Ratio.new(5,3), mul
26
+ end
27
+
28
+ def test_division
29
+ div = @ratio / MM::Ratio.new(5,4)
30
+ assert_equal MM::Ratio.new(6,5), div
31
+ end
32
+
33
+ def test_from_s_single
34
+ assert_equal @ratio, MM::Ratio.from_s("3/2")
35
+ end
36
+
37
+ def test_from_s_array
38
+ assert_equal [@ratio, @ratio], MM::Ratio.from_s(%w(3/2 3/2))
39
+ end
40
+
41
+ def test_from_s_list
42
+ assert_equal [@ratio, @ratio], MM::Ratio.from_s("3/2 3/2")
43
+ end
44
+
45
+ def test_from_s_multi_digit
46
+ assert_equal MM::Ratio.new(10,9), MM::Ratio.from_s("10/9")
47
+ end
48
+
49
+ def test_to_f
50
+ assert_equal 1.5, @ratio.to_f
51
+ end
52
+
53
+ def test_to_s
54
+ assert_equal "3/2", @ratio.to_s
55
+ end
56
+
57
+ def test_eql
58
+ assert @ratio.eql?(MM::Ratio.new(3,2))
59
+ end
60
+
61
+ def test_uniq
62
+ assert_equal [MM::Ratio.new(3,2)], [MM::Ratio.new(3,2), @ratio].uniq
63
+ end
64
+
65
+ def test_plus
66
+ assert_equal MM::Ratio.new(3,1), @ratio + @ratio
67
+ end
68
+
69
+ def test_minus
70
+ assert_equal MM::Ratio.new(5,6), @ratio - @ratio.reciprocal
71
+ end
72
+
73
+ def test_reciprocal
74
+ assert_equal MM::Ratio.new(2,3), @ratio.reciprocal
75
+ end
76
+
77
+ def test_cents
78
+ assert_in_delta 701.955, @ratio.cents
79
+ end
80
+
81
+ def test_reads_ratios_from_yaml
82
+ ratios = MM::Ratio.from_yaml(<<-YAML)
83
+ - 1/1
84
+ - 10/9
85
+ - 5/4
86
+ YAML
87
+ exp = [MM::Ratio.new(1,1), MM::Ratio.new(10,9), MM::Ratio.new(5,4)]
88
+ assert_equal exp, ratios
89
+ end
90
+
91
+ def test_to_vector
92
+ point = [MM::Ratio.new(1,1), MM::Ratio.new(3,2), MM::Ratio.new(5,4)]
93
+ exp = [MM::Ratio.new(2,3), MM::Ratio.new(6,5)]
94
+ assert_equal exp, MM::Ratio.to_vector(point)
95
+ end
96
+
97
+ def test_from_vector
98
+ vector = [MM::Ratio.new(2,3), MM::Ratio.new(6,5)]
99
+ exp = [MM::Ratio.new(1,1), MM::Ratio.new(3,2), MM::Ratio.new(5,4)]
100
+ assert_equal exp, MM::Ratio.from_vector(vector)
101
+ end
102
+
103
+ def test_change_interval
104
+ point = [MM::Ratio.new(1,1), MM::Ratio.new(3,2), MM::Ratio.new(5,4)]
105
+ exp = [MM::Ratio.new(1,1), MM::Ratio.new(4,3), MM::Ratio.new(10,9)]
106
+ assert_equal exp, MM::Ratio.change_interval(point, 0, MM::Ratio.new(3,4))
107
+ end
108
+
109
+ def test_change_interval_reciprocal
110
+ point = [MM::Ratio.new(1,1), MM::Ratio.new(3,2), MM::Ratio.new(5,4)]
111
+ exp = [MM::Ratio.new(1,1), MM::Ratio.new(2,3), MM::Ratio.new(5,9)]
112
+ assert_equal exp, MM::Ratio.change_interval(point, 0, :reciprocal)
113
+ end
114
+
115
+ def test_factors
116
+ assert_equal [[2, -1], [3, 1]], MM::Ratio.new(3,2).factors
117
+ assert_equal [[2, -1], [3, -1], [5, 1]], MM::Ratio.new(5,6).factors
118
+ end
119
+
120
+ def test_each
121
+ enumerator = MM::Ratio.new(3,2).each
122
+ assert_kind_of Enumerator, enumerator
123
+ assert_equal 3, enumerator.next
124
+ assert_equal 2, enumerator.next
125
+ end
126
+
127
+ def test_prime_limit
128
+ assert_equal 13, MM::Ratio.new(26,5).prime_limit
129
+ assert_equal nil, MM::Ratio.new(1,1).prime_limit
130
+ en
@@ -10,18 +10,21 @@ class TestMM::TestScaling < Minitest::Test
10
10
  @n = [4, 3, 6, 2]
11
11
  @m = [3, 4, 1, 2]
12
12
  end
13
+
13
14
  def test_absolute_scaling
14
15
  expected = [[0.667, 0.5, 1.0, 0.333],
15
16
  [0.5, 0.667, 0.167, 0.333]]
16
17
  result = MM::Scaling.absolute([@n, @m])
17
18
  assert_nested_in_delta_2_deep expected, result
18
19
  end
20
+
19
21
  def test_relative_scaling
20
22
  expected = [[0.667, 0.5, 1.0, 0.333],
21
23
  [0.75, 1.0, 0.25, 0.5]]
22
24
  result = MM::Scaling.relative([@n, @m])
23
25
  assert_nested_in_delta_2_deep expected, result
24
26
  end
27
+
25
28
  def test_get_global_scaling
26
29
  expected = [[0.5, 0.375, 0.75, 0.25],
27
30
  [0.375, 0.5, 0.125, 0.25]]