Return indices that are non-zero in the flattened version of a.

This is equivalent to a.ravel().nonzero()[0].

Parameters:

a : ndarray

Input array.

Returns:

res : ndarray

Output array, containing the indices of the elements of a.ravel() that are non-zero.

See also

nonzero
Return the indices of the non-zero elements of the input array.
ravel
Return a 1-D array containing the elements of the input array.

Examples

>>> x = np.arange(-2, 3)
>>> x
array([-2, -1, 0, 1, 2])
>>> np.flatnonzero(x)
array([0, 1, 3, 4])

Use the indices of the non-zero elements as an index array to extract these elements:

>>> x.ravel()[np.flatnonzero(x)]
array([-2, -1, 1, 2])

最新文章

  1. linux下libevent安装
  2. [CareerCup] 6.6 Toggle Lockers 切换锁的状态
  3. Redis 简单命令
  4. .NET MEF入门级例子
  5. MPlayer-2016-bin-noConsole
  6. Spring Assert(方法入参检测工具类-断言)
  7. Java for LeetCode 142 Linked List Cycle II
  8. 机器学习 —— 概率图模型(学习:CRF与MRF)
  9. Thread学习
  10. 连载:面向对象葵花宝典:思想、技巧与实践(32) - LSP原则
  11. HDOJ 1004题 Let the Balloon Rise strcmp()函数
  12. 2014-08-26 解决HttpContext.Current.Session在ashx文件中出现“未将对象引用设置到对象的实例”的问题
  13. android如何用adb shell启动应用程序
  14. 克隆 CentOS 后系统启动问题解析
  15. Python操作文件和目录
  16. Java-TreeSet的用法-入门
  17. Hibernate学习---用Session实现CURD
  18. DxPackNet 5.视频高质量的压缩和传输
  19. SVN简单的使用
  20. jquery 判断 元素是否具有某个class

热门文章

  1. 一个普通Java程序包含哪些线程??
  2. debian使用apt安装时出现“更换介质,插入驱动器"/media/chrom/"再按回车键”的提示,无法从网络安装,解决?
  3. top 进程管理
  4. STL使用迭代器逆向删除
  5. PMP项目管理学习笔记引言(1)——为啥要取得认证?
  6. 项目经验——jboss 配置数据库连接池
  7. Gym 100883J palprime(二分判断点在凸包里)
  8. Linux命令基础操作--vim 归档 压缩 分区 格式化 挂载 Innode
  9. react native在xcode真机调试ios
  10. 使用Spring AOP实现业务依赖解耦