<s> from nose . tools import * <EOL> from nose import SkipTest <EOL> from nose . plugins . attrib import attr <EOL> import networkx <EOL> class TestHITS : <EOL> def setUp ( self ) : <EOL> G = networkx . DiGraph ( ) <EOL> edges = [ ( <NUM_LIT:1> , <NUM_LIT:3> ) , ( <NUM_LIT:1> , <NUM_LIT:5> ) , ( <NUM_LIT:2> , <NUM_LIT:1> ) , ( <NUM_LIT:3> , <NUM_LIT:5> ) , ( <NUM_LIT:5> , <NUM_LIT:4> ) , ( <NUM_LIT:5> , <NUM_LIT:3> ) , ( <NUM_LIT:6> , <NUM_LIT:5> ) ] <EOL> G . add_edges_from ( edges , weight = <NUM_LIT:1> ) <EOL> self . G = G <EOL> self . G . a = dict ( zip ( G , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) ) <EOL> self . G . h = dict ( zip ( G , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) ) <EOL> def test_hits ( self ) : <EOL> G = self . G <EOL> h , a = networkx . hits ( G , tol = <NUM_LIT> ) <EOL> for n in G : <EOL> assert_almost_equal ( h [ n ] , G . h [ n ] , places = <NUM_LIT:4> ) <EOL> for n in G : <EOL> assert_almost_equal ( a [ n ] , G . a [ n ] , places = <NUM_LIT:4> ) <EOL> def test_hits_nstart ( self ) : <EOL> G = self . G <EOL> nstart = dict ( [ ( i , <NUM_LIT:1.> / <NUM_LIT:2> ) for i in G ] ) <EOL> h , a = networkx . hits ( G , nstart = nstart ) <EOL> @ attr ( '<STR_LIT>' ) <EOL> def test_hits_numpy ( self ) : <EOL> try : <EOL> import numpy as np <EOL> except ImportError : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> G = self . G <EOL> h , a = networkx . hits_numpy ( G ) <EOL> for n in G : <EOL> assert_almost_equal ( h [ n ] , G . h [ n ] , places = <NUM_LIT:4> ) <EOL> for n in G : <EOL> assert_almost_equal ( a [ n ] , G . a [ n ] , places = <NUM_LIT:4> ) <EOL> def test_hits_scipy ( self ) : <EOL> try : <EOL> import scipy as sp <EOL> except ImportError : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> G = self . G <EOL> h , a = networkx . hits_scipy ( G , tol = <NUM_LIT> ) <EOL> for n in G : <EOL> assert_almost_equal ( h [ n ] , G . h [ n ] , places = <NUM_LIT:4> ) <EOL> for n in G : <EOL> assert_almost_equal ( a [ n ] , G . a [ n ] , places = <NUM_LIT:4> ) <EOL> @ attr ( '<STR_LIT>' ) <EOL> def test_empty ( self ) : <EOL> try : <EOL> import numpy <EOL> except ImportError : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> G = networkx . Graph ( ) <EOL> assert_equal ( networkx . hits ( G ) , ( { } , { } ) ) <EOL> assert_equal ( networkx . hits_numpy ( G ) , ( { } , { } ) ) <EOL> assert_equal ( networkx . authority_matrix ( G ) . shape , ( <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> assert_equal ( networkx . hub_matrix ( G ) . shape , ( <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> def test_empty_scipy ( self ) : <EOL> try : <EOL> import scipy <EOL> except ImportError : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> G = networkx . Graph ( ) <EOL> assert_equal ( networkx . hits_scipy ( G ) , ( { } , { } ) ) </s>
