Skip to content

Methods not implemented? centroid_distances, centroid_distance #10

@alxx

Description

@alxx

I was looking at the public methods available on a centroid instance and I found these two. The first one is nil, the other one causes an error:

3.4.7 :067 > kmeans.clusters[0].centroid.methods - 1.methods
 => [:label=, :centroid_distances, :dimension, :centroid_distance, :data, :cluster, :cluster=, :label, :to_a, :id] 

3.4.7 :070 > kmeans.clusters[0].centroid.centroid_distances
 => nil 

3.4.7 :071 > kmeans.clusters[0].centroid.centroid_distance
/home/alxx/.rvm/gems/ruby-3.4.7/gems/kmeans-clusterer-0.11.4/lib/kmeans-clusterer.rb:92:in 'KMeansClusterer::Point#centroid_distance': undefined method 'id' for nil (NoMethodError)

      @centroid_distances[@cluster.id]
                                  ^^^
	from (irb):71:in '<main>'
	from <internal:kernel>:168:in 'Kernel#loop'
	from /home/alxx/.rvm/gems/ruby-3.4.7/gems/irb-1.15.2/exe/irb:9:in '<top (required)>'
	from /home/alxx/.rvm/gems/ruby-3.4.7/bin/irb:25:in 'Kernel#load'
	from /home/alxx/.rvm/gems/ruby-3.4.7/bin/irb:25:in '<main>'
	from /home/alxx/.rvm/gems/ruby-3.4.7/bin/ruby_executable_hooks:22:in 'Kernel#eval'
	from /home/alxx/.rvm/gems/ruby-3.4.7/bin/ruby_executable_hooks:22:in '<main>'

Or am I using them wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions