Sha256: 156f69a93914fb00afe91e41c336e64f2a0572f9b32594180d24f43f1cbbc24e
Contents?: true
Size: 746 Bytes
Versions: 2
Compression:
Stored size: 746 Bytes
Contents
module DbClustering module DatasourceAdapters class InMemory def initialize(array:) @array = array.map{ |datasource_point| DbClustering::Models::Point.new(datasource_point) } end def iterate_all_points points_count = @array.count @array.each.with_index do |point, current_index| yield(point, current_index, points_count) end end def neighbors(point:, distance_metric:, max_distance:) neighbors = [] @array.each do |neighbor_candidate| if distance_metric.distance(point.vector, neighbor_candidate.vector) <= max_distance neighbors << neighbor_candidate end end neighbors end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
db_clustering-0.1.6 | lib/datasource_adapters/in_memory.rb |
db_clustering-0.1.5 | lib/datasource_adapters/in_memory.rb |