#NEWLINE# def triu_indices( n , k = 0 ) : #NEWLINE# #INDENT# 'Return the indices for the upper-triangle of an (n,n) array.\n\n    Parameters\n    ----------\n    n : int\n      Sets the size of the arrays for which the returned indices will be valid.\n\n    k : int, optional\n      Diagonal offset (see triu() for details).\n\n    Examples\n    --------\n    Commpute two different sets of indices to access 4x4 arrays, one for the\n    upper triangular part starting at the main diagonal, and one starting two\n    diagonals further right:\n\n    >>> iu1 = triu_indices(4)\n    >>> iu2 = triu_indices(4,2)\n\n    Here is how they can be used with a sample array:\n    >>> a = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]])\n    >>> a\n    array([[ 1,  2,  3,  4],\n           [ 5,  6,  7,  8],\n           [ 9, 10, 11, 12],\n           [13, 14, 15, 16]])\n\n    Both for indexing:\n    >>> a[iu1]\n    array([ 1,  2,  3,  4,  6,  7,  8, 11, 12, 16])\n\n    And for assigning values:\n    >>> a[iu1] = -1\n    >>> a\n    array([[-1, -1, -1, -1],\n           [ 5, -1, -1, -1],\n           [ 9, 10, -1, -1],\n           [13, 14, 15, -1]])\n\n    These cover almost the whole array (two diagonals right of the main one):\n    >>> a[iu2] = -10\n    >>> a\n    array([[ -1,  -1, -10, -10],\n           [  5,  -1,  -1, -10],\n           [  9,  10,  -1,  -1],\n           [ 13,  14,  15,  -1]])\n\n    See also\n    --------\n    - tril_indices : similar function, for lower-triangular.\n    - mask_indices : generic function accepting an arbitrary mask function.\n    ' #NEWLINE# return mask_indices ( n , np . triu , k )