Exemplo n.º 1
0
def flat_map_indicators(phash_chunk_len, kPoints, options, k, flattened, phashes, wards):
    """Returns a list of key value pairs according
    to options.  See options_template above.  
     """
    ph = phash_chunks(phash_chunk_len, phashes)
    items = []
    best_cluster = closestPoint(flattened, kPoints)
    if options.get("phash_to_key"):
        items += [(phi, k) for phi in ph]
    if options.get("key_to_phash"):
        items += [(k, phi) for phi in ph]
    if options.get("phash_to_cluster"):
        items += [(phi, best_cluster) for phi in ph]
    if options.get("cluster_to_phash"):
        items += [(best_cluster, phi) for phi in ph]
    if options.get("phash_to_flattened"):
        items += [(phi, flattened) for phi in ph]
    if options.get("flattened_to_phash"):
        items += [(flattened, phi) for phi in ph]
    if options.get("flattened_to_key"):
        items += [(flattened, k)]
    if options.get("cluster_to_key"):
        items += [(best_cluster, k)]
    if options.get("cluster_to_flattened"):
        items += [(best_cluster, flattened)]
    if options.get("key_to_cluster"):
        items += [(k, best_cluster)]
    if options.get("ward_to_cluster"):
        items += [(wa, best_cluster) for wa in wards]
    if options.get("cluster_to_ward"):
        items += [(best_cluster, wa) for wa in wards]
    if options.get("ward_to_key"):
        items += [(wa, k) for wa in wards]
    return items
Exemplo n.º 2
0
def flat_map_indicators(phash_chunk_len, kPoints, options, k, flattened,
                        phashes, wards):
    """Returns a list of key value pairs according
    to options.  See options_template above.  
     """
    ph = phash_chunks(phash_chunk_len, phashes)
    items = []
    best_cluster = closestPoint(flattened, kPoints)
    if options.get('phash_to_key'):
        items += [(phi, k) for phi in ph]
    if options.get('key_to_phash'):
        items += [(k, phi) for phi in ph]
    if options.get('phash_to_cluster'):
        items += [(phi, best_cluster) for phi in ph]
    if options.get('cluster_to_phash'):
        items += [(best_cluster, phi) for phi in ph]
    if options.get('phash_to_flattened'):
        items += [(phi, flattened) for phi in ph]
    if options.get('flattened_to_phash'):
        items += [(flattened, phi) for phi in ph]
    if options.get('flattened_to_key'):
        items += [(flattened, k)]
    if options.get('cluster_to_key'):
        items += [(best_cluster, k)]
    if options.get('cluster_to_flattened'):
        items += [(best_cluster, flattened)]
    if options.get('key_to_cluster'):
        items += [(k, best_cluster)]
    if options.get('ward_to_cluster'):
        items += [(wa, best_cluster) for wa in wards]
    if options.get('cluster_to_ward'):
        items += [(best_cluster, wa) for wa in wards]
    if options.get('ward_to_key'):
        items += [(wa, k) for wa in wards]
    return items
Exemplo n.º 3
0
def cluster_chunk(config, ward_or_phash, x): 
    """Flatten phash or ward clusters """
    (id_, (best_cluster, self, distance, ward, phash)) = x
    if ward_or_phash == 'ward':
        chunks = ward
    else:
        chunks = phash_chunks(config['phash_chunk_len'], phash)
    return [(best_cluster , (ch, id_)) for ch in chunks]