def has_shape(shape):
def has_shape_inner(arg_id, args, kwargs):<EOL><INDENT>self = args[<NUM_LIT:0>]<EOL>arg = args[arg_id]<EOL>if not hasattr(arg, "<STR_LIT>"):<EOL><INDENT>raise ExpectedTypeError(arg, ["<STR_LIT>"])<EOL><DEDENT>shape_values = []<EOL>for dim in shape:<EOL><INDENT>if not isinstance(dim, integer_types):<EOL><INDENT>dim = getattr(self, dim, None)<EOL><DEDENT>shape_values.append(dim)<EOL><DEDENT>if len(shape) != len(arg.shape):<EOL><INDENT>raise ShapeMismatchError(arg.shape, tuple(shape_values), shape)<EOL><DEDENT>for i, dim in enumerate(shape_values):<EOL><INDENT>if dim is not None and arg.shape[i] != dim:<EOL><INDENT>raise ShapeMismatchError(arg.shape, shape_values, shape)<EOL><DEDENT><DEDENT><DEDENT>return has_shape_inner<EOL>
Check that a particular argument is an array with a given shape. The
    shape may contain string attributes, which will be fetched from arg0 to
    the function (usually self).