Skip to content

Nondeterminism in test_directed_input #297

@sdmccabe

Description

@sdmccabe

Test failed once on PR #293.

_____________________________ test_directed_input ______________________________
    def test_directed_input():
        with warnings.catch_warnings():
            warnings.filterwarnings(
                "ignore", message="Coercing directed graph to undirected."
            )
            G = nx.fast_gnp_random_graph(100, 0.3, directed=True)
    
            for label, obj in distance.__dict__.items():
                if isinstance(obj, type) and BaseDistance in obj.__bases__:
                    dist = obj().dist(G, G)
                    assert np.isclose(dist, 0.0)
    
            G1 = nx.fast_gnp_random_graph(100, 0.3, directed=True)
            G2 = nx.fast_gnp_random_graph(100, 0.3, directed=True)
   
            for label, obj in distance.__dict__.items():
                if isinstance(obj, type) and BaseDistance in obj.__bases__:
                    dist1 = obj().dist(G1, G2)
                    dist2 = obj().dist(G2, G1)
>                   assert np.isclose(dist1, dist2)
E                   assert False
E                    +  where False = <function isclose at 0x7fc528395f70>(nan, nan)
E                    +    where <function isclose at 0x7fc528395f70> = np.isclose
test_distance.py:97: AssertionError

This seemed to be some nondeterminism in the test. I would guess from the nan result that the graphs weren't strongly connected and a distance depends on that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions