statfeed 1.0.1 → 1.1.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/statfeed.rb +14 -7
  3. data/test/test_statfeed.rb +10 -23
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c60df28cfbe507a544ecbdd58cd0c24f1d8ac87
4
- data.tar.gz: 81da8653f2970b5295fd2c84410725e9fc4e86a9
3
+ metadata.gz: 9c6c540c16236c35e45d7f0b20f1ec84d4d2c624
4
+ data.tar.gz: 77ab3b7498230d2c6bed53d4bd3e5a5173e32ac4
5
5
  SHA512:
6
- metadata.gz: 2411be809e795c59c8d6f9208449d03af3f756a7ed72d508852d21c2d250789a13c01734f485c6a31758bfdf0af1acc76137846a8c653bf8ab294764ceda9d84
7
- data.tar.gz: cd055760f586d4f00734623e32adbe2d3987c8ff4eda5e2ec26b92c4de2121b90236430a6ef838287c958bf7ffd68610812b2e5f29472f7c23ee0211e4a5adc6
6
+ metadata.gz: 350b2dfe60dd2801cbee43b6aed20e5d8a2161478465797bcadabfcf182c4a0a3737e416d9859f77676164d12efc4c77a9fccdf3a77f7ec0e1aae1cef572ef77
7
+ data.tar.gz: 762e4da1cfc1305d3b66e514efa831cb393a989d3245812bb3e0cf27cdadf5076a67d02444c05519f8ce66c626639a44caac45cce2b2915f2f903dcfb2a3f022
@@ -1,5 +1,5 @@
1
1
  class Statfeed
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  attr_accessor :weights, :choices, :randoms, :heterogeneities, :accents, :statistics, :size, :decisions, :options
4
4
 
5
5
  def initialize decisions, options, heterogeneity: 0.1, accent: 1.0
@@ -27,13 +27,20 @@ class Statfeed
27
27
  end
28
28
 
29
29
  def populate_choices
30
- @decisions.each_index do |decision|
31
- vals = scheduling_values(decision)
32
- @choices[decision] = sort_options(vals).first
33
- increment_statistics decision, sort_option_indices(vals).first
34
- normalize_statistics! decision
30
+ @choices.tap do |choices|
31
+ @decisions.each_index do |decision|
32
+ options = sort_options(scheduling_values(decision))
33
+ index = options.find_index {|o| acceptable? o}
34
+ choices[decision] = options[index]
35
+ increment_statistics decision, index
36
+ normalize_statistics! decision
37
+ end
35
38
  end
36
- @choices
39
+ end
40
+
41
+ # Default is "everything's okay"
42
+ def acceptable? o
43
+ true
37
44
  end
38
45
 
39
46
  def populate_randoms
@@ -27,32 +27,19 @@ class TestStatfeed < Minitest::Test
27
27
  assert_each_equal %w(a c b), actual
28
28
  end
29
29
 
30
- def test_n_decisions
31
- # Should have N possible decisions
30
+ def test_populate_choices
31
+ actual = @sf.populate_choices
32
+ assert_each_equal %w(a b b), actual
32
33
  end
33
34
 
34
- def test_m_options
35
- # Should have a common pool of M possible options
36
- end
37
-
38
- def test_s_sub_m
39
- # Should have a statistic S_m for the statistic associated with option m
40
- end
41
-
42
- def test_a_sub_n
43
- # Accent (stress) associated with the decision n
44
- end
45
-
46
- def test_h_sub_n
47
- # Heterogeneity associated with decision n
48
- end
49
-
50
- def test_w_sub_m_n
51
- # Weight associated with option m during decision n
52
- end
35
+ def test_additional_constraints
36
+ # Define a new method excluding the a
37
+ def @sf.acceptable? o
38
+ o != 'a'
39
+ end
53
40
 
54
- def test_u_sub_m_n
55
- # Uniformly distributed random number for each option of each decision
41
+ actual = @sf.populate_choices
42
+ assert_each_equal %w(b c c), actual
56
43
  end
57
44
 
58
45
  def assert_each_in_delta exp, act, delta = 0.001
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statfeed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-18 00:00:00.000000000 Z
11
+ date: 2015-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc