measurable 0.0.9 → 0.0.11

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
- SHA1:
3
- metadata.gz: 78f3ee18bb4decc88988138f4a27c967d3ae56a1
4
- data.tar.gz: c623b11567f78a13197f91ccc2bbf5ca19dd2f01
2
+ SHA256:
3
+ metadata.gz: 3ea2c713d50fac6bd342f46e18eb9ed8267ff65cfdbf6f1ee75c70bcc92d5b1c
4
+ data.tar.gz: fa3c04483562118a4d875edce0d8afbcac5cf3ee5fa29e8b5b8d04b374058b73
5
5
  SHA512:
6
- metadata.gz: cb1ea8f5d14c7526955427e96d4232758b6ec94772acf5b51fdc142a4d039c3d95f83d162196431fac663b67cb90dca7e8c5c8543a8eb611d65997086d5466dc
7
- data.tar.gz: 981fb532fd55a2ed1b371009fa869afeb1776096952f93f085631739c874be38a78dbd0acb16d6f4550a826e910abcc3f5474bc3166dd928b92b5da071e8d186
6
+ metadata.gz: 46aa4474a64b5b9e7e5c3ee53adf7804d618941528d0722e0bdff82e5010dc9f978d553ea5c7779d7917f26a9bc0e0f4c993bd74653d7f81b698abc9aabbcf9d
7
+ data.tar.gz: 9eaf669fef73e90a7dc4196939634f42c54f21471301c4913b9b46155feaf59a0755f88bf325a373d1242653fbe19e7f6d06fb4405e411a5e1aeef596a0b8713
@@ -1,9 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0
5
- - 2.1.0
6
- - 2.1
7
- - rbx-2
3
+ - 2.5
4
+ - 2.6
5
+ - 2.7
8
6
  # uncomment this line if your project needs to run something other than `rake`:
9
7
  # script: bundle exec rspec spec
@@ -1,3 +1,8 @@
1
+ 0.0.11 -- 22th June, 2020
2
+ * Updated rake & rdoc
3
+ * Updated Travis CI config
4
+ * ... honestly, just getting back to this repository
5
+
1
6
  0.0.9 -- 16th April, 2015
2
7
  * Removed unnecessary argument length check from jaccard_index.
3
8
  * Host documentation on rubydoc.info.
data/README.md CHANGED
@@ -15,7 +15,7 @@ NMatrix. Thank you, [@reddavis][reddavis]. :)
15
15
 
16
16
  `gem install measurable`
17
17
 
18
- This gem is currently being tested on MRI Ruby 1.9.3, 2.0, 2.1.0, 2.1 (HEAD) and on Rubinius 2.x (HEAD). I hope to add JRuby support in the future.
18
+ I test this gem (via Travis CI) on Ruby MRI 2.5, 2.6 and 2.7.
19
19
 
20
20
  ## Available distance measures
21
21
 
@@ -29,18 +29,20 @@ module Measurable
29
29
  intersection.length.to_f / union.length
30
30
  end
31
31
 
32
+ alias_method :jaccard, :jaccard_index
33
+
32
34
  # call-seq:
33
- # jaccard(u, v) -> Float
35
+ # jaccard_dissimilarity(u, v) -> Float
34
36
  #
35
37
  # The jaccard distance is a measure of dissimilarity between two sets. It is
36
38
  # calculated as:
37
39
  # jaccard_distance = 1 - jaccard_index
38
40
  #
39
41
  # This is a proper metric, i.e. the following conditions hold:
40
- # - Symmetry: jaccard(u, v) == jaccard(v, u)
41
- # - Non-negative: jaccard(u, v) >= 0
42
- # - Coincidence axiom: jaccard(u, v) == 0 if u == v
43
- # - Triangular inequality: jaccard(u, v) <= jaccard(u, w) + jaccard(w, v)
42
+ # - Symmetry: jaccard_dissimilarity(u, v) == jaccard(v, u)
43
+ # - Non-negative: jaccard_dissimilarity(u, v) >= 0
44
+ # - Coincidence axiom: jaccard_dissimilarity(u, v) == 0 if u == v
45
+ # - Triangular inequality: jaccard_dissimilarity(u, v) <= jaccard(u, w) + jaccard(w, v)
44
46
  #
45
47
  # Arguments:
46
48
  # - +u+ -> Array.
@@ -49,10 +51,12 @@ module Measurable
49
51
  # - Float value representing the dissimilarity between +u+ and +v+.
50
52
  # Raises:
51
53
  # - +ArgumentError+ -> The size of the input arrays doesn't match.
52
- def jaccard(u, v)
54
+ def jaccard_dissimilarity(u, v)
53
55
  1 - jaccard_index(u, v)
54
56
  end
55
57
 
58
+ alias_method :jaccard_distance, :jaccard_dissimilarity
59
+
56
60
  extend Measurable::Jaccard
57
61
  end
58
62
  end
@@ -1,3 +1,3 @@
1
1
  module Measurable
2
- VERSION = "0.0.9" # :nodoc:
2
+ VERSION = "0.0.11" # :nodoc:
3
3
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |gem|
24
24
  gem.required_ruby_version = '>= 1.9.3'
25
25
 
26
26
  gem.add_development_dependency 'bundler'
27
- gem.add_development_dependency 'rake', '~> 10.1'
28
- gem.add_development_dependency 'rdoc', '~> 4.1'
27
+ gem.add_development_dependency 'rake', '>= 12.3.3'
28
+ gem.add_development_dependency 'rdoc', '>= 6.0.0'
29
29
  gem.add_development_dependency 'rspec', '~> 3.2'
30
30
  end
@@ -15,12 +15,12 @@ describe "Chebyshev distance" do
15
15
  x = Measurable.chebyshev(@u, @v)
