lite-statistics 1.0.4 → 1.2.0

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
2
  SHA256:
3
- metadata.gz: 49b18fb367a9702f9aa7253b8a6f50b6536ef1e4cad177f0bdba2d8d207ca069
4
- data.tar.gz: 5e63a6d3c6f6e4276379638a7d67791aad8f49504c4c7ac2c99f0d5faf7953c4
3
+ metadata.gz: a8d825f336380fddde691b041da67751df05101d1dd452eb334cb3f37c6a4a8c
4
+ data.tar.gz: bc28a499f0565d127be3039074beb152687c6d5d8e0824af1f86eb436cd389b9
5
5
  SHA512:
6
- metadata.gz: ca8ec918047e496c990f5a317167e353939c303affb7b32eb93193a28b8c18f1b1ea924f50bfa53fbbcf8b92cae0bd577e53f3fa3e806487b061790653c0f6e2
7
- data.tar.gz: 7f819820a89cb88bc977a535df475cc021de63ff508ab301fac94c4d32e799db40aa2cf9b47cb54cf2dff5b358283ec78508c9f6ac03b064338d4285016c420b
6
+ metadata.gz: 40d1e2a1aa2e7702258c22fcecb9cf0fc706dca2284ae6af95465e90cd1c5450555761040ad22aa79f85cc0dbf88349f9021bcbba322dff2235965a69c3e3813
7
+ data.tar.gz: 7448f5cf419f2ba60633ceb2e7418397cc958f0c44871f136e224224d841dd8b7242708a5dc52ce5fc6baf2e86b0114cd5fddd093d41476b0d06580e8975e5d2
data/.rubocop.yml CHANGED
@@ -1,12 +1,16 @@
1
1
  require:
2
2
  - rubocop-performance
3
+ - rubocop-rake
3
4
  - rubocop-rspec
4
5
  AllCops:
5
- TargetRubyVersion: 2.6
6
+ TargetRubyVersion: 3.0
7
+ NewCops: enable
6
8
  DisplayCopNames: true
7
9
  DisplayStyleGuide: true
8
- LineLength:
9
- Max: 100
10
+ Gemspec/RequiredRubyVersion:
11
+ Enabled: false
12
+ Layout/EmptyLinesAroundAttributeAccessor:
13
+ Enabled: true
10
14
  Layout/EmptyLinesAroundBlockBody:
11
15
  Exclude:
12
16
  - 'spec/**/**/*'
@@ -14,12 +18,22 @@ Layout/EmptyLinesAroundClassBody:
14
18
  EnforcedStyle: empty_lines_except_namespace
15
19
  Layout/EmptyLinesAroundModuleBody:
16
20
  EnforcedStyle: empty_lines_except_namespace
21
+ Layout/LineLength:
22
+ Max: 100
23
+ Layout/SpaceAroundMethodCallOperator:
24
+ Enabled: true
25
+ Lint/RaiseException:
26
+ Enabled: true
27
+ Lint/StructNewOverride:
28
+ Enabled: true
17
29
  Metrics/BlockLength:
18
30
  Enabled: false
19
31
  Metrics/ClassLength:
20
32
  Enabled: false
21
33
  Naming/FileName:
22
34
  Enabled: false
35
+ Style/ArgumentsForwarding:
36
+ Enabled: false
23
37
  Style/Documentation:
24
38
  Enabled: false
25
39
  Style/ExpandPathArguments:
data/.travis.yml CHANGED
@@ -4,6 +4,7 @@ cache: bundler
4
4
  rvm:
5
5
  - 2.5
6
6
  - 2.6
7
+ - 2.7
7
8
  - ruby-head
8
9
  matrix:
9
10
  fast_finish: true
data/CHANGELOG.md CHANGED
@@ -6,6 +6,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.2.0] - 2021-07-19
10
+ ### Added
11
+ - Added Ruby 3.0 support
12
+
13
+ ## [1.1.1] - 2019-07-05
14
+ ### Changed
15
+ - Linter fixes
16
+
17
+ ## [1.1.0] - 2019-06-06
18
+ ### Changed
19
+ - Removed underscore of quartile numbers
20
+
21
+ ## [1.0.5] - 2019-08-24
22
+ ### Added
23
+ - Added ruby 2.7 support
24
+ ### Changed
25
+ - Improved how configuration works
26
+
9
27
  ## [1.0.4] - 2019-08-17
