Module Import alias identifier Import alias ImportFrom alias alias FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr For NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num body Assign SubscriptStore NameLoad Index TupleLoad NameLoad NameLoad Num Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call NameLoad NameLoad Assign TupleStore NameStore NameStore AttributeLoad NameLoad attr For NameStore Call NameLoad NameLoad body For NameStore Call NameLoad NameLoad body For NameStore Call NameLoad NameLoad body Assign SubscriptStore NameLoad Index TupleLoad NameLoad NameLoad Call NameLoad SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad BinOpAdd SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad Return NameLoad decorator_list Expr Str Expr Str Expr Str FunctionDef arguments args defaults body Assign NameStore Num Assign NameStore BinOpPow BinOpMult Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Num Num Expr Call AttributeLoad NameLoad attr NameLoad ListLoad NameLoad Call NameLoad NameLoad Expr Str decorator_list If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr
N/A N/A numpy np N/A parakeet parakeet jit testing_helpers init N/A N/A W N/A N/A N/A C N/A N/A W copy N/A i N/A xrange N/A N/A C shape N/A 0 N/A N/A N/A C N/A N/A i i 0 N/A C N/A loop_dists N/A N/A W N/A N/A N/A C N/A init W N/A N/A m n N/A C shape N/A k N/A range n N/A N/A i N/A range n N/A N/A j N/A range n N/A N/A N/A C N/A N/A i j N/A min N/A C N/A N/A i j N/A N/A C N/A N/A i k N/A C N/A N/A k j N/A C N/A N/A 
def outer_dists(W,E = None):
  C = init(W,E)
  m,n = C.shape
  assert m == n
  vertices = np.arange(n)
  for k in vertices:
    from_k = C[:, k]
    to_k = C[k, :]
    A = np.add.outer(from_k, to_k)
    mask = (A<=C)
    C = mask * A + (1-mask) * C
    A = np.add.outer(from_k, to_k)
    mask = (A<=C)
    C = mask * A + ~mask * C
  return C
 N/A 
def np_dists(W, E = None):
  C = init(W,E)
  n = C.shape[0]
  for k in range(n):
    C = np.minimum(C, np.tile(C[:,k].reshape(-1,1),(1,n)) + np.tile(C[k,:],(n,1)))
  return C
 N/A 
def parakeet_dists(W, E = None):
  C = init(W,E)
  m,n = C.shape
  # assert m == n
  vertices = np.arange(n)
  def min_row(c_row, a_row):
    return map(min, c_row, a_row)
  
  for k in vertices:
    from_k = C[:, k]
    to_k = C[k, :]
    A = parakeet.allpairs(parakeet.add, from_k, to_k)
    C = parakeet.each(min_row, C, A)
  return C
 test_dists N/A N/A N/A N/A N/A n 10 N/A W N/A N/A N/A N/A N/A np random randn n n 2 2 N/A N/A N/A testing_helpers expect loop_dists N/A W N/A loop_dists W N/A 
  C1 = outer_dists(W)
  C2 = np_dists(W)
  assert np.all(np.ravel(C1 == C2)),       "C2 wrong: Expected %s but got %s" % (C1, C2)
      
  C3 = parakeet_dists(W)
  assert np.all(np.ravel(C1 == C3)),       "Parakeet wrong: Expected %s but got %s" % (C1, C3)
   N/A N/A N/A __name__ __main__ N/A N/A N/A N/A testing_helpers run_local_tests