def get_edge_bin(array):
    'Detect the edge indcies of a binary 1-D array.\n\n    Args:\n        array (:class:`numpy.ndarray`): A list or Numpy 1d array, with binary\n            (0/1) or boolean (True/False) values.\n\n    Returns:\n        list: A list containing starting and ending indices of the non-zero\n            blocks.\n\n    Examples:\n\n        .. code-block:: python\n\n            >>> a = [0,1,1,0,0,0,1,0,1]\n            >>> get_edge_bin(a)\n            [(1, 3), (6, 7), (8, 9)]\n            >>> b = [True, False, True, True, False, False]\n            >>> get_edge_bin(b)\n            [(0, 1), (2, 4)]\n    '
    array1 = np.int64(array)
    array1 = np.insert(array1, 0, 0)
    array1 = np.append(array1, 0)
    tmp = (array1 - np.roll(array1, 1))
    i1_lst = (np.nonzero((tmp == 1))[0] - 1)
    i2_lst = (np.nonzero((tmp == (- 1)))[0] - 1)
    return list(zip(i1_lst, i2_lst))
Detect the edge indcies of a binary 1-D array.

Args:
    array (:class:`numpy.ndarray`): A list or Numpy 1d array, with binary
        (0/1) or boolean (True/False) values.

Returns:
    list: A list containing starting and ending indices of the non-zero
        blocks.

Examples:

    .. code-block:: python

        >>> a = [0,1,1,0,0,0,1,0,1]
        >>> get_edge_bin(a)
        [(1, 3), (6, 7), (8, 9)]
        >>> b = [True, False, True, True, False, False]
        >>> get_edge_bin(b)
        [(0, 1), (2, 4)]
def get_edge_bin(array):
    'Detect the edge indcies of a binary 1-D array.\n\n    Args:\n        array (:class:`numpy.ndarray`): A list or Numpy 1d array, with binary\n            (0/1) or boolean (True/False) values.\n\n    Returns:\n        list: A list containing starting and ending indices of the non-zero\n            blocks.\n\n    Examples:\n\n        .. code-block:: python\n\n            >>> a = [0,1,1,0,0,0,1,0,1]\n            >>> get_edge_bin(a)\n            [(1, 3), (6, 7), (8, 9)]\n            >>> b = [True, False, True, True, False, False]\n            >>> get_edge_bin(b)\n            [(0, 1), (2, 4)]\n    '
    array1 = np.int64(array)
    array1 = np.insert(array1, 0, 0)
    array1 = np.append(array1, 0)
    tmp = (array1 - np.roll(array1, 1))
    i1_lst = (np.nonzero((tmp == 1))[0] - 1)
    i2_lst = (np.nonzero((tmp == (- 1)))[0] - 1)
    return list(zip(i1_lst, i2_lst))