Sha256: 9e6856bb14b24463a55e2ee8d930c604194466e2121da9aab3eb5c1fc77c5ae5
Contents?: true
Size: 1.61 KB
Versions: 1
Compression:
Stored size: 1.61 KB
Contents
# frozen_string_literal: true module SVMKit # @!visibility private module Validation module_function # @!visibility private def check_sample_array(x) raise TypeError, 'Expect class of sample matrix to be Numo::DFloat' unless x.is_a?(Numo::DFloat) raise ArgumentError, 'Expect sample matrix to be 2-D array' unless x.shape.size == 2 nil end # @!visibility private def check_label_array(y) raise TypeError, 'Expect class of label vector to be Numo::Int32' unless y.is_a?(Numo::Int32) raise ArgumentError, 'Expect label vector to be 1-D arrray' unless y.shape.size == 1 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 # @!visibility private def check_params_type_or_nil(type, params = {}) params.each { |k, v| raise TypeError, "Expect class of #{k} to be #{type} or nil" unless v.is_a?(type) || v.is_a?(NilClass) } nil end # @!visibility private def check_params_float(params = {}) check_params_type(Float, params) end # @!visibility private def check_params_integer(params = {}) check_params_type(Integer, params) end # @!visibility private def check_params_string(params = {}) check_params_type(String, params) 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
svmkit-0.2.8 | lib/svmkit/validation.rb |