Used for identifying an ancillary computation

        The data columns and the used configuration keys/values
        are hashed.
326322
def hash(self, rtdc_ds):
        
        hasher = hashlib.md5()
        # data columns
        for col in self.req_features:
            hasher.update(obj2str(rtdc_ds[col]))
        # config keys
        for sec, keys in self.req_config:
            for key in keys:
                val = rtdc_ds.config[sec][key]
                data = "{}:{}={}".format(sec, key, val)
                hasher.update(obj2str(data))
        return hasher.hexdigest()
1070091
def _compute_dynamic_properties(self, builder):
    """"""
    # Fill other things by going over the dataset.
    splits = self.splits
    for split_info in utils.tqdm(
        splits.values(), desc="Computing statistics...", unit=" split"):
      try:
        split_name = split_info.name
        # Fill DatasetFeatureStatistics.
        dataset_feature_statistics, schema = get_dataset_feature_statistics(
            builder, split_name)

        # Add the statistics to this split.
        split_info.statistics.CopyFrom(dataset_feature_statistics)

        # Set the schema at the top-level since this is independent of the
        # split.
        self.as_proto.schema.CopyFrom(schema)

      except tf.errors.InvalidArgumentError:
        # This means there is no such split, even though it was specified in the
        # info, the least we can do is to log this.
        logging.error(("%s's info() property specifies split %s, but it "
                       "doesn't seem to have been generated. Please ensure "
                       "that the data was downloaded for this split and re-run "
                       "download_and_prepare."), self.name, split_name)
        raise

    # Set splits to trigger proto update in setter
    self._set_splits(splits)
1145535
def compute_transformed(context):
    """"""

    key_composite = compute_key_composite(
        password=context._._.password,
        keyfile=context._._.keyfile
    )
    kdf_parameters = context._.header.value.dynamic_header.kdf_parameters.data.dict

    if context._._.transformed_key is not None:
        transformed_key = context._._.transformed_key
    elif kdf_parameters['$UUID'].value == kdf_uuids['argon2']:
        transformed_key = argon2.low_level.hash_secret_raw(
            secret=key_composite,
            salt=kdf_parameters['S'].value,
            hash_len=32,
            type=argon2.low_level.Type.D,
            time_cost=kdf_parameters['I'].value,
            memory_cost=kdf_parameters['M'].value // 1024,
            parallelism=kdf_parameters['P'].value,
            version=kdf_parameters['V'].value
        )
    elif kdf_parameters['$UUID'].value == kdf_uuids['aeskdf']:
        transformed_key = aes_kdf(
            kdf_parameters['S'].value,
            kdf_parameters['R'].value,
            key_composite
        )
    else:
        raise Exception('Unsupported key derivation method')

    return transformed_key
1045539
private String redisColumnKey(SqlpKit.FLAG flag) {
		StringBuilder key = new StringBuilder(this._getUsefulClass().toGenericString());
		String[] attrs = this._getAttrNames();
		Object val;
		for (String attr : attrs) {
			val = this.get(attr);
			if (null == val) {
				continue;
			}
			key.append(val.toString());
		}
		key = new StringBuilder(HashKit.md5(key.toString()));
		if (flag.equals(SqlpKit.FLAG.ONE)) {
			return "data:"+key;
		}
		return "datas:"+key;
	}
752694
private int computeCredsHashCode( Credentials c ) {
        if (c instanceof SimpleCredentials) {
            return computeSimpleCredsHashCode((SimpleCredentials)c);
        }
        return c.hashCode();
    }
190637
def []=(key, value)
      characteristics[key] = Curation.new value, subject.class.characterization[key]
    end
497110
def hash_for_datasource(data_source):
        
        import hashlib
        hash_value = hashlib.md5()
        hash_value.update(data_source.encode('utf-8'))
        hash_value = hash_value.hexdigest()
        return hash_value
1009432
def baselineable
      key :type, :int
      key :ts, :timestamp
      key :uid, :text

      column :val, :float

      # Generate the aggregator methods
      generate_aggregators { |ts, method|
        type = method_names_type_counter(method)
        aggregate type, ts
      }
    end
569299
def _compute_public_key(self):
        

        if self.algorithm == 'dsa':
            params = self['private_key_algorithm']['parameters']
            return Integer(pow(
                params['g'].native,
                self['private_key'].parsed.native,
                params['p'].native
            ))

        if self.algorithm == 'rsa':
            key = self['private_key'].parsed
            return RSAPublicKey({
                'modulus': key['modulus'],
                'public_exponent': key['public_exponent'],
            })

        if self.algorithm == 'ec':
            curve_type, details = self.curve

            if curve_type == 'implicit_ca':
                raise ValueError(unwrap(
                    '''
                    Unable to compute public key for EC key using Implicit CA
                    parameters
                    '''
                ))

            if curve_type == 'specified':
                if details['field_id']['field_type'] == 'characteristic_two_field':
                    raise ValueError(unwrap(
                        '''
                        Unable to compute public key for EC key over a
                        characteristic two field
                        '''
                    ))

                curve = PrimeCurve(
                    details['field_id']['parameters'],
                    int_from_bytes(details['curve']['a']),
                    int_from_bytes(details['curve']['b'])
                )
                base_x, base_y = self['private_key_algorithm']['parameters'].chosen['base'].to_coords()
                base_point = PrimePoint(curve, base_x, base_y)

            elif curve_type == 'named':
                if details not in ('secp192r1', 'secp224r1', 'secp256r1', 'secp384r1', 'secp521r1'):
                    raise ValueError(unwrap(
                        '''
                        Unable to compute public key for EC named curve %s,
                        parameters not currently included
                        ''',
                        details
                    ))

                base_point = {
                    'secp192r1': SECP192R1_BASE_POINT,
                    'secp224r1': SECP224R1_BASE_POINT,
                    'secp256r1': SECP256R1_BASE_POINT,
                    'secp384r1': SECP384R1_BASE_POINT,
                    'secp521r1': SECP521R1_BASE_POINT,
                }[details]

            public_point = base_point * self['private_key'].parsed['private_key'].native
            return ECPointBitString.from_coords(public_point.x, public_point.y)
21491
def _data(self):
        
        d = {}

        # Iterate all keys and values
        for k, v in self._row_values.items():
            # Split related model fields
            attrs = k.rsplit('__', 1)

            # Set value depending case
            if len(attrs) == 2:
                # Related model field, store nested
                fk, fn = attrs
                if fk not in d:
                    d[fk] = {}
                d[fk][fn] = v

            else:
                # Own model field, store directly
                d[k] = v

        # Return (+cache) data
        return d
880836
def _compute_diff(configured, expected):

    ''''''

    diff = {
        'add': {},
        'update': {},
        'remove': {}
    }

    configured_users = set(configured.keys())
    expected_users = set(expected.keys())

    add_usernames = expected_users - configured_users
    remove_usernames = configured_users - expected_users
    common_usernames = expected_users & configured_users

    add = dict((username, expected.get(username)) for username in add_usernames)
    remove = dict((username, configured.get(username)) for username in remove_usernames)
    update = {}

    for username in common_usernames:
        user_configuration = configured.get(username)
        user_expected = expected.get(username)
        if user_configuration == user_expected:
            continue
        update[username] = {}
        for field, field_value in six.iteritems(user_expected):
            if user_configuration.get(field) != field_value:
                update[username][field] = field_value

    diff.update({
        'add': add,
        'update': update,
        'remove': remove
    })

    return diff
1158005
def dynamic_field_factories_hash
      @dynamic_field_factories_hash ||=
        begin
          dynamic_field_factories_hash = @types.inject({}) do |hash, type|
            Setup.for(type).dynamic_field_factories.each do |field_factory|
              (hash[field_factory.name.to_sym] ||= {})[type.name] = field_factory
            end
            hash
          end
          dynamic_field_factories_hash.each_pair do |field_name, field_configurations_hash|
            if @types.any? { |type| field_configurations_hash[type.name].nil? }
              dynamic_field_factories_hash.delete(field_name)
            else
              dynamic_field_factories_hash[field_name] = field_configurations_hash.values.first
            end
          end
        end
    end
