histogram 0.2.1.4 → 0.2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/histogram.rb +3 -1
- data/lib/histogram/version.rb +1 -1
- data/spec/histogram_spec.rb +10 -1
- metadata +51 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50a58993942b0878e8dbe58afc139a880d094a33
|
4
|
+
data.tar.gz: 0ff8419d39eae42dddb713cecc00c8b4e76f73a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4d286bb8e206c0121149ede1f464c5ad8807cbcd2076a3c73b1b2e5add968c55c9dd087168afedd45f0718584897c99e39c3b98d80196b3414a8ed9b5d51313
|
7
|
+
data.tar.gz: a224cd19415ebb82a5222601fb0a44fb85edd7f1c0568bdddca13a0aa93417ee312628384ee7da110cfe1ef3bd50bd004e03a034d0e49994496d52e3761399ae
|
data/README.md
CHANGED
@@ -65,6 +65,7 @@ Big thanks to those who have made contributions!
|
|
65
65
|
|
66
66
|
* deal with zero std ([Greg Dean](https://github.com/gsdean))
|
67
67
|
* support for 1.8.7 and jruby ([Kiera Radman](https://github.com/kierarad))
|
68
|
+
* reorder nan checks (fix zero stdev arrays) [arjun810](https://github.com/arjun810)
|
68
69
|
|
69
70
|
## See Also
|
70
71
|
|
data/lib/histogram.rb
CHANGED
@@ -53,6 +53,7 @@ module Histogram
|
|
53
53
|
opt = {:method => DEFAULT_QUARTILE_METHOD, :sorted => false}.merge( opts )
|
54
54
|
srted = opt[:sorted] ? obj : obj.sort
|
55
55
|
sz = srted.size
|
56
|
+
return 0 if sz == 1
|
56
57
|
answer =
|
57
58
|
case opt[:method]
|
58
59
|
when :tukey
|
@@ -72,6 +73,7 @@ module Histogram
|
|
72
73
|
|
73
74
|
# finds median on a pre-sorted array
|
74
75
|
def median(sorted)
|
76
|
+
return sorted[0] if sorted.size == 1
|
75
77
|
(sorted[(sorted.size - 1) / 2] + sorted[sorted.size / 2]) / 2.0
|
76
78
|
end
|
77
79
|
end
|
@@ -99,8 +101,8 @@ module Histogram
|
|
99
101
|
when :fd
|
100
102
|
2 * Histogram.iqrange(self, :method => quartile_method) * (self.size**(-1.0/3))
|
101
103
|
end
|
102
|
-
nbins = 1 if nbins <= 0
|
103
104
|
nbins = 1 if nbins.nan?
|
105
|
+
nbins = 1 if nbins <= 0
|
104
106
|
nbins.ceil.to_i
|
105
107
|
end
|
106
108
|
end
|
data/lib/histogram/version.rb
CHANGED
data/spec/histogram_spec.rb
CHANGED
@@ -98,6 +98,14 @@ shared_examples 'something that can histogram' do
|
|
98
98
|
bins, freq = obj6.histogram
|
99
99
|
end
|
100
100
|
|
101
|
+
it 'can handle 0 stddev for :middle' do
|
102
|
+
bins, freq = obj6.histogram(:middle)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'can handle an array of length 1' do
|
106
|
+
bins, freq = obj7.histogram(:middle)
|
107
|
+
end
|
108
|
+
|
101
109
|
end
|
102
110
|
|
103
111
|
describe Histogram do
|
@@ -108,7 +116,8 @@ describe Histogram do
|
|
108
116
|
:obj3 => [1, 1, 2, 2, 3, 3, 4, 4, 4],
|
109
117
|
:obj4 => [2, 2, 2, 2, 2, 4],
|
110
118
|
:obj5 => [1,2,3,3,3,4,5,6,7,8],
|
111
|
-
:obj6 => [0,0,0,0,0]
|
119
|
+
:obj6 => [0,0,0,0,0],
|
120
|
+
:obj7 => [0]
|
112
121
|
}
|
113
122
|
data = tmp.each {|k,v| [k, v.map(&:to_f).extend(Histogram)] }
|
114
123
|
|
metadata
CHANGED
@@ -1,85 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: histogram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John T. Prince
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
|
-
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
|
-
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
23
|
requirements:
|
22
|
-
- - ~>
|
24
|
+
- - "~>"
|
23
25
|
- !ruby/object:Gem::Version
|
24
26
|
version: '1.3'
|
25
|
-
prerelease: false
|
26
|
-
type: :development
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
|
-
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 10.1.0
|
34
|
-
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
35
37
|
requirements:
|
36
|
-
- - ~>
|
38
|
+
- - "~>"
|
37
39
|
- !ruby/object:Gem::Version
|
38
40
|
version: 10.1.0
|
39
|
-
prerelease: false
|
40
|
-
type: :development
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: simplecov
|
43
|
-
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.7.1
|
48
|
-
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
51
|
requirements:
|
50
|
-
- - ~>
|
52
|
+
- - "~>"
|
51
53
|
- !ruby/object:Gem::Version
|
52
54
|
version: 0.7.1
|
53
|
-
prerelease: false
|
54
|
-
type: :development
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
|
-
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 2.13.0
|
62
|
-
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
65
|
requirements:
|
64
|
-
- - ~>
|
66
|
+
- - "~>"
|
65
67
|
- !ruby/object:Gem::Version
|
66
68
|
version: 2.13.0
|
67
|
-
prerelease: false
|
68
|
-
type: :development
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rdoc
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
71
78
|
version_requirements: !ruby/object:Gem::Requirement
|
72
79
|
requirements:
|
73
|
-
- -
|
80
|
+
- - ">="
|
74
81
|
- !ruby/object:Gem::Version
|
75
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: narray
|
76
85
|
requirement: !ruby/object:Gem::Requirement
|
77
86
|
requirements:
|
78
|
-
- -
|
87
|
+
- - ">="
|
79
88
|
- !ruby/object:Gem::Version
|
80
89
|
version: '0'
|
81
|
-
prerelease: false
|
82
90
|
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: gives objects the ability to 'histogram' in several useful ways
|
84
98
|
email:
|
85
99
|
- jtprince@gmail.com
|
@@ -88,7 +102,7 @@ executables:
|
|
88
102
|
extensions: []
|
89
103
|
extra_rdoc_files: []
|
90
104
|
files:
|
91
|
-
- .gitignore
|
105
|
+
- ".gitignore"
|
92
106
|
- Gemfile
|
93
107
|
- LICENSE
|
94
108
|
- README.md
|
@@ -106,24 +120,24 @@ homepage: https://github.com/jtprince/histogram
|
|
106
120
|
licenses:
|
107
121
|
- MIT
|
108
122
|
metadata: {}
|
109
|
-
post_install_message:
|
123
|
+
post_install_message:
|
110
124
|
rdoc_options: []
|
111
125
|
require_paths:
|
112
126
|
- lib
|
113
127
|
required_ruby_version: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- -
|
129
|
+
- - ">="
|
116
130
|
- !ruby/object:Gem::Version
|
117
131
|
version: '0'
|
118
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
133
|
requirements:
|
120
|
-
- -
|
134
|
+
- - ">="
|
121
135
|
- !ruby/object:Gem::Version
|
122
136
|
version: '0'
|
123
137
|
requirements: []
|
124
|
-
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
126
|
-
signing_key:
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.2.2
|
140
|
+
signing_key:
|
127
141
|
specification_version: 4
|
128
142
|
summary: histograms data in different ways
|
129
143
|
test_files:
|