ones

mipylib.numeric.minum.ones(shape, dtype='float')

Create a new aray of given shape and type, filled with ones.

Parameters:
  • shape – (int or sequence of ints) Shape of the new array, e.g., (2, 3) or 2.

  • dtype – (data-type, optional) The desired data-type for the array, including ‘int’, ‘float’ and ‘double’.

Returns:

(MIArray) Array of ones with the given shape and dtype.

Examples

>>> ones(5)
array([1.0, 1.0, 1.0, 1.0, 1.0])
>>> ones(5, dtype='int')
array([1, 1, 1, 1, 1])
>>> ones((2, 1))
array([[1.0]
      [1.0]])