Takes a hash with these keys and defaults:
  :source_factories => []
Calls #get_unit(key) on each source factory and averages results.
519568
def get_unit(key)
    return 0.0 if source_factories.empty?
    values = source_factories.map{|factory| factory.get_unit(key)}
    average = values.inject(0.0){|sum, value| sum += value} / source_factories.size
  end
357246
def call(context, *args)
      Hash[ collect { |k,v| [k,v.(context, *args) ] } ]
    end
104914
def merge_with_symbolized_keys(defaults, hash)
      hash.inject(defaults) { |symbolized, (k, v)| deep_set_symbol_key(symbolized, k, v) }
    end
733290
def build_environment_hash
      parsed_variables = {}
      @env.each do |env_row|
        # Each row can potentially contain multiple environment
        # variables
        variables = extract_variables(env_row)

        variables.each do |variables_with_values|
          variables_with_values.each do |key, value|
            parsed_variables[key] = value
          end
        end
      end

      @override_envs.each do |env|
        parsed_variables = parsed_variables.merge env
      end

      parsed_variables
    end
1321398
def fetch(*keys, default: nil, &block)
      # check alias
      real_key = @aliases[flatten_keys(keys)]
      keys = real_key.split(key_delim) if real_key

      keys = convert_to_keys(keys)
      env_key = autoload_env? ? to_env_key(keys[0]) : @envs[flatten_keys(keys)]
      # first try settings
      value = deep_fetch(@settings, *keys)
      # then try ENV var
      if value.nil? && env_key
        value = ENV[env_key]
      end
      # then try default
      value = block || default if value.nil?

      while callable_without_params?(value)
        value = value.call
      end
      value
    end
243714
def sizes
      @attrs.fetch(:sizes, []).each_with_object({}) do |(key, value), object|
        object[key] = Size.new(value)
      end
    end
258406
def actual_value(node, multi_keys)
      multi_keys.inject(node) { |n, key|
        if n
          key == :source ? n.send(key) : n.send(key)
        end
      }
    end
332330
def hash_dig(hash, *keys)
      keys.inject(hash) { |res, key| res[key] or return nil }
    end
1174956
def sources
      @sources ||= Licensed::Sources::Source.sources
                                            .select { |source_class| enabled?(source_class.type) }
                                            .map { |source_class| source_class.new(self) }
    end
383441
def lookup(outputs, key)
      out = outputs.find { |o| o.output_key == key }
      out&.output_value
    end
29183
def from_hash(hash:, klass:, use_alias: false)
      validate_class_kit(klass)

      return hash.map { |i| from_hash(hash: i, klass: klass, use_alias: use_alias) } if hash.is_a?(Array)

      @hash_helper.indifferent!(hash)
      entity = klass.new
      attributes = @attribute_helper.get_attributes(klass)
      attributes.each do |attribute|
        key = use_alias ? (attribute[:alias] || attribute[:name]) : attribute[:name]
        type = attribute[:type]

        # if the hash value is nil skip it
        next if hash[key].nil?

        value = if is_class_kit?(type)
                  from_hash(hash: hash[key], klass: type, use_alias: use_alias)
                elsif type == Array
                  hash[key].map do |array_element|
                    if attribute[:collection_type].nil?
                      array_element
                    else
                      if is_class_kit?(attribute[:collection_type])
                        from_hash(hash: array_element, klass: attribute[:collection_type], use_alias: use_alias)
                      else
                        @value_helper.parse(type: attribute[:collection_type], value: array_element)
                      end
                    end
                  end
                else
                  hash[key]
                end

        entity.public_send(:"#{attribute[:name]}=", value)
      end

      entity
    end
771377
def to_hash
      hash = {}
      hash["attrs"] = @attrs

      self.instance_variables.keep_if { |key| key != :@attrs }.each do |var|
        val = self.instance_variable_get(var)
        hash["attrs"][var.to_s.delete("@").to_sym] = val.to_hash if val.is_a? ACTV::Base
      end

      hash["attrs"]
    end
764566
def to_base_unit
      unit = @unit.base_unit
      val  = unit.convert(self)
      expr = unit.unit_string
      self.class.new( val, expr, unit )
    end
789354
def divide(self, data_source_factory):
        """"""
        data_length = data_source_factory.length()
        data_interval_length = data_length / self.workers_number() + 1

        current_index = 0
        self.responses = []
        while current_index < data_length:
            self.responses.append(0)
            offset = current_index
            limit = min((data_length - current_index, data_interval_length))
            yield data_source_factory.part(limit, offset)
            current_index += limit
155477
def []=(key, value)
      normalized_key = normalized_key(key)

      if key.is_a?(SymbolOperator)
        operator = :"$#{key.operator}"
        normalized_value = normalized_value(normalized_key, operator, value)
        @source[normalized_key] ||= {}
        @source[normalized_key][operator] = normalized_value
      else
        if key == :conditions
          value.each { |k, v| self[k] = v }
        else
          normalized_value = normalized_value(normalized_key, normalized_key, value)
          @source[normalized_key] = normalized_value
        end
      end
    end
1027719
def get_multi(*keys)
      check_keys = keys.flatten
      check_keys.compact!

      return {} if check_keys.empty?
      if block_given?
        get_multi_yielder(keys) {|k, data| yield k, data.first}
      else
        Hash.new.tap do |hash|
          get_multi_yielder(keys) {|k, data| hash[k] = data.first}
        end
      end
    end
204375
def get(self, key, param=None):
        ''''''
        try:
            return self._initializers[key][param]()
        except KeyError:
            if key in self._factories:
                return self._factories[key](param)
            raise DependencyError('Dependency "{0}" is not found'.format(key))