fathom 0.3.4 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.6
@@ -19,39 +19,6 @@ module Fathom
19
19
  lib = File.expand_path(File.dirname(__FILE__))
20
20
  $LOAD_PATH.unshift(lib)
21
21
 
22
- Fathom.autoload :Node, "node"
23
- Fathom.autoload :BeliefNode, "node/belief_node"
24
- Fathom.autoload :DataCollection, "node/data_collection"
25
- Fathom.autoload :DataNode, "node/data_node"
26
- Fathom.autoload :DiscreteNode, "node/discrete_node"
27
- Fathom.autoload :MCNode, "node/mc_node"
28
- Fathom.autoload :PlausibleRange, "node/plausible_range"
29
- Fathom.autoload :Fact, "node/fact"
30
- Fathom.autoload :Decision, "node/decision"
31
- Fathom.autoload :CPMNode, 'node/cpm_node'
32
-
33
- Fathom.autoload :ValueDescription, "value_description"
34
- Fathom.autoload :MonteCarloSet, "monte_carlo_set"
35
- Fathom.autoload :KnowledgeBase, "knowledge_base"
36
-
37
- Fathom.autoload :Import, "import"
38
- Fathom.autoload :ImportNode, "import/import_node"
39
- Fathom.autoload :YAMLImport, 'import/yaml_import'
40
- Fathom.autoload :CSVImport, 'import/csv_import'
41
-
42
- Fathom.autoload :Simulation, 'simulation'
43
- Fathom.autoload :TickMethods, 'simulation/tick_methods'
44
- Fathom.autoload :TickSimulation, 'simulation/tick_simulation'
45
-
46
- Fathom.autoload :Agent, 'agent'
47
- Fathom.autoload :Properties, 'agent/properties'
48
- Fathom.autoload :AgentCluster, 'agent/agent_cluster'
49
-
50
- Fathom.autoload :EnforcedName, 'node/node_extensions/enforced_name'
51
- Fathom.autoload :NumericMethods, 'node/node_extensions/numeric_methods'
52
-
53
-
54
-
55
22
  # Autoload classes and modules so that we only load as much of the library as we're using.
56
23
  # This allows us to have a fairly large library without taking up a lot of memory unless we need it.
57
24
  # autoload :Node, "node"
@@ -103,3 +70,34 @@ end
103
70
 
104
71
  # Temporary
105
72
  # include Fathom
73
+
74
+ Fathom.autoload :Node, "node"
75
+ Fathom.autoload :BeliefNode, "node/belief_node"
76
+ Fathom.autoload :DataCollection, "node/data_collection"
77
+ Fathom.autoload :DataNode, "node/data_node"
78
+ Fathom.autoload :DiscreteNode, "node/discrete_node"
79
+ Fathom.autoload :MCNode, "node/mc_node"
80
+ Fathom.autoload :PlausibleRange, "node/plausible_range"
81
+ Fathom.autoload :Fact, "node/fact"
82
+ Fathom.autoload :Decision, "node/decision"
83
+ Fathom.autoload :CPMNode, 'node/cpm_node'
84
+
85
+ Fathom.autoload :ValueDescription, "value_description"
86
+ Fathom.autoload :MonteCarloSet, "monte_carlo_set"
87
+ Fathom.autoload :KnowledgeBase, "knowledge_base"
88
+
89
+ Fathom.autoload :Import, "import"
90
+ Fathom.autoload :ImportNode, "import/import_node"
91
+ Fathom.autoload :YAMLImport, 'import/yaml_import'
92
+ Fathom.autoload :CSVImport, 'import/csv_import'
93
+
94
+ Fathom.autoload :Simulation, 'simulation'
95
+ Fathom.autoload :TickMethods, 'simulation/tick_methods'
96
+ Fathom.autoload :TickSimulation, 'simulation/tick_simulation'
97
+
98
+ Fathom.autoload :Agent, 'agent'
99
+ Fathom.autoload :Properties, 'agent/properties'
100
+ Fathom.autoload :AgentCluster, 'agent/agent_cluster'
101
+
102
+ Fathom.autoload :EnforcedName, 'node/node_extensions/enforced_name'
103
+ Fathom.autoload :NumericMethods, 'node/node_extensions/numeric_methods'
@@ -1,7 +1,8 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'fathom'))
2
2
  class Fathom::MCNode < Fathom::Node
3
3
 
4
- attr_reader :value_description, :samples_taken
4
+ attr_reader :samples_taken
5
+ attr_accessor :value_description
5
6
 
6
7
  def initialize(opts={}, &block)
7
8
  super(opts)
@@ -18,7 +18,7 @@ describe Gaussian do
18
18
  end
19
19
 
20
20
  it "should be able to generate an inverse CDF" do
21
- Gaussian.inverse_cdf(@opts).should be_close(-0.16448, 0.00001)
21
+ Gaussian.inverse_cdf(@opts).should be_within(0.00001).of(-0.16448)
22
22
  end
23
23
 
