lib/svmkit/validation.rb in svmkit-0.2.8 vs lib/svmkit/validation.rb in svmkit-0.2.9

- old
+ new

@@ -18,10 +18,16 @@ raise ArgumentError, 'Expect label vector to be 1-D arrray' unless y.shape.size == 1 nil end # @!visibility private + def check_sample_label_size(x, y) + raise ArgumentError, 'Expect to have the same number of samples for sample matrix and label vector' unless x.shape[0] == y.shape[0] + nil + end + + # @!visibility private def check_params_type(type, params = {}) params.each { |k, v| raise TypeError, "Expect class of #{k} to be #{type}" unless v.is_a?(type) } nil end @@ -47,9 +53,15 @@ end # @!visibility private def check_params_boolean(params = {}) params.each { |k, v| raise TypeError, "Expect class of #{k} to be Boolean" unless v.is_a?(FalseClass) || v.is_a?(TrueClass) } + nil + end + + # @!visibility private + def check_params_positive(params = {}) + params.reject { |_, v| v.nil? }.each { |k, v| raise ArgumentError, "Expect #{k} to be positive value" if v < 0 } nil end end end