16
16
  y = Measurable.chebyshev(@v, @u)
17
17
 
18
- x.should be_within(TOLERANCE).of(y)
18
+ expect(x).to be_within(TOLERANCE).of(y)
19
19
  end
20
20
 
21
21
  it "should return the correct value" do
22
22
  x = Measurable.chebyshev(@u, @v)
23
- x.should be_within(TOLERANCE).of(3.1)
23
+ expect(x).to be_within(TOLERANCE).of(3.1)
24
24
  end
25
25
 
26
26
  it "shouldn't work with vectors of different length" do
@@ -33,7 +33,7 @@ describe "Chebyshev distance" do
33
33
  end
34
34
 
35
35
  x = klass.chebyshev(@u, @v)
36
- x.should be_within(TOLERANCE).of(3.1)
36
+ expect(x).to be_within(TOLERANCE).of(3.1)
37
37
  end
38
38
 
39
39
  it "can be included separately" do
@@ -42,7 +42,7 @@ describe "Chebyshev distance" do
42
42
  end
43
43
 
44
44
  x = klass.new.chebyshev(@u, @v)
45
- x.should be_within(TOLERANCE).of(3.1)
45
+ expect(x).to be_within(TOLERANCE).of(3.1)
46
46
  end
47
47
 
48
48
  end
@@ -16,17 +16,17 @@ describe "Jaccard" do
16
16
  x = Measurable.jaccard_index(@u, @v)
17
17
  y = Measurable.jaccard_index(@v, @u)
18
18
 
19
- x.should be_within(TOLERANCE).of(y)
19
+ expect(x).to be_within(TOLERANCE).of(y)
20
20
  end
21
21
 
22
22
  it "should return the correct value" do
23
23
  x = Measurable.jaccard_index(@u, @v)
24
24
 
25
- x.should be_within(TOLERANCE).of(1.0 / 2.0)
25
+ expect(x).to be_within(TOLERANCE).of(1.0 / 2.0)
26
26
  end
27
27
 
28
- it "shouldn't work with vectors of different length" do
29
- expect { Measurable.jaccard_index(@u, [1, 2, 3, 4]) }.to raise_error(ArgumentError)
28
+ it "should work with vectors of different length" do
29
+ expect { Measurable.jaccard_index(@u, [1, 2, 3, 4]) }.to_not raise_error
30
30
  end
31
31
 
32
32
  it "can be extended separately" do
@@ -36,7 +36,7 @@ describe "Jaccard" do
36
36
 
37
37
  x = klass.jaccard_index(@u, @v)
38
38
 
39
- x.should be_within(TOLERANCE).of(1.0 / 2.0)
39
+ expect(x).to be_within(TOLERANCE).of(1.0 / 2.0)
40
40
  end
41
41
 
42
42
  it "can be included separately" do
@@ -46,7 +46,7 @@ describe "Jaccard" do
46
46
 
47
47
  x = klass.new.jaccard_index(@u, @v)
48
48
 
49
- x.should be_within(TOLERANCE).of(1.0 / 2.0)
49
+ expect(x).to be_within(TOLERANCE).of(1.0 / 2.0)
50
50
  end
51
51
 
52
52
  end
@@ -59,25 +59,25 @@ describe "Jaccard" do
59
59
  end
60
60
 
61
61
  it "accepts two arguments" do
62
- expect { Measurable.jaccard(@u, @v) }.to_not raise_error
63
- expect { Measurable.jaccard(@u, @v, @w) }.to raise_error(ArgumentError)
62
+ expect { Measurable.jaccard_dissimilarity(@u, @v) }.to_not raise_error
63
+ expect { Measurable.jaccard_dissimilarity(@u, @v, @w) }.to raise_error(ArgumentError)
64
64
  end
65
65
 
66
66
  it "should be symmetric" do
67
- x = Measurable.jaccard(@u, @v)
68
- y = Measurable.jaccard(@v, @u)
67
+ x = Measurable.jaccard_dissimilarity(@u, @v)
68
+ y = Measurable.jaccard_dissimilarity(@v, @u)
69
69
 
70
- x.should be_within(TOLERANCE).of(y)
70
+ expect(x).to be_within(TOLERANCE).of(y)
71
71
  end
72
72
 
73
73
  it "should return the correct value" do
74
- x = Measurable.jaccard(@u, @v)
74
+ x = Measurable.jaccard_dissimilarity(@u, @v)
75
75
 
76
- x.should be_within(TOLERANCE).of(1.0 / 2.0)
76
+ expect(x).to be_within(TOLERANCE).of(1.0 / 2.0)
77
77
  end
78
78
 
79
- it "shouldn't work with vectors of different length" do
80
- expect { Measurable.jaccard(@u, [1, 2, 3, 4]) }.to raise_error(ArgumentError)
79
+ it "should work with vectors of different length" do
80
+ expect { Measurable.jaccard_dissimilarity(@u, [1, 2, 3, 4]) }.to_not raise_error
81
81
  end
82
82
  end
83
83
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: measurable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Agarie
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2020-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,30 +28,30 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.1'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.1'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '4.1'
47
+ version: 6.0.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '4.1'
54
+ version: 6.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -110,7 +110,7 @@ homepage: http://github.com/agarie/measurable
110
110
  licenses:
111
111
  - MIT
112
112
  metadata: {}
113
- post_install_message:
113
+ post_install_message:
114
114
  rdoc_options: []
115
115
  require_paths:
116
116
  - lib
@@ -125,9 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubyforge_project:
129
- rubygems_version: 2.4.5
130
- signing_key:
128
+ rubygems_version: 3.1.2
129
+ signing_key:
131
130
  specification_version: 4
132
131
  summary: A Ruby gem with a lot of distance measures for your projects.
133
132
  test_files: