<commit_before># -*- coding: utf-8 -*-
require 'rubygems' if RUBY_VERSION < '1.9'
require "logger"

require "gargor/version"
require "gargor/individual"
require "gargor/parameter"

class Gargor
  class GargorError < RuntimeError; end
  class ExterminationError < GargorError; end
  class ParameterError < GargorError; end
  class ValidationError < GargorError; end
  class ArgumentError < GargorError; end

  class Individuals < Array
    def has? i
      !!self.find { |ii| ii.params == i.params }
    end
  end

  GLOBAL_OPTS = ["population","max_generations","target_nodes",
                 "attack_cmd","elite","mutation","target_cooking_cmd",
                 "fitness_precision"]

  GLOBAL_OPTS.each { |name| 
    define_method(name) { |val|
      Gargor.class_variable_set("@@#{name}", val)
    }
  }

  class << self
    def log message,level = :debug
      unless $TESTING
        @@logger ||= Logger.new(STDOUT)
        @@logger.send(level,message)
      end
    end

    def params
      result = {}
      GLOBAL_OPTS.map { |name| 
        result[name] = Gargor.class_variable_get("@@#{name}")
      }
      result
    end

    def start
      @@fitness_precision = 100000000
      @@prev_generation = nil
      @@individuals = []
      @@param_procs = {}<commit_msg>add debug for debug log<commit_after># -*- coding: utf-8 -*-
require 'rubygems' if RUBY_VERSION < '1.9'
require "logger"

require "gargor/version"
require "gargor/individual"
require "gargor/parameter"

class Gargor
  class GargorError < RuntimeError; end
  class ExterminationError < GargorError; end
  class ParameterError < GargorError; end
  class ValidationError < GargorError; end
  class ArgumentError < GargorError; end

  class Individuals < Array
    def has? i
      !!self.find { |ii| ii.params == i.params }
    end
  end

  GLOBAL_OPTS = ["population","max_generations","target_nodes",
                 "attack_cmd","elite","mutation","target_cooking_cmd",
                 "fitness_precision"]

  GLOBAL_OPTS.each { |name| 
    define_method(name) { |val|
      Gargor.class_variable_set("@@#{name}", val)
    }
  }

  class << self
    def log message,level = :info
      @@logger.send(level,message)
    end

    def debug message
      log message,:debug
    end

    def params
      result = {}
      GLOBAL_OPTS.map { |name| 
        result[name] = Gargor.class_variable_get("@@#{name}")
      }
      result
    end

    def start
      @@fitness_precision = 100000000
      @@prev_generation = nil
      @@individuals = []
      @@param_procs = {}
{'fraction_non_alphanumeric': 0.12043938799529227, 'fraction_numerical': 0.009415457041977247, 'mean_word_length': 2.811659192825112, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2429331', 'n_tokens_mistral': 883, 'n_tokens_neox': 819, 'n_words': 185}