numpy.mask_indices()

numpy.mask_indices

numpy.mask_indices(n, mask_func, k=0) [source]

Return the indices to access (n, n) arrays, given a masking function.

Assume mask_func is a function that, for a square array a of size (n, n) with a possible offset argument k, when called as mask_func(a, k) returns a new array with zeros in certain locations (functions like triu or tril do precisely this). T