lib/umappp.rb in umappp-0.1.3 vs lib/umappp.rb in umappp-0.1.4

- old
+ new

@@ -4,24 +4,23 @@ require_relative "umappp/version" require_relative "umappp/umappp" # Uniform Manifold Approximation and Projection module Umappp - # Make wrapper methods for the C++ function generated by Rice private private_class_method :umappp_run private_class_method :umappp_default_parameters # View the default parameters defined within the Umappp C++ library structure. def self.default_parameters # {method: :annoy, ndim: 2, tick: 0}.merge umappp_default_parameters end - # Runs the Uniform Manifold Approximation and Projection (UMAP) dimensional - # reduction technique. - # @param embedding [Array, Numo::SFloat] + # Runs the Uniform Manifold Approximation and Projection (UMAP) dimensional + # reduction technique. + # @param embedding [Array, Numo::SFloat] # @param method [Symbol] # @param ndim [Integer] # @param tick [Integer] # @param local_connectivity [Numeric] # @param bandwidth [Numeric] @@ -43,10 +42,13 @@ unless (u = (params.keys - default_parameters.keys)).empty? raise ArgumentError, "[umappp.rb] unknown option : #{u.inspect}" end nnmethod = %i[annoy vptree].index(method.to_sym) - data = Numo::SFloat.cast(embedding) + raise ArgumentError, "method must be :annoy or :vptree" if nnmethod.nil? - umappp_run(params, data, ndim, nnmethod, tick) + embedding2 = Numo::SFloat.cast(embedding) + raise ArgumentError, "embedding must be a 2D array" if embedding2.ndim <= 1 + + umappp_run(params, embedding2, ndim, nnmethod, tick) end end