986320
def external_system_identifiers2marc(self, key, value):
    
    def _is_scheme_cernkey(id_, schema):
        return schema == 'CERNKEY'

    def _is_scheme_spires(id_, schema):
        return schema == 'SPIRES'

    result_035 = self.get('035', [])
    id_dict = self.get('id_dict', defaultdict(list))
    result_970 = self.get('970', [])

    values = force_list(value)
    for value in values:
        id_ = value.get('value')
        schema = value.get('schema')

        if _is_scheme_spires(id_, schema):
            result_970.append({
                'a': id_,
            })
        elif _is_scheme_cernkey(id_, schema):
            result_035.append({
                '9': 'CERNKEY',
                'z': id_,
            })
        else:
            id_dict[schema].append(id_)

    self['970'] = result_970
    self['id_dict'] = id_dict
    return result_035
740023
def computed_values
      unless defined?(@computed_values) && @computed_values
        # Do nothing if all weights are 1, as n * 1 is n
        @computed_values = hashes if weights.all? {|weight| weight == 1 }
        # Otherwise, multiply the values in each hash by that hash's weighting
        @computed_values ||= hashes.each_with_index.map do |hash, index|
          weight = weights[index]
          Hash[hash.map {|k, v| [k, (v * weight)]}]
        end
      end
      @computed_values
    end
954958
def _compute_key(self, id, nbytes):
        """"""
        m = Message()
        m.add_mpint(self.K)
        m.add_bytes(self.H)
        m.add_byte(b(id))
        m.add_bytes(self.session_id)
        out = sofar = sha1(m.asbytes()).digest()
        while len(out) < nbytes:
            m = Message()
            m.add_mpint(self.K)
            m.add_bytes(self.H)
            m.add_bytes(sofar)
            digest = sha1(m.asbytes()).digest()
            out += digest
            sofar += digest
        return out[:nbytes]
1275240
def parse_keys(self, sn: "DataNode") -> Dict[InstanceName, ScalarValue]:
        
        res = {}
        for k in self.keys:
            knod = sn.get_data_child(*k)
            if knod is None:
                raise NonexistentSchemaNode(sn.qual_name, *k)
            kval = knod.type.parse_value(self.keys[k])
            if kval is None:
                raise InvalidKeyValue(self.keys[k])
            res[knod.iname()] = kval
        return res
89074
def stream_compute_ecc_hash(ecc_manager, hasher, file, max_block_size, header_size, resilience_rates):
    ''''''
    curpos = file.tell() # init the reading cursor at the beginning of the file
    # Find the total size to know when to stop
    #size = os.fstat(file.fileno()).st_size # old way of doing it, doesn't work with StringIO objects
    file.seek(0, os.SEEK_END) # alternative way of finding the total size: go to the end of the file
    size = file.tell()
    file.seek(0, curpos) # place the reading cursor back at the beginning of the file
    # Main encoding loop
    while curpos < size: # Continue encoding while we do not reach the end of the file
        # Calculating the encoding rate
        if curpos < header_size: # if we are still reading the file's header, we use a constant rate
            rate = resilience_rates[0]
        else: # else we use a progressive rate for the rest of the file the we calculate on-the-fly depending on our current reading cursor position in the file
            rate = feature_scaling(curpos, header_size, size, resilience_rates[1], resilience_rates[2]) # find the rate for the current stream of data (interpolate between stage 2 and stage 3 rates depending on the cursor position in the file)

        # Compute the ecc parameters given the calculated rate
        ecc_params = compute_ecc_params(max_block_size, rate, hasher)
        #ecc_manager = ECCMan(max_block_size, ecc_params["message_size"]) # not necessary to create an ecc manager anymore, as it is very costly. Now we can specify a value for k on the fly (tables for all possible values of k are pre-generated in the reed-solomon libraries)

        # Compute the ecc and hash for the current message block
        mes = file.read(ecc_params["message_size"])
        hash = hasher.hash(mes)
        ecc = ecc_manager.encode(mes, k=ecc_params["message_size"])
        #print("mes %i (%i) - ecc %i (%i) - hash %i (%i)" % (len(mes), message_size, len(ecc), ecc_params["ecc_size"], len(hash), ecc_params["hash_size"])) # DEBUGLINE

        # Return the result
        yield [hash, ecc, ecc_params]
        # Prepare for next iteration
        curpos = file.tell()