def _parse_nested_sequence(context, typ):
 if isinstance(typ, (types.Buffer,)):
  raise TypingError('%r not allowed in a homogenous sequence')
 elif isinstance(typ, (types.Sequence,)):
  (n, dtype) = _parse_nested_sequence(context, typ.dtype)
  return ((n + 1), dtype)
 elif isinstance(typ, (types.BaseTuple,)):
  if (typ.count == 0):
   return (1, types.float64)
  (n, dtype) = _parse_nested_sequence(context, typ[0])
  dtypes = [dtype]
  for i in range(1, typ.count):
   (_n, dtype) = _parse_nested_sequence(context, typ[i])
   if (_n != n):
    raise TypingError(('type %r does not have a regular shape' % (typ,)))
   dtypes.append(dtype)
  dtype = context.unify_types(*dtypes)
  if (dtype is None):
   raise TypingError('cannot convert %r to a homogenous type')
  return ((n + 1), dtype)
 else:
  as_dtype(typ)
  return (0, typ)

def _parse_nested_sequence ( context , typ ) : if isinstance ( typ , ( types . Buffer , ) ) : raise TypingError ( '%r not allowed in a homogenous sequence' ) elif isinstance ( typ , ( types . Sequence , ) ) : ( n , dtype ) = _parse_nested_sequence ( context , typ . dtype ) return ( ( n + 1 ) , dtype ) elif isinstance ( typ , ( types . BaseTuple , ) ) : if ( typ . count == 0 ) : return ( 1 , types . float64 ) ( n , dtype ) = _parse_nested_sequence ( context , typ [ 0 ] ) dtypes = [ dtype ] for i in range ( 1 , typ . count ) : ( _n , dtype ) = _parse_nested_sequence ( context , typ [ i ] ) if ( _n != n ) : raise TypingError ( ( 'type %r does not have a regular shape' % ( typ , ) ) ) dtypes . append ( dtype ) dtype = context . unify_types ( * dtypes ) if ( dtype is None ) : raise TypingError ( 'cannot convert %r to a homogenous type' ) return ( ( n + 1 ) , dtype ) else : as_dtype ( typ ) return ( 0 , typ )
parse a nested sequence type .