sklearn_hierarchical_classification/tests/test_metrics.py
def graph_fixture(as_str=False):
    """Sets up our fixture class hierarchy graph for the metrics unit-tests.
    This class hierarchy looks like this (directed graph):

                   R
                 /  \
                0    1
                    / \
                   2   3
                  / \
                 4   5
                     |
                     6

    Parameters
    ----------
    as_str : bool, default False
        If set to true, will return graph with node ids converted to strings using
        inflect library (e.g. 1 will be converted to the string literal 'one').

    """
    G = DiGraph()
    G.add_edges_from([
        (ROOT, 0),
        (ROOT, 1),
        (1, 2),
        (1, 3),
        (2, 4),
        (2, 5),
        (5, 6),
    ])

    if as_str:
        inflect_engine = engine()
        relabel_nodes(
            G,
            {
                node_id: inflect_engine.number_to_words(node_id)
                for node_id in G.nodes()
                if node_id != ROOT
            },
            copy=False,
        )

    return G
Sets up our fixture class hierarchy graph for the metrics unit-tests.
    This class hierarchy looks like this (directed graph):

                   R
                 /  \
                0    1
                    / \
                   2   3
                  / \
                 4   5
                     |
                     6

    Parameters
    ----------
    as_str : bool, default False
        If set to true, will return graph with node ids converted to strings using
        inflect library (e.g. 1 will be converted to the string literal 'one').

    
Sets up our fixture class hierarchy graph for the metrics unit-tests.
This class hierarchy looks like this (directed graph).



Parameters

as_str : bool, default False
If set to true, will return graph with node ids converted to strings using
inflect library .
Sets up our fixture class hierarchy graph for the metrics unit - tests . This class hierarchy looks like this ( directed graph ) . Parameters as_str : bool default False If set to true will return graph with node ids converted to strings using inflect library .
def graph_fixture(as_str=False):
    G = DiGraph()
    G.add_edges_from([
        (ROOT, 0),
        (ROOT, 1),
        (1, 2),
        (1, 3),
        (2, 4),
        (2, 5),
        (5, 6),
    ])
    if as_str:
        inflect_engine = engine()
        relabel_nodes(
            G,
            {
                node_id: inflect_engine.number_to_words(node_id)
                for node_id in G.nodes()
                if node_id != ROOT
            },
            copy=False,
        )
    return G
def graph_fixture ( as_str = False ) : G = DiGraph ( ) G . add_edges_from ( [ ( ROOT , 0 ) , ( ROOT , 1 ) , ( 1 , 2 ) , ( 1 , 3 ) , ( 2 , 4 ) , ( 2 , 5 ) , ( 5 , 6 ) , ] ) if as_str : inflect_engine = engine ( ) relabel_nodes ( G , { node_id : inflect_engine . number_to_words ( node_id ) for node_id in G . nodes ( ) if node_id != ROOT } , copy = False , ) return G
Sets up our fixture class hierarchy graph for the metrics unit-tests.
Sets up our fixture class hierarchy graph for the metrics unit - tests .
"""Sets up our fixture class hierarchy graph for the metrics unit-tests.
    This class hierarchy looks like this (directed graph):

                   R
                 /  \
                0    1
                    / \
                   2   3
                  / \
                 4   5
                     |
                     6

    Parameters
    ----------
    as_str : bool, default False
        If set to true, will return graph with node ids converted to strings using
        inflect library (e.g. 1 will be converted to the string literal 'one').

    """
as_str