PyDL:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- pydl v0.6.0 »
- PyDL »
- SDSS Utilities (`pydl.pydlutils`) »
- find_contiguous

# find_contiguous

`pydl.pydlutils.math.``find_contiguous`(x)

  Find the longest sequence of contiguous non-zero array elements.

  Parameters:

  x : `numpy.ndarray`

  > A 1d array. A dtype of bool is preferred although any dtype where the operation `if x[k]:` is well-defined should work.

  Returns:

  `list`

  > A list of indices of the longest contiguous non-zero sequence.

  Examples

      >>> import numpy as np
      >>> from pydl.pydlutils.math import find_contiguous
      >>> find_contiguous(np.array([0,1,1,1,0,1,1,0,1]))
      [1, 2, 3]