def slice_axis_attributes(old, oldaxis, new, newaxis, slice_):
slice_ = as_slice(slice_)<EOL>index = '<STR_LIT>'.format<EOL>origin = '<STR_LIT>'.format<EOL>delta = '<STR_LIT>'.format<EOL>if hasattr(old, '<STR_LIT>'.format(oldaxis)):<EOL><INDENT>setattr(new, index(newaxis), getattr(old, index(oldaxis))[slice_])<EOL><DEDENT>elif isinstance(slice_, slice) or not numpy.sum(slice_):<EOL><INDENT>if isinstance(slice_, slice):<EOL><INDENT>offset = slice_.start or <NUM_LIT:0><EOL>step = slice_.step or <NUM_LIT:1><EOL><DEDENT>else:  <EOL><INDENT>offset = <NUM_LIT:0><EOL>step = <NUM_LIT:1><EOL><DEDENT>dx = getattr(old, delta(oldaxis))<EOL>x0 = getattr(old, origin(oldaxis))<EOL>setattr(new, origin(newaxis), x0 + offset * dx)<EOL>setattr(new, delta(newaxis), dx * step)<EOL><DEDENT>else:<EOL><INDENT>setattr(new, index(newaxis), getattr(old, index(oldaxis))[slice_])<EOL><DEDENT>return new<EOL>
Set axis metadata for ``new`` by slicing an axis of ``old``

    This is primarily for internal use in slice functions (__getitem__)

    Parameters
    ----------
    old : `Array`
        array being sliced

    oldaxis : ``'x'`` or ``'y'``
        the axis to slice

    new : `Array`
        product of slice

    newaxis : ``'x'`` or ``'y'``
        the target axis

    slice_ : `slice`, `numpy.ndarray`
        the slice to apply to old (or an index array)

    See Also
    --------
    Series.__getitem__
    Array2D.__getitem__