@staticmethod
def _format_axes(axes, shape):
    """
        Format target axes given an array shape
        """
    if isinstance(axes, int):
        axes = axes,
    elif isinstance(axes, list) or hasattr(axes, '__iter__'):
        axes = tuple(axes)
    if not isinstance(axes, tuple):
        raise ValueError(
            'axes argument %s in the constructor not specified correctly' %
            str(axes))
    if min(axes) < 0 or max(axes) > len(shape) - 1:
        raise ValueError('invalid key axes %s given shape %s' % (str(axes),
            str(shape)))
    return axes
