📜  numpy.mask_indices()函数| Python

📅  最后修改于: 2022-05-13 01:54:53.100000             🧑  作者: Mango

numpy.mask_indices()函数| Python

numpy.mask_indices()函数返回索引以访问 (n, n) 数组,给定一个掩码函数。

代码#1:

# Python program explaining
# numpy.mask_indices() function
  
# importing numpy as geek 
import numpy as geek
  
gfg = geek.mask_indices(3, geek.triu)
  
print (gfg)

输出 :

(array([0, 0, 0, 1, 1, 2]), array([0, 1, 2, 1, 2, 2]))


代码#2:

# Python program explaining
# numpy.mask_indices() function
  
# importing numpy as geek 
import numpy as geek
  
gfg = geek.mask_indices(3, geek.triu, 1)
  
print (gfg)

输出 :

(array([0, 0, 1]), array([1, 2, 2]))