def _pad_sym(arr, pad_amt, method, axis=-<NUM_LIT:1>):
<EOL>if pad_amt[<NUM_LIT:0>] == <NUM_LIT:0> and pad_amt[<NUM_LIT:1>] == <NUM_LIT:0>:<EOL><INDENT>return arr<EOL><DEDENT>sym_slice = tuple(slice(None) if i != axis else slice(<NUM_LIT:0>, pad_amt[<NUM_LIT:0>])<EOL>for (i, x) in enumerate(arr.shape))<EOL>rev_idx = tuple(slice(None) if i != axis else slice(None, None, -<NUM_LIT:1>)<EOL>for (i, x) in enumerate(arr.shape))<EOL>sym_chunk1 = arr[sym_slice][rev_idx]<EOL>pad_singleton = tuple(x if i != axis else <NUM_LIT:1><EOL>for (i, x) in enumerate(arr.shape))<EOL>if pad_amt[<NUM_LIT:0>] == <NUM_LIT:1>:<EOL><INDENT>sym_chunk1 = sym_chunk1.reshape(pad_singleton)<EOL><DEDENT>if '<STR_LIT>' in method and pad_amt[<NUM_LIT:0>] > <NUM_LIT:0>:<EOL><INDENT>edge_slice1 = tuple(slice(None) if i != axis else <NUM_LIT:0><EOL>for (i, x) in enumerate(arr.shape))<EOL>edge_chunk = arr[edge_slice1].reshape(pad_singleton)<EOL>sym_chunk1 = <NUM_LIT:2> * edge_chunk - sym_chunk1<EOL>del edge_chunk<EOL><DEDENT>start = arr.shape[axis] - pad_amt[<NUM_LIT:1>]<EOL>end = arr.shape[axis]<EOL>sym_slice = tuple(slice(None) if i != axis else slice(start, end)<EOL>for (i, x) in enumerate(arr.shape))<EOL>sym_chunk2 = arr[sym_slice][rev_idx]<EOL>if pad_amt[<NUM_LIT:1>] == <NUM_LIT:1>:<EOL><INDENT>sym_chunk2 = sym_chunk2.reshape(pad_singleton)<EOL><DEDENT>if '<STR_LIT>' in method:<EOL><INDENT>edge_slice2 = tuple(slice(None) if i != axis else -<NUM_LIT:1><EOL>for (i, x) in enumerate(arr.shape))<EOL>edge_chunk = arr[edge_slice2].reshape(pad_singleton)<EOL>sym_chunk2 = <NUM_LIT:2> * edge_chunk - sym_chunk2<EOL>del edge_chunk<EOL><DEDENT>return np.concatenate((sym_chunk1, arr, sym_chunk2), axis=axis)<EOL>
Pad `axis` of `arr` by symmetry.

Parameters
----------
arr : ndarray
    Input array of arbitrary shape.
pad_amt : tuple of ints, length 2
    Padding to (prepend, append) along `axis`.
method : str
    Controls method of symmetry; options are 'even' or 'odd'.
axis : int
    Axis along which to pad `arr`.

Returns
-------
padarr : ndarray
    Output array, with `pad_amt[0]` values prepended and `pad_amt[1]`
    values appended along `axis`. Both regions are padded with symmetric
    values from the original array.

Notes
-----
This algorithm DOES pad with repetition, i.e. the edges are repeated.
For a method that does not repeat edges, use `method='reflect'`.

The modes 'reflect', 'symmetric', and 'wrap' must be padded with a
single function, lest the indexing tricks in non-integer multiples of the
original shape would violate repetition in the final iteration.