hierclust 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,10 @@
1
+ == 0.1.5 2008-03-21
2
+
3
+ * 1 minor enhancement:
4
+ * added cluster radius
5
+ * 1 new example script:
6
+ * demonstrates SVG rendering of points and clusters
7
+
1
8
  == 0.1.4 2008-02-13
2
9
 
3
10
  * 1 minor enhancement:
@@ -37,6 +37,14 @@ module Hierclust
37
37
  @items.size
38
38
  end
39
39
 
40
+ # Returns the distance from the center of this Cluster to the edge.
41
+ def radius
42
+ return nil if @items.empty?
43
+ return 0 if @items.size == 1
44
+ return (@items[0].distance_to(@items[1]) + @items[0].radius + @items[1].radius) / 2.0
45
+ raise "radius not implemented for clusters with more than two items"
46
+ end
47
+
40
48
  # Returns a flat list of all the points contained in either this cluster
41
49
  # or any of the clusters it contains.
42
50
  def points
@@ -23,6 +23,11 @@ module Hierclust
23
23
  1
24
24
  end
25
25
 
26
+ # Simplifies code by letting us treat Clusters and Points interchangeably
27
+ def radius #:nodoc:
28
+ 0
29
+ end
30
+
26
31
  # Simplifies code by letting us treat Clusters and Points interchangeably
27
32
  def points #:nodoc:
28
33
  [self]
@@ -2,7 +2,7 @@ module Hierclust #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 4
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -13,6 +13,10 @@ module Hierclust
13
13
  it "should have nil y-coordinate" do
14
14
  @c.y.should be_nil
15
15
  end
16
+
17
+ it "should have nil radius" do
18
+ @c.radius.should be_nil
19
+ end
16
20
  end
17
21
 
18
22
  describe Cluster, " with one point" do
@@ -30,6 +34,10 @@ module Hierclust
30
34
  it "should have the same y-coordinate as the point" do
31
35
  @c.y.should == @p.y
32
36
  end
37
+
38
+ it "should have 0 radius" do
39
+ @c.radius.should == 0
40
+ end
33
41
  end
34
42
 
35
43
  describe Cluster, " with two points" do
@@ -57,6 +65,11 @@ module Hierclust
57
65
  it "should include both points" do
58
66
  @points.should include(@p_1, @p_2)
59
67
  end
68
+
69
+ it "should have correct radius" do
70
+ radius = Math.sqrt((@x_1 - @x_2) ** 2 + (@y_1 - @y_2) ** 2) / 2.0
71
+ @c.radius.should == radius
72
+ end
60
73
  end
61
74
 
62
75
  describe Cluster, " with one point and one cluster" do
@@ -14,5 +14,9 @@ module Hierclust
14
14
  it "should calculate distance to other" do
15
15
  @p.distance_to(@p2).should == 1.0
16
16
  end
17
+
18
+ it "should have zero radius" do
19
+ @p.radius.should == 0.0
20
+ end
17
21
  end
18
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hierclust
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandt Kurowski
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-02-13 00:00:00 -05:00
12
+ date: 2008-03-21 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15