lib/annoy.rb in annoy-rb-0.6.0 vs lib/annoy.rb in annoy-rb-0.6.1
- old
+ new
@@ -38,17 +38,18 @@
#
# @param n_features [Integer] The number of features (dimensions) of stored vector.
# @param metric [String] The distance metric between vectors ('angular', 'dot', 'hamming', 'euclidean', or 'manhattan').
# @param dtype [String] The data type of features ('float64' and 'float32').
# If metric is given 'hamming', 'uint64' is automatically assigned to this argument.
- def initialize(n_features:, metric: 'angular', dtype: 'float64')
+ def initialize(n_features:, metric: 'angular', dtype: 'float64') # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
raise ArgumentError, 'Expect n_features to be Integer.' unless n_features.is_a?(Numeric)
@n_features = n_features.to_i
@metric = metric
@dtype = dtype
+ # rubocop:disable Layout/LineLength
@index = case @metric
when 'angular'
@dtype == 'float64' ? AnnoyIndexAngular.new(@n_features) : AnnoyIndexAngularFloat32.new(@n_features)
when 'dot'
@dtype == 'float64' ? AnnoyIndexDotProduct.new(@n_features) : AnnoyIndexDotProductFloat32.new(@n_features)
@@ -60,9 +61,10 @@
when 'manhattan'
@dtype == 'float64' ? AnnoyIndexManhattan.new(@n_features) : AnnoyIndexManhattanFloat32.new(@n_features)
else
raise ArgumentError, "No such metric: #{@metric}."
end
+ # rubocop:enable Layout/LineLength
end
# Add item to be indexed.
#
# @param i [Integer] The ID of item.