third_party/blink/renderer/build/scripts/update_css_ranking.py
def find_partition_rule(css_property_set,
                        all_properties,
                        n_cluster,
                        transform=lambda x: x):
    """Find partition rule for a set of CSS property based on its popularity

    Args:
        css_property_set: list of CSS properties and their popularity of form
                          [(css_property_name, popularity_score)..]
        n_cluster: number of cluster to divide the set into
        all_properties: all CSS properties and its score
        transform: data transform function to transform the popularity score,
                   default value is the identity function

    Returns:
        partition rule for css_property_set
    """
    _, cluster_alloc, _ = cluster.k_means(
        [transform(p[1]) for p in css_property_set], n_cluster=n_cluster)
    return [
        all_properties[css_property_set[i][0]]
        for i in range(len(cluster_alloc) - 1)
        if cluster_alloc[i] != cluster_alloc[i + 1]
    ] + [1.0]
Find partition rule for a set of CSS property based on its popularity

    Args:
        css_property_set: list of CSS properties and their popularity of form
                          [(css_property_name, popularity_score)..]
        n_cluster: number of cluster to divide the set into
        all_properties: all CSS properties and its score
        transform: data transform function to transform the popularity score,
                   default value is the identity function

    Returns:
        partition rule for css_property_set
    
Find partition rule for a set of CSS property based on its popularity
Find partition rule for a set of CSS property based on its popularity
def find_partition_rule(css_property_set,
                        all_properties,
                        n_cluster,
                        transform=lambda x: x):
    _, cluster_alloc, _ = cluster.k_means(
        [transform(p[1]) for p in css_property_set], n_cluster=n_cluster)
    return [
        all_properties[css_property_set[i][0]]
        for i in range(len(cluster_alloc) - 1)
        if cluster_alloc[i] != cluster_alloc[i + 1]
    ] + [1.0]
def find_partition_rule ( css_property_set , all_properties , n_cluster , transform = lambda x : x ) : _ , cluster_alloc , _ = cluster . k_means ( [ transform ( p [ 1 ] ) for p in css_property_set ] , n_cluster = n_cluster ) return [ all_properties [ css_property_set [ i ] [ 0 ] ] for i in range ( len ( cluster_alloc ) - 1 ) if cluster_alloc [ i ] != cluster_alloc [ i + 1 ] ] + [ 1.0 ]
Find partition rule for a set of CSS property based on its popularity
Find partition rule for a set of CSS property based on its popularity
"""Find partition rule for a set of CSS property based on its popularity

    Args:
        css_property_set: list of CSS properties and their popularity of form
                          [(css_property_name, popularity_score)..]
        n_cluster: number of cluster to divide the set into
        all_properties: all CSS properties and its score
        transform: data transform function to transform the popularity score,
                   default value is the identity function

    Returns:
        partition rule for css_property_set
    """
partition rule for css_property_set
partition rule for css_property_set
css_property_set
list of CSS properties and their popularity of form
[(css_property_name, popularity_score)..]
list of CSS properties and their popularity of form [ ( css_property_name popularity_score ) .. ]
all_properties
all CSS properties and its score
all CSS properties and its score
n_cluster
number of cluster to divide the set into
number of cluster to divide the set into
transform
data transform function to transform the popularity score,
default value is the identity function
data transform function to transform the popularity score default value is the identity function