24
24
  it "should require mean as an option for an inverse CDF" do
@@ -33,20 +33,20 @@ describe Gaussian do
33
33
 
34
34
  it "should take std as an alias for sd when creating an inverse CDF" do
35
35
  @opts.delete(:sd)
36
- Gaussian.inverse_cdf(@opts.merge(:std => 0.1)).should be_close(-0.16448, 0.00001)
36
+ Gaussian.inverse_cdf(@opts.merge(:std => 0.1)).should be_within(0.00001).of(-0.16448)
37
37
  end
38
38
 
39
39
  it "should take standard_deviation as an alias for sd when creating an inverse CDF" do
40
40
  @opts.delete(:sd)
41
- Gaussian.inverse_cdf(@opts.merge(:standard_deviation => 0.1)).should be_close(-0.16448, 0.00001)
41
+ Gaussian.inverse_cdf(@opts.merge(:standard_deviation => 0.1)).should be_within(0.00001).of(-0.16448)
42
42
  end
43
43
 
44
44
  it "should be able to set upper to true and get Q instead of P" do
45
- Gaussian.inverse_cdf(@opts.merge(:upper =>true)).should be_close(0.16448, 0.00001)
45
+ Gaussian.inverse_cdf(@opts.merge(:upper =>true)).should be_within(0.00001).of(0.16448)
46
46
  end
47
47
 
48
48
  it "should be able to take a different confidence interval" do
49
- Gaussian.inverse_cdf(@opts.merge(:confidence_interval => 0.1)).should be_close(-0.12815, 0.00001)
49
+ Gaussian.inverse_cdf(@opts.merge(:confidence_interval => 0.1)).should be_within(0.00001).of(-0.12815)
50
50
  end
51
51
 
52
52
  it "should have a lower_bound alias for inverse_cdf" do
@@ -5,6 +5,6 @@ include Fathom
5
5
  describe ImportNode do
6
6
  it "should record the time of the import" do
7
7
  i = ImportNode.new
8
- i.imported_at.should be_close(Time.now, 0.01)
8
+ i.imported_at.should be_within(0.01).of(Time.now)
9
9
  end
10
10
  end
@@ -46,24 +46,24 @@ describe CPMNode do
46
46
  # GSL::Matrix
47
47
  # [ 8.000e-02 1.200e-01
48
48
  # 3.200e-01 4.800e-01 ]
49
- @cpm.probability(:color => :red, :child => :asher).should be_close(0.08, 1e-10)
50
- @cpm.probability(:color => :red, :child => :stella).should be_close(0.32, 1e-10)
51
- @cpm.probability(:color => :green, :child => :asher).should be_close(0.12, 1e-10)
52
- @cpm.probability(:color => :green, :child => :stella).should be_close(0.48, 1e-10)
49
+ @cpm.probability(:color => :red, :child => :asher).should be_within(1e-10).of(0.08)
50
+ @cpm.probability(:color => :red, :child => :stella).should be_within(1e-10).of(0.32)
51
+ @cpm.probability(:color => :green, :child => :asher).should be_within(1e-10).of(0.12)
52
+ @cpm.probability(:color => :green, :child => :stella).should be_within(1e-10).of(0.48)
53
53
  end
54
54
 
55
55
  it "should look for all children values, if no child is provided" do
56
- @cpm.probability(:child => :asher).should be_close(0.2, 1e-10)
57
- @cpm.probability(:child => :stella).should be_close(0.8, 1e-10)
56
+ @cpm.probability(:child => :asher).should be_within(1e-10).of(0.2)
57
+ @cpm.probability(:child => :stella).should be_within(1e-10).of(0.8)
58
58
  end
59
59
 
60
60
  it "should look for all parent values, if no parent is provided" do
61
- @cpm.probability(:color => :red).should be_close(0.4, 1e-10)
62
- @cpm.probability(:color => :green).should be_close(0.6, 1e-10)
61
+ @cpm.probability(:color => :red).should be_within(1e-10).of(0.4)
62
+ @cpm.probability(:color => :green).should be_within(1e-10).of(0.6)
63
63
  end
64
64
 
65
65
  it "should provide a probability of 1 if no filter is set" do
66
- @cpm.probability.should be_close(1.0, 1e-10)
66
+ @cpm.probability.should be_within(1e-10).of(1.0)
67
67
  end
68
68
 
69
69
  it "should give a description in a hash, if description is turned on" do
@@ -79,38 +79,38 @@ describe CPMNode do
79
79
  end
80
80
 
81
81
  it "should alias p for probability" do
