def _parse_shape(context, builder, ty, val):
 if isinstance(ty, types.Integer):
  ndim = 1
  shapes = [context.cast(builder, val, ty, types.intp)]
 else:
  assert isinstance(ty, types.BaseTuple)
  ndim = ty.count
  arrshape = context.cast(builder, val, ty, types.UniTuple(types.intp, ndim))
  shapes = cgutils.unpack_tuple(builder, val, count=ndim)
 zero = context.get_constant_generic(builder, types.intp, 0)
 for dim in range(ndim):
  is_neg = builder.icmp_signed('<', shapes[dim], zero)
  with cgutils.if_unlikely(builder, is_neg):
   context.call_conv.return_user_exc(builder, ValueError, ('negative dimensions not allowed',))
 return shapes

def _parse_shape ( context , builder , ty , val ) : if isinstance ( ty , types . Integer ) : ndim = 1 shapes = [ context . cast ( builder , val , ty , types . intp ) ] else : assert isinstance ( ty , types . BaseTuple ) ndim = ty . count arrshape = context . cast ( builder , val , ty , types . UniTuple ( types . intp , ndim ) ) shapes = cgutils . unpack_tuple ( builder , val , count = ndim ) zero = context . get_constant_generic ( builder , types . intp , 0 ) for dim in range ( ndim ) : is_neg = builder . icmp_signed ( '<' , shapes [ dim ] , zero ) with cgutils . if_unlikely ( builder , is_neg ) : context . call_conv . return_user_exc ( builder , ValueError , ( 'negative dimensions not allowed' , ) ) return shapes
parse the shape argument to an array constructor .