def sameSegment(seg1, seg2):
 result = True
 for field in [1, 2, 3, 4, 5, 6]:
  if (abs((seg1[0][field] - seg2[0][field])) > 0.001):
   result = False
 if (len(seg1[1:]) != len(seg2[1:])):
  result = False
 for syn in seg2[1:]:
  if (syn[2] <= 0):
   print 'A synapse with zero permanence encountered'
   result = False
 if (result == True):
  for syn in seg1[1:]:
   if (syn[2] <= 0):
    print 'A synapse with zero permanence encountered'
    result = False
   res = sameSynapse(syn, seg2[1:])
   if (res == False):
    result = False
 return result

def sameSegment ( seg1 , seg2 ) : result = True for field in [ 1 , 2 , 3 , 4 , 5 , 6 ] : if ( abs ( ( seg1 [ 0 ] [ field ] - seg2 [ 0 ] [ field ] ) ) > 0.001 ) : result = False if ( len ( seg1 [ 1 : ] ) != len ( seg2 [ 1 : ] ) ) : result = False for syn in seg2 [ 1 : ] : if ( syn [ 2 ] <= 0 ) : print 'A synapse with zero permanence encountered' result = False if ( result == True ) : for syn in seg1 [ 1 : ] : if ( syn [ 2 ] <= 0 ) : print 'A synapse with zero permanence encountered' result = False res = sameSynapse ( syn , seg2 [ 1 : ] ) if ( res == False ) : result = False return result
return true if seg1 and seg2 are identical .