10
28
  ### Changed
11
29
  - Add check for monkey patches
data/Gemfile.lock CHANGED
@@ -1,107 +1,119 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-statistics (1.0.4)
4
+ lite-statistics (1.2.0)
5
5
  lite-memoize
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionpack (5.2.3)
11
- actionview (= 5.2.3)
12
- activesupport (= 5.2.3)
13
- rack (~> 2.0)
10
+ actionpack (6.1.4)
11
+ actionview (= 6.1.4)
12
+ activesupport (= 6.1.4)
13
+ rack (~> 2.0, >= 2.0.9)
14
14
  rack-test (>= 0.6.3)
15
15
  rails-dom-testing (~> 2.0)
16
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
- actionview (5.2.3)
18
- activesupport (= 5.2.3)
16
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
17
+ actionview (6.1.4)
18
+ activesupport (= 6.1.4)
19
19
  builder (~> 3.1)
20
20
  erubi (~> 1.4)
21
21
  rails-dom-testing (~> 2.0)
22
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
23
- activesupport (5.2.3)
22
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
23
+ activesupport (6.1.4)
24
24
  concurrent-ruby (~> 1.0, >= 1.0.2)
25
- i18n (>= 0.7, < 2)
26
- minitest (~> 5.1)
27
- tzinfo (~> 1.1)
28
- ast (2.4.0)
29
- builder (3.2.3)
25
+ i18n (>= 1.6, < 2)
26
+ minitest (>= 5.1)
27
+ tzinfo (~> 2.0)
28
+ zeitwerk (~> 2.3)
29
+ ast (2.4.2)
30
+ builder (3.2.4)
30
31
  colorize (0.8.1)
31
- concurrent-ruby (1.1.5)
32
- crass (1.0.4)
33
- diff-lcs (1.3)
34
- erubi (1.8.0)
35
- fasterer (0.6.0)
32
+ concurrent-ruby (1.1.9)
33
+ crass (1.0.6)
34
+ diff-lcs (1.4.4)
35
+ erubi (1.10.0)
36
+ fasterer (0.9.0)
36
37
  colorize (~> 0.7)
37
- ruby_parser (>= 3.13.0)
38
+ ruby_parser (>= 3.14.1)
38
39
  generator_spec (0.9.4)
39
40
  activesupport (>= 3.0.0)
40
41
  railties (>= 3.0.0)
41
- i18n (1.6.0)
42
+ i18n (1.8.10)
42
43
  concurrent-ruby (~> 1.0)
43
- jaro_winkler (1.5.3)
44
- lite-memoize (1.0.3)
45
- loofah (2.2.3)
44
+ lite-memoize (1.1.0)
45
+ loofah (2.10.0)
46
46
  crass (~> 1.0.2)
47
47
  nokogiri (>= 1.5.9)
48
- method_source (0.9.2)
49
- mini_portile2 (2.4.0)
50
- minitest (5.11.3)
51
- nokogiri (1.10.4)
52
- mini_portile2 (~> 2.4.0)
53
- parallel (1.17.0)
54
- parser (2.6.3.0)
55
- ast (~> 2.4.0)
56
- rack (2.0.7)
48
+ method_source (1.0.0)
49
+ mini_portile2 (2.5.3)
50
+ minitest (5.14.4)
51
+ nokogiri (1.11.7)
52
+ mini_portile2 (~> 2.5.0)
53
+ racc (~> 1.4)
54
+ parallel (1.20.1)
55
+ parser (3.0.2.0)
56
+ ast (~> 2.4.1)
57
+ racc (1.5.2)
58
+ rack (2.2.3)
57
59
  rack-test (1.1.0)
58
60
  rack (>= 1.0, < 3)
59
61
  rails-dom-testing (2.0.3)
60
62
  activesupport (>= 4.2.0)
61
63
  nokogiri (>= 1.6)
62
- rails-html-sanitizer (1.2.0)
63
- loofah (~> 2.2, >= 2.2.2)
64
- railties (5.2.3)
65
- actionpack (= 5.2.3)
66
- activesupport (= 5.2.3)
64
+ rails-html-sanitizer (1.3.0)
65
+ loofah (~> 2.3)
66
+ railties (6.1.4)
67
+ actionpack (= 6.1.4)
68
+ activesupport (= 6.1.4)
67
69
  method_source
