enumerable-statistics 2.0.6 → 2.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ca7750e402868e65da3619203a19ad1b7bd86348aee8ca2168c35db6fe6f262
4
- data.tar.gz: 425bd2623655dd3f189ee50f12b0d44d3c25bed86194d2f31eb530431cab1090
3
+ metadata.gz: caf1b8203b177aef325480c7d7d5a4c0ddb7cecdad3d12944d4b2caa71eebe13
4
+ data.tar.gz: 00d91f25e099eb2577eb1f6078dafb5c884538fe3863eb1b6795de58c0c3b642
5
5
  SHA512:
6
- metadata.gz: 37a9f4e270fee3e34852bccd0adc18d288514c1d8363807b2db16877ada2174aea7c1f8c8ef7cea94cb3274bb5716c35ee689ecde95a5a71cb7724e1afd2a164
7
- data.tar.gz: 5426b9ff42ce8033cf403be706da8a3dea94c88056a7a621218c0bc9aabe676571f868c263bef55266175759c95cc7f54267108f86cb483b0adacd11ce844968
6
+ metadata.gz: 2c9ab8a29752eb46cd00bf8f3f9787d6f151bc10e06d2179fa5f80e3ebb4625b96144a49fd907eb52c02e8f88767f9da1717761643d87e1489677a9eab227af9
7
+ data.tar.gz: de2d3d348ead4d6e99cffdb66f95a56ac7cfe603a4450db23deaddb6eeb82e454f79e84c236ea89142ea334999a82c6c307e16ac7085b1afe2895c63a6a8c5d4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 2.0.7
2
+
3
+ - Fix the bug of histogram with bin range that is smaller than value range
4
+
1
5
  # 2.0.6
2
6
 
3
7
  - Add edges parameter in histogram
@@ -2104,10 +2104,15 @@ histogram_edge_bin_index(VALUE edge, VALUE rb_x, int left_p)
2104
2104
  static void
2105
2105
  histogram_weights_push_values(VALUE bin_weights, VALUE edge, VALUE values, VALUE weight_array, int left_p)
2106
2106
  {
2107
+ const VALUE one = INT2FIX(1);
2108
+ long bi, i, n, n_bins, weighted = 0;
2107
2109
  VALUE x, cur;
2108
- long i, n, bi, one, weighted = 0;
2110
+
2111
+ assert(RB_TYPE_P(edge, T_ARRAY));
2112
+ assert(RB_TYPE_P(values, T_ARRAY));
2109
2113
 
2110
2114
  n = RARRAY_LEN(values);
2115
+ n_bins = RARRAY_LEN(edge) - 1;
2111
2116
 
2112
2117
  if (! NIL_P(weight_array)) {
2113
2118
  assert(RB_TYPE_P(weight_array, T_ARRAY));
@@ -2115,7 +2120,6 @@ histogram_weights_push_values(VALUE bin_weights, VALUE edge, VALUE values, VALUE
2115
2120
  weighted = 1;
2116
2121
  }
2117
2122
 
2118
- one = INT2FIX(1);
2119
2123
  for (i = 0; i < n; ++i) {
2120
2124
  x = RARRAY_AREF(values, i);
2121
2125
 
@@ -2143,15 +2147,17 @@ histogram_weights_push_values(VALUE bin_weights, VALUE edge, VALUE values, VALUE
2143
2147
 
2144
2148
  bi = histogram_edge_bin_index(edge, x, left_p);
2145
2149
 
2146
- cur = rb_ary_entry(bin_weights, bi);
2147
- if (NIL_P(cur)) {
2148
- cur = w;
2149
- }
2150
- else {
2151
- cur = rb_funcall(cur, idPLUS, 1, w);
2152
- }
2150
+ if (0 <= bi && bi < n_bins) {
2151
+ cur = rb_ary_entry(bin_weights, bi);
2152
+ if (NIL_P(cur)) {
2153
+ cur = w;
2154
+ }
2155
+ else {
2156
+ cur = rb_funcall(cur, idPLUS, 1, w);
2157
+ }
2153
2158
 
2154
- rb_ary_store(bin_weights, bi, cur);
2159
+ rb_ary_store(bin_weights, bi, cur);
2160
+ }
2155
2161
  }
2156
2162
  return;
2157
2163
 
@@ -1,5 +1,5 @@
1
1
  module EnumerableStatistics
2
- VERSION = '2.0.6'
2
+ VERSION = '2.0.7'
3
3
 
4
4
  module Version
5
5
  numbers, TAG = VERSION.split('-', 2)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enumerable-statistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenta Murata
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-22 00:00:00.000000000 Z
11
+ date: 2021-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -289,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
289
289
  - !ruby/object:Gem::Version
290
290
  version: '0'
291
291
  requirements: []
292
- rubygems_version: 3.2.3
292
+ rubygems_version: 3.2.21
293
293
  signing_key:
294
294
  specification_version: 4
295
295
  summary: Statistics features for Enumerable