rails-data-explorer 0.2.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -3
- data/README.md +2 -0
- data/lib/rails-data-explorer-no-rails.rb +36 -32
- data/lib/rails-data-explorer.rb +38 -35
- data/lib/rails_data_explorer.rb +29 -10
- data/lib/{rails-data-explorer → rails_data_explorer}/action_view_extension.rb +39 -17
- data/lib/rails_data_explorer/active_record_extension.rb +19 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/chart.rb +10 -0
- data/lib/rails_data_explorer/chart/anova.rb +1 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/box_plot.rb +12 -3
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/box_plot_group.rb +49 -22
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/contingency_table.rb +19 -8
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/descriptive_statistics_table.rb +9 -0
- data/lib/rails_data_explorer/chart/descriptive_statistics_table_group.rb +1 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/histogram_categorical.rb +12 -8
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/histogram_quantitative.rb +12 -2
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/histogram_temporal.rb +11 -2
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/multi_dimensional_charts.rb +2 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/parallel_coordinates.rb +11 -1
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/parallel_set.rb +11 -2
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/pie_chart.rb +12 -8
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/scatterplot.rb +13 -1
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/scatterplot_matrix.rb +2 -0
- data/lib/{rails-data-explorer/chart/stacked_bar_chart_categorical_percent.rb → rails_data_explorer/chart/stacked_bar_chart_categorical.rb} +37 -14
- data/lib/rails_data_explorer/chart/stacked_bar_chart_categorical_percent.rb +28 -0
- data/lib/rails_data_explorer/chart/stacked_histogram_temporal.rb +199 -0
- data/lib/rails_data_explorer/data_series.rb +241 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/data_set.rb +13 -4
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type.rb +13 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type/categorical.rb +79 -18
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type/geo.rb +2 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type/quantitative.rb +14 -4
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type/quantitative/decimal.rb +9 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type/quantitative/integer.rb +9 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type/quantitative/temporal.rb +9 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/engine.rb +12 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/exploration.rb +11 -0
- data/lib/rails_data_explorer/statistics/pearsons_chi_squared_independence_test.rb +72 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/statistics/rng_category.rb +13 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/statistics/rng_gaussian.rb +12 -1
- data/lib/{rails-data-explorer → rails_data_explorer}/statistics/rng_power_law.rb +11 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/utils/color_scale.rb +6 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/utils/data_binner.rb +13 -8
- data/lib/{rails-data-explorer → rails_data_explorer}/utils/data_encoder.rb +2 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/utils/data_quantizer.rb +8 -3
- data/lib/{rails-data-explorer → rails_data_explorer}/utils/rde_table.rb +14 -11
- data/lib/{rails-data-explorer → rails_data_explorer}/utils/value_formatter.rb +9 -4
- data/rails-data-explorer.gemspec +5 -6
- data/spec/rails_data_explorer/chart_spec.rb +11 -0
- data/spec/{rails-data-explorer → rails_data_explorer}/data_series_spec.rb +0 -0
- data/spec/rails_data_explorer/data_set_spec.rb +31 -0
- data/spec/rails_data_explorer/data_type/categorical_spec.rb +126 -0
- data/{lib/rails-data-explorer/chart/descriptive_statistics_table_group.rb → spec/rails_data_explorer/data_type/quantitative/decimal_spec.rb} +0 -0
- data/spec/rails_data_explorer/data_type/quantitative/integer_spec.rb +0 -0
- data/spec/rails_data_explorer/data_type/quantitative/temporal_spec.rb +34 -0
- data/spec/rails_data_explorer/data_type/quantitative_spec.rb +118 -0
- data/spec/rails_data_explorer/data_type_spec.rb +7 -0
- data/spec/{rails-data-explorer → rails_data_explorer}/exploration_spec.rb +5 -5
- data/spec/rails_data_explorer/statistics/pearsons_chi_squared_independence_test_spec.rb +0 -0
- data/spec/rails_data_explorer/utils/color_scale_spec.rb +13 -0
- data/spec/{rails-data-explorer → rails_data_explorer}/utils/data_binner_spec.rb +0 -0
- data/spec/{rails-data-explorer → rails_data_explorer}/utils/data_quantizer_spec.rb +0 -0
- data/spec/rails_data_explorer/utils/value_formatter_spec.rb +33 -0
- data/vendor/assets/stylesheets/sources/rde-default-style.css +5 -1
- metadata +91 -82
- data/lib/rails-data-explorer/active_record_extension.rb +0 -14
- data/lib/rails-data-explorer/constants.rb +0 -5
- data/lib/rails-data-explorer/data_series.rb +0 -156
- data/lib/rails-data-explorer/statistics/pearsons_chi_squared_independence_test.rb +0 -75
- data/spec/rails-data-explorer/data_type/categorical_spec.rb +0 -34
|
@@ -1,12 +1,23 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
1
3
|
class RailsDataExplorer
|
|
2
4
|
module Statistics
|
|
5
|
+
|
|
6
|
+
# Responsibilities:
|
|
7
|
+
# * Provide random numeric data, following a power distribution.
|
|
8
|
+
#
|
|
3
9
|
class RngPowerLaw
|
|
4
10
|
|
|
11
|
+
# @param min [Numeric]
|
|
12
|
+
# @param max [Numeric]
|
|
13
|
+
# @param pow [Numeric]
|
|
14
|
+
# @param rng [Proc, optional] a random number generator
|
|
5
15
|
def initialize(min = 1, max = 1000, pow = 2, rng = lambda { Kernel.rand })
|
|
6
16
|
@min, @max, @pow, @rng = min, max, pow, rng
|
|
7
17
|
@max += 1
|
|
8
18
|
end
|
|
9
19
|
|
|
20
|
+
# Returns random data following a power distribution.
|
|
10
21
|
def rand
|
|
11
22
|
y = (
|
|
12
23
|
(
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
# E.g., ages in years to 5 groups:
|
|
4
|
-
# * < 10
|
|
5
|
-
# * 11 - 20
|
|
6
|
-
# * 21 - 30
|
|
7
|
-
# * 31 - 40
|
|
8
|
-
# * > 40
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
9
3
|
class RailsDataExplorer
|
|
10
4
|
module Utils
|
|
5
|
+
|
|
6
|
+
# Responsibilities:
|
|
7
|
+
# * Convert quantitative data to categorical data.
|
|
8
|
+
#
|
|
9
|
+
# http://saedsayad.com/binning.htm
|
|
10
|
+
# E.g., ages in years to 5 groups:
|
|
11
|
+
# * < 10
|
|
12
|
+
# * 11 - 20
|
|
13
|
+
# * 21 - 30
|
|
14
|
+
# * 31 - 40
|
|
15
|
+
# * > 40
|
|
11
16
|
class DataBinner
|
|
12
17
|
|
|
13
18
|
# @param[Hash] threshold_specs a hash with a key value pair for each threshold
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
3
|
class RailsDataExplorer
|
|
4
4
|
module Utils
|
|
5
|
+
|
|
6
|
+
# Responsibilities:
|
|
7
|
+
# * Map a large set of quantitative/temporal/geo input values to a (countable)
|
|
8
|
+
# smaller set – such as rounding values to some unit of precision.
|
|
9
|
+
#
|
|
5
10
|
class DataQuantizer
|
|
6
11
|
|
|
7
12
|
attr_accessor :number_of_bins, :delta
|
|
@@ -10,7 +15,7 @@ class RailsDataExplorer
|
|
|
10
15
|
@options = {
|
|
11
16
|
nice: true,
|
|
12
17
|
type: 'midtread', # 'midtread' or 'midrise'
|
|
13
|
-
number_of_bins: 100, # assuming
|
|
18
|
+
number_of_bins: 100, # assuming 1000px wide chart, 10px per bin
|
|
14
19
|
delta: nil,
|
|
15
20
|
}.merge(options)
|
|
16
21
|
@data_series = data_series
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
#
|
|
2
|
-
# rde_table.rows
|
|
3
|
-
# rde_row.css_class
|
|
4
|
-
# rde_row.tag
|
|
5
|
-
# rde_row.cells
|
|
6
|
-
# rde_cell.css_class
|
|
7
|
-
# rde_cell.ruby_formatter
|
|
8
|
-
# rde_cell.style
|
|
9
|
-
# rde_cell.tag
|
|
10
|
-
# rde_cell.title
|
|
11
|
-
# rde_cell.value
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
12
2
|
|
|
13
3
|
class RailsDataExplorer
|
|
14
4
|
module Utils
|
|
15
5
|
|
|
6
|
+
# Responsibilities:
|
|
7
|
+
# * Provide classes to describe tables:
|
|
8
|
+
# rde_table.rows
|
|
9
|
+
# rde_row.css_class
|
|
10
|
+
# rde_row.tag
|
|
11
|
+
# rde_row.cells
|
|
12
|
+
# rde_cell.css_class
|
|
13
|
+
# rde_cell.ruby_formatter
|
|
14
|
+
# rde_cell.style
|
|
15
|
+
# rde_cell.tag
|
|
16
|
+
# rde_cell.title
|
|
17
|
+
# rde_cell.value
|
|
18
|
+
#
|
|
16
19
|
class RdeTable
|
|
17
20
|
|
|
18
21
|
attr_accessor :rows
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
# * http://www.edu.pe.ca/gray/class_pages/krcutcliffe/physics521/sigfigs/sigfigRULES.htm
|
|
4
|
-
# * http://en.wikipedia.org/wiki/Significant_figures
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
5
3
|
class RailsDataExplorer
|
|
6
4
|
module Utils
|
|
5
|
+
|
|
6
|
+
# Responsibilities:
|
|
7
|
+
# * Format values in data series and individual data
|
|
8
|
+
#
|
|
9
|
+
# Good resource on significant figures:
|
|
10
|
+
# * http://www.edu.pe.ca/gray/class_pages/krcutcliffe/physics521/sigfigs/sigfigRULES.htm
|
|
11
|
+
# * http://en.wikipedia.org/wiki/Significant_figures
|
|
7
12
|
class ValueFormatter
|
|
8
13
|
|
|
9
14
|
attr_accessor :d3_format, :ruby_formatter, :significant_figures
|
data/rails-data-explorer.gemspec
CHANGED
|
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |gem|
|
|
5
5
|
gem.name = 'rails-data-explorer'
|
|
6
|
-
gem.version = '0.
|
|
6
|
+
gem.version = '1.0.0'
|
|
7
7
|
gem.platform = Gem::Platform::RUBY
|
|
8
8
|
|
|
9
9
|
gem.authors = ['Jo Hund']
|
|
@@ -16,15 +16,14 @@ Gem::Specification.new do |gem|
|
|
|
16
16
|
gem.files = `git ls-files`.split("\n")
|
|
17
17
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
18
|
|
|
19
|
-
gem.add_dependency 'color'
|
|
20
|
-
gem.add_dependency 'descriptive-statistics'
|
|
21
|
-
gem.add_dependency 'distribution'
|
|
22
|
-
gem.add_dependency 'interpolate'
|
|
19
|
+
gem.add_dependency 'color', ['~> 1.7.1']
|
|
20
|
+
gem.add_dependency 'descriptive-statistics', ['~> 2.1.2']
|
|
21
|
+
gem.add_dependency 'distribution', ['~> 0.7.1']
|
|
22
|
+
gem.add_dependency 'interpolate', ['~> 0.3.0']
|
|
23
23
|
|
|
24
24
|
gem.add_development_dependency 'actionview', '>= 3.0.0'
|
|
25
25
|
gem.add_development_dependency 'bundler', ['>= 1.0.0']
|
|
26
26
|
gem.add_development_dependency 'minitest'
|
|
27
27
|
gem.add_development_dependency 'minitest-spec-expect'
|
|
28
28
|
gem.add_development_dependency 'rake', ['>= 0']
|
|
29
|
-
gem.add_development_dependency 'yui-compressor'
|
|
30
29
|
end
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require_relative '../helper_no_rails'
|
|
2
|
+
|
|
3
|
+
class RailsDataExplorer
|
|
4
|
+
describe DataSet do
|
|
5
|
+
|
|
6
|
+
let(:data_set) {
|
|
7
|
+
data_series_attrs = [
|
|
8
|
+
{ name: 'ds1', values: (1..6).to_a },
|
|
9
|
+
{ name: 'ds2', values: ('a'..'f').to_a },
|
|
10
|
+
]
|
|
11
|
+
DataSet.new(data_series_attrs, 'the title')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
it 'returns #data_series' do
|
|
15
|
+
data_set.data_series.count.must_equal 2
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'returns #number_of_values' do
|
|
19
|
+
data_set.number_of_values.must_equal 6
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'returns number of dimensions' do
|
|
23
|
+
data_set.dimensions_count.must_equal 2
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'returns data data_series_names' do
|
|
27
|
+
data_set.data_series_names.must_equal ["ds1", "ds2"]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
require_relative '../../helper_no_rails'
|
|
2
|
+
|
|
3
|
+
class RailsDataExplorer
|
|
4
|
+
class DataType
|
|
5
|
+
describe Categorical do
|
|
6
|
+
|
|
7
|
+
let(:dt) { Categorical.new }
|
|
8
|
+
let(:values) { ['a', 'a', 'b', 'c'] }
|
|
9
|
+
|
|
10
|
+
describe "#descriptive_statistics" do
|
|
11
|
+
|
|
12
|
+
let(:desc_stats) {
|
|
13
|
+
dt.descriptive_statistics(values)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it "computes count for each uniq val" do
|
|
17
|
+
desc_stats.detect{ |e| 'a_count' == e[:label] }[:value].must_equal 2
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "computes percent for each uniq val" do
|
|
21
|
+
desc_stats.detect{ |e| 'a_percent' == e[:label] }[:value].must_equal 50.0
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "computes total count" do
|
|
25
|
+
desc_stats.detect{ |e| '[Total]_count' == e[:label] }[:value].must_equal 4
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "#available_chart_types" do
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe '#label_sorter' do
|
|
33
|
+
|
|
34
|
+
it 'sorts numerical labels with greater and less than signs' do
|
|
35
|
+
labels = ['3', '< -1', '2', '1', '0', '> 3', '-1']
|
|
36
|
+
ds = DataSeries.new('_', labels)
|
|
37
|
+
labels.sort(
|
|
38
|
+
&Categorical.new.label_sorter(nil, ds, '_')
|
|
39
|
+
).must_equal(['< -1', '-1', '0', '1', '2', '3', '> 3'])
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'sorts mixed numerical and non-numerical labels with non-num at the end' do
|
|
43
|
+
labels = ['3', '2', '[Other]', '1']
|
|
44
|
+
ds = DataSeries.new('_', labels)
|
|
45
|
+
labels.sort(
|
|
46
|
+
&Categorical.new.label_sorter(nil, ds, '_')
|
|
47
|
+
).must_equal(['1', '2', '3', '[Other]'])
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'accesses label_val_key if given' do
|
|
51
|
+
labels = ['2', '1']
|
|
52
|
+
ds = DataSeries.new('_', labels)
|
|
53
|
+
labels.map { |e| { x: e } }.sort(
|
|
54
|
+
&Categorical.new.label_sorter(:x, ds, '_')
|
|
55
|
+
).must_equal([{ x: '1' }, { x: '2' }])
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '#limit_distinct_values' do
|
|
61
|
+
|
|
62
|
+
let(:vals) {
|
|
63
|
+
%w[
|
|
64
|
+
a a a a a a a a a a a a a
|
|
65
|
+
b b b b
|
|
66
|
+
c
|
|
67
|
+
d
|
|
68
|
+
e e e e e
|
|
69
|
+
f f f f f f f
|
|
70
|
+
g
|
|
71
|
+
h h h h
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
it 'reduces large number of observations to smaller number' do
|
|
76
|
+
Categorical.new.limit_distinct_values(vals, 4).must_equal(
|
|
77
|
+
%w[
|
|
78
|
+
a a a a a a a a a a a a a
|
|
79
|
+
[Other] [Other] [Other] [Other]
|
|
80
|
+
[Other]
|
|
81
|
+
[Other]
|
|
82
|
+
e e e e e
|
|
83
|
+
f f f f f f f
|
|
84
|
+
[Other]
|
|
85
|
+
[Other] [Other] [Other] [Other]
|
|
86
|
+
]
|
|
87
|
+
)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'allows override for val_for_others' do
|
|
91
|
+
Categorical.new.limit_distinct_values(
|
|
92
|
+
vals, 4, 'override'
|
|
93
|
+
).must_equal(
|
|
94
|
+
%w[
|
|
95
|
+
a a a a a a a a a a a a a
|
|
96
|
+
override override override override
|
|
97
|
+
override
|
|
98
|
+
override
|
|
99
|
+
e e e e e
|
|
100
|
+
f f f f f f f
|
|
101
|
+
override
|
|
102
|
+
override override override override
|
|
103
|
+
]
|
|
104
|
+
)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'uses label value as tie breaker on equal frequencies' do
|
|
108
|
+
Categorical.new.limit_distinct_values(vals, 5).must_equal(
|
|
109
|
+
%w[
|
|
110
|
+
a a a a a a a a a a a a a
|
|
111
|
+
b b b b
|
|
112
|
+
[Other]
|
|
113
|
+
[Other]
|
|
114
|
+
e e e e e
|
|
115
|
+
f f f f f f f
|
|
116
|
+
[Other]
|
|
117
|
+
[Other] [Other] [Other] [Other]
|
|
118
|
+
]
|
|
119
|
+
)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require_relative '../../../helper_no_rails'
|
|
2
|
+
|
|
3
|
+
class RailsDataExplorer
|
|
4
|
+
class DataType
|
|
5
|
+
class Quantitative
|
|
6
|
+
describe Temporal do
|
|
7
|
+
|
|
8
|
+
let(:dt) { Temporal.new }
|
|
9
|
+
let(:values) { [DateTime.new(2015, 02, 06), DateTime.new(2015, 02, 07)] }
|
|
10
|
+
|
|
11
|
+
describe "#descriptive_statistics" do
|
|
12
|
+
|
|
13
|
+
let(:desc_stats) {
|
|
14
|
+
dt.descriptive_statistics(values)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
it "computes 'Min'" do
|
|
18
|
+
desc_stats.detect { |e| 'Min' == e[:label] }[:value].must_equal DateTime.new(2015, 02, 06)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "computes 'Max'" do
|
|
22
|
+
desc_stats.detect { |e| 'Max' == e[:label] }[:value].must_equal DateTime.new(2015, 02, 07)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "computes 'Count'" do
|
|
26
|
+
desc_stats.detect { |e| 'Count' == e[:label] }[:value].must_equal 2
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
require_relative '../../helper_no_rails'
|
|
2
|
+
|
|
3
|
+
class RailsDataExplorer
|
|
4
|
+
class DataType
|
|
5
|
+
describe Quantitative do
|
|
6
|
+
|
|
7
|
+
let(:dt) { Quantitative.new }
|
|
8
|
+
let(:values) { (1..101).to_a }
|
|
9
|
+
|
|
10
|
+
describe "#descriptive_statistics" do
|
|
11
|
+
|
|
12
|
+
let(:desc_stats) {
|
|
13
|
+
dt.descriptive_statistics(values)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it "computes 'Min'" do
|
|
17
|
+
desc_stats.detect { |e| 'Min' == e[:label] }[:value].must_equal 1
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "computes '1%ile'" do
|
|
21
|
+
desc_stats.detect { |e| '1%ile' == e[:label] }[:value].must_equal 3
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "computes '5%ile'" do
|
|
25
|
+
desc_stats.detect { |e| '5%ile' == e[:label] }[:value].must_equal 7
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "computes '10%ile'" do
|
|
29
|
+
desc_stats.detect { |e| '10%ile' == e[:label] }[:value].must_equal 12
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "computes '25%ile'" do
|
|
33
|
+
desc_stats.detect { |e| '25%ile' == e[:label] }[:value].must_equal 27
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "computes 'Median'" do
|
|
37
|
+
desc_stats.detect { |e| 'Median' == e[:label] }[:value].must_equal 51
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "computes '75%ile'" do
|
|
41
|
+
desc_stats.detect { |e| '75%ile' == e[:label] }[:value].must_equal 77
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "computes '90%ile'" do
|
|
45
|
+
desc_stats.detect { |e| '90%ile' == e[:label] }[:value].must_equal 92
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "computes '95%ile'" do
|
|
49
|
+
desc_stats.detect { |e| '95%ile' == e[:label] }[:value].must_equal 97
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "computes '99%ile'" do
|
|
53
|
+
desc_stats.detect { |e| '99%ile' == e[:label] }[:value].must_equal 101
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "computes 'Max'" do
|
|
57
|
+
desc_stats.detect { |e| 'Max' == e[:label] }[:value].must_equal 101
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "computes 'Range'" do
|
|
61
|
+
desc_stats.detect { |e| 'Range' == e[:label] }[:value].must_equal 100
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "computes 'Mean'" do
|
|
65
|
+
desc_stats.detect { |e| 'Mean' == e[:label] }[:value].must_equal 51
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "computes 'Mode'" do
|
|
69
|
+
desc_stats.detect { |e| 'Mode' == e[:label] }[:value].must_equal nil
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "computes 'Count'" do
|
|
73
|
+
desc_stats.detect { |e| 'Count' == e[:label] }[:value].must_equal 101
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "computes 'Sum'" do
|
|
77
|
+
desc_stats.detect { |e| 'Sum' == e[:label] }[:value].must_equal 5151
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "computes 'Variance'" do
|
|
81
|
+
desc_stats.detect { |e| 'Variance' == e[:label] }[:value].must_equal 858.5
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "computes 'Std. dev.'" do
|
|
85
|
+
desc_stats.detect { |e| 'Std. dev.' == e[:label] }[:value].must_equal 29.300170647967224
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "computes 'Rel. std. dev.'" do
|
|
89
|
+
desc_stats.detect { |e| 'Rel. std. dev.' == e[:label] }[:value].must_equal 57.166195047502946
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "computes 'Skewness'" do
|
|
93
|
+
desc_stats.detect { |e| 'Skewness' == e[:label] }[:value].must_equal 0.0
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "computes 'Kurtosis'" do
|
|
97
|
+
desc_stats.detect { |e| 'Kurtosis' == e[:label] }[:value].must_equal 1.781945253348864
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe '#axis_scale' do
|
|
103
|
+
|
|
104
|
+
it 'determines linear' do
|
|
105
|
+
ds = DataSeries.new('_', [1, 1_000])
|
|
106
|
+
Quantitative.new.axis_scale(ds, {}, :vega).must_equal 'linear'
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'determines log' do
|
|
110
|
+
ds = DataSeries.new('_', [1, 1_000_000])
|
|
111
|
+
Quantitative.new.axis_scale(ds, {}, :vega).must_equal 'log'
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|