68
- rake (>= 0.8.7)
69
- thor (>= 0.19.0, < 2.0)
70
+ rake (>= 0.13)
71
+ thor (~> 1.0)
70
72
  rainbow (3.0.0)
71
- rake (12.3.3)
72
- rspec (3.8.0)
73
- rspec-core (~> 3.8.0)
74
- rspec-expectations (~> 3.8.0)
75
- rspec-mocks (~> 3.8.0)
76
- rspec-core (3.8.2)
77
- rspec-support (~> 3.8.0)
78
- rspec-expectations (3.8.4)
73
+ rake (13.0.6)
74
+ regexp_parser (2.1.1)
75
+ rexml (3.2.5)
76
+ rspec (3.10.0)
77
+ rspec-core (~> 3.10.0)
78
+ rspec-expectations (~> 3.10.0)
79
+ rspec-mocks (~> 3.10.0)
80
+ rspec-core (3.10.1)
81
+ rspec-support (~> 3.10.0)
82
+ rspec-expectations (3.10.1)
79
83
  diff-lcs (>= 1.2.0, < 2.0)
80
- rspec-support (~> 3.8.0)
81
- rspec-mocks (3.8.1)
84
+ rspec-support (~> 3.10.0)
85
+ rspec-mocks (3.10.2)
82
86
  diff-lcs (>= 1.2.0, < 2.0)
83
- rspec-support (~> 3.8.0)
84
- rspec-support (3.8.2)
85
- rubocop (0.74.0)
86
- jaro_winkler (~> 1.5.1)
87
+ rspec-support (~> 3.10.0)
88
+ rspec-support (3.10.2)
89
+ rubocop (1.18.3)
87
90
  parallel (~> 1.10)
88
- parser (>= 2.6)
91
+ parser (>= 3.0.0.0)
89
92
  rainbow (>= 2.2.2, < 4.0)
93
+ regexp_parser (>= 1.8, < 3.0)
94
+ rexml
95
+ rubocop-ast (>= 1.7.0, < 2.0)
90
96
  ruby-progressbar (~> 1.7)
91
- unicode-display_width (>= 1.4.0, < 1.7)
92
- rubocop-performance (1.4.1)
93
- rubocop (>= 0.71.0)
94
- rubocop-rspec (1.35.0)
95
- rubocop (>= 0.60.0)
96
- ruby-progressbar (1.10.1)
97
- ruby_parser (3.13.1)
98
- sexp_processor (~> 4.9)
99
- sexp_processor (4.12.1)
100
- thor (0.20.3)
101
- thread_safe (0.3.6)
102
- tzinfo (1.2.5)
103
- thread_safe (~> 0.1)
104
- unicode-display_width (1.6.0)
97
+ unicode-display_width (>= 1.4.0, < 3.0)
98
+ rubocop-ast (1.8.0)
99
+ parser (>= 3.0.1.1)
100
+ rubocop-performance (1.11.4)
101
+ rubocop (>= 1.7.0, < 2.0)
102
+ rubocop-ast (>= 0.4.0)
103
+ rubocop-rake (0.6.0)
104
+ rubocop (~> 1.0)
105
+ rubocop-rspec (2.4.0)
106
+ rubocop (~> 1.0)
107
+ rubocop-ast (>= 1.1.0)
108
+ ruby-progressbar (1.11.0)
109
+ ruby_parser (3.16.0)
110
+ sexp_processor (~> 4.15, >= 4.15.1)
111
+ sexp_processor (4.15.3)
112
+ thor (1.1.0)
113
+ tzinfo (2.0.4)
114
+ concurrent-ruby (~> 1.0)
115
+ unicode-display_width (2.0.0)
116
+ zeitwerk (2.4.2)
105
117
 
106
118
  PLATFORMS
107
119
  ruby
@@ -115,7 +127,8 @@ DEPENDENCIES
115
127
  rspec
116
128
  rubocop
117
129
  rubocop-performance
130
+ rubocop-rake
118
131
  rubocop-rspec
119
132
 
120
133
  BUNDLED WITH
121
- 2.0.1
134
+ 2.2.24
data/benchmarks/base.rb CHANGED
@@ -13,9 +13,9 @@ def ls_baseline_summary(data)
13
13
  median: data.median,
14
14
  min: data.min,
15
15
  mode: data.mode,
