### Navigation

- index
- modules |
- modules |
- next |
- previous |
- NumPy v1.5 Manual (DRAFT) »
- NumPy Reference »
- Routines »
- Array creation routines »

# numpy.ones_like

`numpy.``ones_like`(x[, out])

  Returns an array of ones with the same shape and type as a given array.

  Equivalent to `a.copy().fill(1)`.

  Please refer to the documentation for zeros_like for further details.

  See also

  `zeros_like`, `ones`

  Examples

      >>> a = np.array([[1, 2, 3], [4, 5, 6]])
      >>> np.ones_like(a)
      array([[1, 1, 1],
             [1, 1, 1]])

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- NumPy v1.5 Manual (DRAFT) »
- NumPy Reference »
- Routines »
- Array creation routines »