lib/machine_learning_workbench/optimizer/natural_evolution_strategies/base.rb
Method sorted_inds
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
def sorted_inds
# Xumo::NArray implements the Box-Muller, but no random seed (yet)
samples = standard_normal_samples
# samples = NArray.new([popsize, ndims]).rand_norm(0,1)
inds = move_inds(samples)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method initialize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def initialize ndims, obj_fn, opt_type, rseed: nil, mu_init: 0, sigma_init: 1, parallel_fit: false, rescale_popsize: 1, rescale_lrate: 1, utilities: nil, popsize: nil, lrate: nil
raise ArgumentError, "opt_type: #{opt_type}" unless [:min, :max].include? opt_type
raise ArgumentError, "obj_fn not callable: #{obj_fn}" unless obj_fn.respond_to? :call
raise ArgumentError, "utilities only if popsize" if utilities && popsize.nil?
raise ArgumentError, "wrong sizes" if utilities && utilities.size != popsize
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
Open
raise ArgumentError, "minimum popsize 5 for default utilities" if popsize&.<(5) && utilities.nil?
- Exclude checks