82
- @cpm.p(:color => :red, :child => :asher).should be_close(0.08, 1e-10)
83
- @cpm.p(:color => :red, :child => :stella).should be_close(0.32, 1e-10)
84
- @cpm.p(:color => :green, :child => :asher).should be_close(0.12, 1e-10)
85
- @cpm.p(:color => :green, :child => :stella).should be_close(0.48, 1e-10)
86
- @cpm.p(:child => :asher).should be_close(0.2, 1e-10)
87
- @cpm.p(:child => :stella).should be_close(0.8, 1e-10)
88
- @cpm.p(:color => :red).should be_close(0.4, 1e-10)
89
- @cpm.p(:color => :green).should be_close(0.6, 1e-10)
90
- @cpm.p.should be_close(1.0, 1e-10)
82
+ @cpm.p(:color => :red, :child => :asher).should be_within(1e-10).of(0.08)
83
+ @cpm.p(:color => :red, :child => :stella).should be_within(1e-10).of(0.32)
84
+ @cpm.p(:color => :green, :child => :asher).should be_within(1e-10).of(0.12)
85
+ @cpm.p(:color => :green, :child => :stella).should be_within(1e-10).of(0.48)
86
+ @cpm.p(:child => :asher).should be_within(1e-10).of(0.2)
87
+ @cpm.p(:child => :stella).should be_within(1e-10).of(0.8)
88
+ @cpm.p(:color => :red).should be_within(1e-10).of(0.4)
89
+ @cpm.p(:color => :green).should be_within(1e-10).of(0.6)
90
+ @cpm.p.should be_within(1e-10).of(1.0)
91
91
  end
92
92
 
93
93
  it "should have odds for any query" do
94
- @cpm.odds(:color => :red, :child => :asher).should be_close(0.087, 1e-3)
95
- @cpm.odds(:color => :red, :child => :stella).should be_close(0.471, 1e-3)
96
- @cpm.odds(:color => :green, :child => :asher).should be_close(0.136, 1e-3)
97
- @cpm.odds(:color => :green, :child => :stella).should be_close(0.923, 1e-3)
98
- @cpm.odds(:child => :asher).should be_close(0.25, 1e-3)
99
- @cpm.odds(:child => :stella).should be_close(4.0, 1e-3)
100
- @cpm.odds(:color => :red).should be_close(0.666, 1e-3)
101
- @cpm.odds(:color => :green).should be_close(1.5, 1e-3)
94
+ @cpm.odds(:color => :red, :child => :asher).should be_within(1e-3).of(0.087)
95
+ @cpm.odds(:color => :red, :child => :stella).should be_within(1e-3).of(0.471)
96
+ @cpm.odds(:color => :green, :child => :asher).should be_within(1e-3).of(0.136)
97
+ @cpm.odds(:color => :green, :child => :stella).should be_within(1e-3).of(0.923)
98
+ @cpm.odds(:child => :asher).should be_within(1e-3).of(0.25)
99
+ @cpm.odds(:child => :stella).should be_within(1e-3).of(4.0)
100
+ @cpm.odds(:color => :red).should be_within(1e-3).of(0.666)
101
+ @cpm.odds(:color => :green).should be_within(1e-3).of(1.5)
102
102
  @cpm.odds.should eql(1 / 0.0)
103
103
  end
104
104
 
105
105
  it "should alias o for odds" do
106
- @cpm.o(:color => :red, :child => :asher).should be_close(0.087, 1e-3)
107
- @cpm.o(:color => :red, :child => :stella).should be_close(0.471, 1e-3)
108
- @cpm.o(:color => :green, :child => :asher).should be_close(0.136, 1e-3)
109
- @cpm.o(:color => :green, :child => :stella).should be_close(0.923, 1e-3)
110
- @cpm.o(:child => :asher).should be_close(0.25, 1e-3)
111
- @cpm.o(:child => :stella).should be_close(4.0, 1e-3)
112
- @cpm.o(:color => :red).should be_close(0.666, 1e-3)
113
- @cpm.o(:color => :green).should be_close(1.5, 1e-3)
106
+ @cpm.o(:color => :red, :child => :asher).should be_within(1e-3).of(0.087)
107
+ @cpm.o(:color => :red, :child => :stella).should be_within(1e-3).of(0.471)
108
+ @cpm.o(:color => :green, :child => :asher).should be_within(1e-3).of(0.136)
109
+ @cpm.o(:color => :green, :child => :stella).should be_within(1e-3).of(0.923)
110
+ @cpm.o(:child => :asher).should be_within(1e-3).of(0.25)
111
+ @cpm.o(:child => :stella).should be_within(1e-3).of(4.0)
112
+ @cpm.o(:color => :red).should be_within(1e-3).of(0.666)
113
+ @cpm.o(:color => :green).should be_within(1e-3).of(1.5)
114
114
  @cpm.o.should eql(1 / 0.0)
115
115
  end
116
116
 
@@ -68,7 +68,7 @@ describe PlausibleRange do
68
68
  end
69
69
 
70
70
  it "should be able to calculate the standard deviation" do
71
- @pr.standard_deviation.should be_close( 2.7358, 0.0001)
71
+ @pr.standard_deviation.should be_within(0.0001).of( 2.7358)
72
72
  end
73
73
 
74
74
  it "should be able to use std instead of standard_deviation" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fathom
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 6
10
+ version: 0.3.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - David