annoy-rb 0.7.0 → 0.7.1

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: 26a73345b4bb8bb29cbfc836599215b38dfa2e61f53bcf8183978802dbafbadc
4
- data.tar.gz: fdf69a4b34bd4c1a06cab5a68c54de13ac7a521c079ff9526981c8b13056373b
3
+ metadata.gz: d1f1b7326f096ef01be709b819e6fcac709776e5561d931b8b8a5b022aed1dc2
4
+ data.tar.gz: e767849b0970773b1c01307b830d6bbf15c250d86a4716d809867dc0cf8f211d
5
5
  SHA512:
6
- metadata.gz: 7999995d341e22f10ce89c645b5eaa2a7911812a03e3c04291c28e120bfcec27397930815b8491854a2f65577804a8b7fb50ac6bb7eaba2d7cc1d780c90df711
7
- data.tar.gz: b58d1820ce6a48d7bae526afccaefe16770091c9b84b00679517ffeabfde16df5cd70ababc751037b54c3f04a064131614edb852d9c8298a756efa6fc09592e3
6
+ metadata.gz: da4627d3414ed6ba062a3fb5d9ba546a32dced3e11d42ab4756badc219c29813b9d5389cbcb2159c027ad9a3b43c58f23f0f19660836c557d12c2c1b2a37330f
7
+ data.tar.gz: f195b96f9010a67ccc01088006a09e1ec5f857e7226f3d6b7c58a9ab5205757365061bbd1eb571715bfcd24a8f47c00e6aea7fcc1d7024f8cb6e511b7cb37255
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.7.1
2
+
3
+ - Fix bug that item elements are converted to unsingned integers when dtype is set to float32 ([#3](https://github.com/yoshoku/annoy-rb/issues/3)).
4
+
1
5
  ## 0.7.0
2
6
 
3
7
  - Update bundled Annoy version to 1.17.1.
@@ -111,7 +111,7 @@ private:
111
111
 
112
112
  F* vec = (F*)ruby_xmalloc(n_dims * sizeof(F));
113
113
  for (int i = 0; i < n_dims; i++) {
114
- vec[i] = typeid(F) == typeid(double) ? NUM2DBL(rb_ary_entry(arr, i)) : NUM2UINT(rb_ary_entry(arr, i));
114
+ vec[i] = (F)(typeid(F) == typeid(uint64_t) ? NUM2UINT(rb_ary_entry(arr, i)) : NUM2DBL(rb_ary_entry(arr, i)));
115
115
  }
116
116
 
117
117
  char* error;
@@ -195,7 +195,7 @@ private:
195
195
  const int sz_distances = distances.size();
196
196
  VALUE distances_arr = rb_ary_new2(sz_distances);
197
197
  for (int i = 0; i < sz_distances; i++) {
198
- rb_ary_store(distances_arr, i, typeid(F) == typeid(double) ? DBL2NUM(distances[i]) : UINT2NUM(distances[i]));
198
+ rb_ary_store(distances_arr, i, typeid(F) == typeid(uint64_t) ? UINT2NUM(distances[i]) : DBL2NUM(distances[i]));
199
199
  }
200
200
  VALUE res = rb_ary_new2(2);
201
201
  rb_ary_store(res, 0, neighbors_arr);
@@ -222,7 +222,7 @@ private:
222
222
 
223
223
  F* vec = (F*)ruby_xmalloc(n_dims * sizeof(F));
224
224
  for (int i = 0; i < n_dims; i++) {
225
- vec[i] = typeid(F) == typeid(double) ? NUM2DBL(rb_ary_entry(_vec, i)) : NUM2UINT(rb_ary_entry(_vec, i));
225
+ vec[i] = (F)(typeid(F) == typeid(uint64_t) ? NUM2UINT(rb_ary_entry(_vec, i)) : NUM2DBL(rb_ary_entry(_vec, i)));
226
226
  }
227
227
 
228
228
  const int n_neighbors = NUM2INT(_n_neighbors);
@@ -246,7 +246,7 @@ private:
246
246
  const int sz_distances = distances.size();
247
247
  VALUE distances_arr = rb_ary_new2(sz_distances);
248
248
  for (int i = 0; i < sz_distances; i++) {
249
- rb_ary_store(distances_arr, i, typeid(F) == typeid(double) ? DBL2NUM(distances[i]) : UINT2NUM(distances[i]));
249
+ rb_ary_store(distances_arr, i, typeid(F) == typeid(uint64_t) ? UINT2NUM(distances[i]) : DBL2NUM(distances[i]));
250
250
  }
251
251
  VALUE res = rb_ary_new2(2);
252
252
  rb_ary_store(res, 0, neighbors_arr);
@@ -266,7 +266,7 @@ private:
266
266
  get_annoy_index(self)->get_item(idx, vec);
267
267
 
268
268
  for (int i = 0; i < n_dims; i++) {
269
- rb_ary_store(arr, i, typeid(F) == typeid(double) ? DBL2NUM(vec[i]) : UINT2NUM(vec[i]));
269
+ rb_ary_store(arr, i, typeid(F) == typeid(uint64_t) ? UINT2NUM(vec[i]) : DBL2NUM(vec[i]));
270
270
  }
271
271
 
272
272
  ruby_xfree(vec);
@@ -277,7 +277,7 @@ private:
277
277
  const int32_t i = (int32_t)NUM2INT(_i);
278
278
  const int32_t j = (int32_t)NUM2INT(_j);
279
279
  const F dist = get_annoy_index(self)->get_distance(i, j);
280
- return typeid(F) == typeid(double) ? DBL2NUM(dist) : UINT2NUM(dist);
280
+ return typeid(F) == typeid(uint64_t) ? UINT2NUM(dist) : DBL2NUM(dist);
281
281
  };
282
282
 
283
283
  static VALUE _annoy_index_get_n_items(VALUE self) {
data/lib/annoy/version.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # Annoy.rb is a Ruby wrapper for Annoy (Approximate Nearest Neighbors Oh Yeah).
4
4
  module Annoy
5
5
  # The version of Annoy.rb you are using.
6
- VERSION = '0.7.0'
6
+ VERSION = '0.7.1'
7
7
 
8
8
  # The version of Annoy included with gem.
9
9
  ANNOY_VERSION = '1.17.1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: annoy-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-13 00:00:00.000000000 Z
11
+ date: 2022-09-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Annoy.rb provides Ruby bindings for the Annoy (Approximate Nearest Neighbors
14
14
  Oh Yeah).