def resize(a, new_shape):
if isinstance(new_shape, (int, nt.integer)):<EOL><INDENT>new_shape = (new_shape,)<EOL><DEDENT>a = ravel(a)<EOL>Na = len(a)<EOL>if not Na: return mu.zeros(new_shape, a.dtype.char)<EOL>total_size = um.multiply.reduce(new_shape)<EOL>n_copies = int(total_size / Na)<EOL>extra = total_size % Na<EOL>if total_size == <NUM_LIT:0>:<EOL><INDENT>return a[:<NUM_LIT:0>]<EOL><DEDENT>if extra != <NUM_LIT:0>:<EOL><INDENT>n_copies = n_copies+<NUM_LIT:1><EOL>extra = Na-extra<EOL><DEDENT>a = concatenate( (a,)*n_copies)<EOL>if extra > <NUM_LIT:0>:<EOL><INDENT>a = a[:-extra]<EOL><DEDENT>return reshape(a, new_shape)<EOL>
Return a new array with the specified shape.

If the new array is larger than the original array, then the new
array is filled with repeated copies of `a`.  Note that this behavior
is different from a.resize(new_shape) which fills with zeros instead
of repeated copies of `a`.

Parameters
----------
a : array_like
    Array to be resized.

new_shape : int or tuple of int
    Shape of resized array.

Returns
-------
reshaped_array : ndarray
    The new array is formed from the data in the old array, repeated
    if necessary to fill out the required number of elements.  The
    data are repeated in the order that they are stored in memory.

See Also
--------
ndarray.resize : resize an array in-place.

Examples
--------
>>> a=np.array([[0,1],[2,3]])
>>> np.resize(a,(1,4))
array([[0, 1, 2, 3]])
>>> np.resize(a,(2,4))
array([[0, 1, 2, 3],
       [0, 1, 2, 3]])