16
- quartile_1: data.value_from_percentile(25),
17
- quartile_2: data.value_from_percentile(50),
18
- quartile_3: data.value_from_percentile(75),
16
+ quartile1: data.value_from_percentile(25),
17
+ quartile2: data.value_from_percentile(50),
18
+ quartile3: data.value_from_percentile(75),
19
19
  range: data.range,
20
20
  size: data.size,
21
21
  sum: data.sum,
@@ -17,9 +17,9 @@ def baseline_summary(data)
17
17
  median: data.median,
18
18
  min: data.min,
19
19
  mode: data.mode,
20
- quartile_1: data.value_from_percentile(25),
21
- quartile_2: data.value_from_percentile(50),
22
- quartile_3: data.value_from_percentile(75),
20
+ quartile1: data.value_from_percentile(25),
21
+ quartile2: data.value_from_percentile(50),
22
+ quartile3: data.value_from_percentile(75),
23
23
  range: data.range,
24
24
  size: data.size,
25
25
  sum: data.sum,
@@ -17,9 +17,9 @@ def baseline_summary(data)
17
17
  median: data.get_median,
18
18
  min: data.min,
19
19
  mode: data.get_mode,
20
- quartile_1: data.get_percentile(25),
21
- quartile_2: data.get_percentile(50),
22
- quartile_3: data.get_percentile(75),
20
+ quartile1: data.get_percentile(25),
21
+ quartile2: data.get_percentile(50),
22
+ quartile3: data.get_percentile(75),
23
23
  range: data.get_range,
24
24
  size: data.size,
25
25
  sum: data.get_sum,
@@ -50,7 +50,7 @@ def full_summary(data)
50
50
  geometric_mean: data.get_geo_mean,
51
51
  harmonic_mean: data.get_harm_mean,
52
52
  product: data.get_product,
53
- interquartile_range: data.get_interquartile_range,
53
+ interquartilerange: data.get_interquartilerange,
54
54
  relative_variance: data.get_relative_variance,
55
55
  coeff_variation: data.get_coeff_variation
56
56
  )
@@ -7,9 +7,9 @@ collection = [1, 1, 2, 3, 10]
7
7
  results = {
8
8
  # - all documented calculations - ...
9
9
  # - including value_from_percentile of 25, 50, and 75 (quartile) -
10
- quartile_1: 2,
11
- quartile_2: 3,
12
- quartile_3: 10
10
+ quartile1: 2,
11
+ quartile2: 3,
12
+ quartile3: 10
13
13
  }
14
14
 
15
15
  klass = Lite::Statistics::Descriptive.new(collection)
@@ -2,10 +2,8 @@
2
2
 
3
3
  require 'lite/memoize'
4
4
 
5
- %w[version configuration descriptive].each do |filename|
5
+ %w[version configuration descriptive enumerable].each do |filename|
6
6
  require "lite/statistics/#{filename}"
7
7
  end
8
8
 
9
- require 'lite/statistics/enumerable' if Lite::Statistics.configuration.monkey_patches
10
-
11
9
  require 'generators/lite/statistics/install_generator'
@@ -13,16 +13,22 @@ module Lite
13
13
 
14
14
  end
15
15
 
16
- def self.configuration
17
- @configuration ||= Configuration.new
18
- end
16
+ class << self
19
17
 
20
- def self.configuration=(config)
21
- @configuration = config
22
- end
18
+ attr_writer :configuration
19
+
20
+ def configuration
21
+ @configuration ||= Configuration.new
22
+ end
23
+
24
+ def configure
25
+ yield(configuration)
26
+ end
27
+
28
+ def reset_configuration!
29
+ @configuration = Configuration.new
30
+ end
23
31
 
24
- def self.configure
25
- yield(configuration)
26
32
  end
27
33
 
28
34
  end
@@ -6,7 +6,7 @@ module Lite
6
6
 
7
7
  extend Lite::Memoize::Alias
8
8
 
