aggregate 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aggregate/version.rb +1 -1
- data/lib/aggregate.rb +4 -4
- data/test/ts_aggregate.rb +5 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 443886b0ec9c5942e00bcf724b9fb867828d896cae4d0691682b94f0c9907f09
|
4
|
+
data.tar.gz: e9623280785d01741cc7b07a26528e64f9f273492a9cd202d2b94e9478def21a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e960a849a22191f5c9f964ef4365ba2a73389aa43cfba38a3879cfcdea4d3f8c4cd6de64cacaeb2310c7dee4fd95d284a1805c8515f12fc27560c0a54499277
|
7
|
+
data.tar.gz: 8110ec772721e648025c8e15ed3fa0f941d04a1884d7309ffd30ccf54e7b66294421c04e26d50f4f218bbf5c39f8e8c31ddb3d0af3e42e872185f01cdecf6a52
|
data/lib/aggregate/version.rb
CHANGED
data/lib/aggregate.rb
CHANGED
@@ -26,7 +26,7 @@ class Aggregate
|
|
26
26
|
# Create a new Aggregate that maintains a binary logarithmic histogram
|
27
27
|
# by default. Specifying values for low, high, and width configures
|
28
28
|
# the aggregate to maintain a linear histogram with (high - low)/width buckets
|
29
|
-
def initialize
|
29
|
+
def initialize(low=nil, high=nil, width=nil)
|
30
30
|
@count = 0
|
31
31
|
@sum = 0.0
|
32
32
|
@sum2 = 0.0
|
@@ -204,7 +204,7 @@ class Aggregate
|
|
204
204
|
nil != @width
|
205
205
|
end
|
206
206
|
|
207
|
-
def outlier?
|
207
|
+
def outlier?(data)
|
208
208
|
|
209
209
|
if data < @low
|
210
210
|
@outliers_low += 1
|
@@ -231,7 +231,7 @@ class Aggregate
|
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
234
|
-
def right_bucket?
|
234
|
+
def right_bucket?(index, data)
|
235
235
|
|
236
236
|
# check invariant
|
237
237
|
raise unless linear?
|
@@ -262,7 +262,7 @@ class Aggregate
|
|
262
262
|
# A data point is added to the bucket[n] where the data point
|
263
263
|
# is less than the value represented by bucket[n], but greater
|
264
264
|
# than the value represented by bucket[n+1]
|
265
|
-
def to_index
|
265
|
+
def to_index(data)
|
266
266
|
|
267
267
|
# basic case is simple
|
268
268
|
return log2(data).to_i if !linear?
|
data/test/ts_aggregate.rb
CHANGED
@@ -38,7 +38,7 @@ class SimpleStatsTest < MiniTest::Test
|
|
38
38
|
i = 0
|
39
39
|
@stats.each do |bucket, count|
|
40
40
|
assert_equal 2**i, bucket
|
41
|
-
|
41
|
+
|
42
42
|
total_bucket_sum += count
|
43
43
|
i += 1
|
44
44
|
end
|
@@ -129,16 +129,16 @@ class LinearHistogramTest < MiniTest::Test
|
|
129
129
|
def test_validation
|
130
130
|
|
131
131
|
# Range cannot be 0
|
132
|
-
assert_raises(ArgumentError) {
|
132
|
+
assert_raises(ArgumentError) { Aggregate.new(32,32,4) }
|
133
133
|
|
134
134
|
# Range cannot be negative
|
135
|
-
assert_raises(ArgumentError) {
|
135
|
+
assert_raises(ArgumentError) { Aggregate.new(32,16,4) }
|
136
136
|
|
137
137
|
# Range cannot be < single bucket
|
138
|
-
assert_raises(ArgumentError) {
|
138
|
+
assert_raises(ArgumentError) { Aggregate.new(16,32,17) }
|
139
139
|
|
140
140
|
# Range % width must equal 0 (for now)
|
141
|
-
assert_raises(ArgumentError) {
|
141
|
+
assert_raises(ArgumentError) { Aggregate.new(1,16384,1024) }
|
142
142
|
end
|
143
143
|
|
144
144
|
#XXX: Update test_bucket_contents() if you muck with @@DATA
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aggregate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Ruscio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Aggregate is a Ruby class for accumulating aggregate statistics and
|
14
14
|
includes histogram support. For a detailed README see: http://github.com/josephruscio/aggregate'
|
@@ -44,7 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
requirements: []
|
47
|
-
rubygems_version: 3.
|
47
|
+
rubygems_version: 3.3.26
|
48
48
|
signing_key:
|
49
49
|
specification_version: 3
|
50
50
|
summary: Aggregate is a Ruby class for accumulating aggregate statistics and includes
|