9
- CALCULATIONS ||= %i[
9
+ CALCULATIONS = %i[
10
10
  frequencies max mean median midrange min mode proportions percentile_from_value
11
11
  population_coefficient_of_variation population_kurtosis population_size population_skewness
12
12
  population_standard_deviation population_standard_error population_summary
@@ -38,7 +38,7 @@ module Lite
38
38
 
39
39
  memoize :frequencies
40
40
 
41
- # rubocop:disable Style/UnneededSort
41
+ # rubocop:disable Style/RedundantSort
42
42
  def max
43
43
  return if @collection.empty?
44
44
 
@@ -46,7 +46,7 @@ module Lite
46
46
  end
47
47
 
48
48
  memoize :max
49
- # rubocop:enable Style/UnneededSort
49
+ # rubocop:enable Style/RedundantSort
50
50
 
51
51
  def mean
52
52
  return if @collection.empty?
@@ -68,7 +68,7 @@ module Lite
68
68
  memoize :median
69
69
  # rubocop:enable Metrics/AbcSize
70
70
 
71
- # rubocop:disable Style/UnneededSort
71
+ # rubocop:disable Style/RedundantSort
72
72
  def min
73
73
  return if @collection.empty?
74
74
 
@@ -76,7 +76,7 @@ module Lite
76
76
  end
77
77
 
78
78
  memoize :min
79
- # rubocop:enable Style/UnneededSort
79
+ # rubocop:enable Style/RedundantSort
80
80
 
81
81
  def mode
82
82
  return if @collection.empty?
@@ -192,7 +192,7 @@ module Lite
192
192
  def proportions
193
193
  return if @collection.empty?
194
194
 
195
- frequencies.each_with_object({}) { |(key, val), hash| hash[key] = val / size.to_f }
195
+ frequencies.transform_values { |val| val / size.to_f }
196
196
  end
197
197
 
198
198
  memoize :proportions
@@ -326,9 +326,9 @@ module Lite
326
326
  min: min,
327
327
  mode: mode,
328
328
  proportions: proportions,
329
- quartile_1: value_from_percentile(25),
330
- quartile_2: value_from_percentile(50),
331
- quartile_3: value_from_percentile(75),
329
+ quartile1: value_from_percentile(25),
330
+ quartile2: value_from_percentile(50),
331
+ quartile3: value_from_percentile(75),
332
332
  range: range,
333
333
  size: size,
334
334
  sum: sum
@@ -3,8 +3,10 @@
3
3
  if Lite::Statistics.configuration.monkey_patches
4
4
  module Enumerable
5
5
 
6
+ EXCLUDED_DESCRIPTIVE_CALCULATIONS = %i[max min sum].freeze
7
+
6
8
  Lite::Statistics::Descriptive::CALCULATIONS.each do |name|
7
- next if %i[max min sum].include?(name)
9
+ next if EXCLUDED_DESCRIPTIVE_CALCULATIONS.include?(name)
8
10
 
9
11
  define_method(name) { |*args| Lite::Statistics::Descriptive.send(name, self, *args) }
10
12
  end
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Statistics
5
5
 
6
- VERSION ||= '1.0.4'
6
+ VERSION = '1.2.0'
7
7
 
8
8
  end
9
9
  end
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  )
26
26
  else
27
27
  raise 'RubyGems 2.0 or newer is required to protect against ' \
28
- 'public gem pushes.'
28
+ 'public gem pushes.'
29
29
  end
30
30
 
31
31
  # Specify which files should be added to the gem when it is released.
@@ -46,5 +46,6 @@ Gem::Specification.new do |spec|
46
46
  spec.add_development_dependency 'rspec'
47
47
  spec.add_development_dependency 'rubocop'
48
48
  spec.add_development_dependency 'rubocop-performance'
49
+ spec.add_development_dependency 'rubocop-rake'
49
50
  spec.add_development_dependency 'rubocop-rspec'
50
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-statistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-17 00:00:00.000000000 Z
11
+ date: 2021-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lite-memoize
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rubocop-rspec
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +150,7 @@ dependencies:
136
150
  - - ">="
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
139
- description:
153
+ description:
140
154
  email:
141
155
  - j.gomez@drexed.com
142
156
  executables: []
@@ -196,7 +210,7 @@ homepage: http://drexed.github.io/lite-statistics
196
210
  licenses:
197
211
  - MIT
198
212
  metadata: {}
199
- post_install_message:
213
+ post_install_message:
200
214
  rdoc_options: []
201
215
  require_paths:
202
216
  - lib
@@ -211,8 +225,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
225
  - !ruby/object:Gem::Version
212
226
  version: '0'
213
227
  requirements: []
214
- rubygems_version: 3.0.4
215
- signing_key:
228
+ rubygems_version: 3.2.24
229
+ signing_key:
216
230
  specification_version: 4
217
231
  summary: Generate statistics from collections of data points
218
232
  test_files: []