Did I find the right examples for you? yes no

# numpy.matlib.ones

All Samples(16)  |  Call(10)  |  Derive(0)  |  Import(6)
```Matrix of ones.

Return a matrix of given shape and type, filled with ones.

Parameters
----------
shape : {sequence of ints, int}
Shape of the matrix
dtype : data-type, optional
The desired data-type for the matrix, default is np.float64.(more...)
```

```        def ones(shape, dtype=None, order='C'):
"""
Matrix of ones.

Return a matrix of given shape and type, filled with ones.

Parameters
----------
shape : {sequence of ints, int}
Shape of the matrix
dtype : data-type, optional
The desired data-type for the matrix, default is np.float64.
order : {'C', 'F'}, optional
Whether to store matrix in C- or Fortran-contiguous order,
default is 'C'.

Returns
-------
out : matrix
Matrix of ones of given shape, dtype, and order.

--------
ones : Array of ones.
matlib.zeros : Zero matrix.

Notes
-----
If `shape` has length one i.e. ``(N,)``, or is a scalar ``N``,
`out` becomes a single row matrix of shape ``(1,N)``.

Examples
--------
>>> np.matlib.ones((2,3))
matrix([[ 1.,  1.,  1.],
[ 1.,  1.,  1.]])

>>> np.matlib.ones(2)
matrix([[ 1.,  1.]])

"""
a = ndarray.__new__(matrix, shape, dtype, order=order)
a.fill(1)
return a
```

```from numpy import r_, c_, arange, diff, mean, sqrt, log, mat
from numpy import asarray, nan
from numpy.matlib import ones, zeros, rand, eye, empty
from numpy.linalg import eigh, cholesky, solve, lstsq
# (lstsq also as tool to determine rank)
```
```        for row in range(p):
# (must be ones() instead of 1 because of 2d-requirement
if lstsq( m[row,:], ones(1) )[2] == 0 or idrcount >= r:
c = r_[ c, zeros(r) ]
co = r_[ co, idpr[row-idrcount, :] ]
```
```    else: return temp

from numpy.matlib import empty, ones, zeros
from numpy import mat, c_, r_
def getDeterministics(nobs, which = 'c', date = 0.5):
```
```        out = c_[ out, slopeshift ]
if 'i' in which:
impulse = r_[ zeros(shiftperiod).T, ones(1), zeros(nobs-shiftperiod-1).T ]
out = c_[ out, impulse ]
if 'q' in which or 'Q' in which:
```
```    else: return result

from numpy.matlib import ones, zeros, mat
from numpy.linalg import solve
def commontrendstest(series, LagTrunc=4, determ = 'c', breakpoint=0.5):
```

```from numpy import r_, c_, arange, diff, mean, sqrt, log, mat
from numpy import asarray, nan
from numpy.matlib import ones, zeros, rand, eye, empty
from numpy.linalg import eigh, cholesky, solve, lstsq
# (lstsq also as tool to determine rank)
```
```        for row in range(p):
# (must be ones() instead of 1 because of 2d-requirement
if lstsq( m[row,:], ones(1) )[2] == 0 or idrcount >= r:
c = r_[ c, zeros(r) ]
co = r_[ co, idpr[row-idrcount, :] ]
```
```    else: return temp

from numpy.matlib import empty, ones, zeros
from numpy import mat, c_, r_
def getDeterministics(nobs, which = 'c', date = 0.5):
```
```        out = c_[ out, slopeshift ]
if 'i' in which:
impulse = r_[ zeros(shiftperiod).T, ones(1), zeros(nobs-shiftperiod-1).T ]
out = c_[ out, impulse ]
if 'q' in which or 'Q' in which:
```
```    else: return result

from numpy.matlib import ones, zeros, mat
from numpy.linalg import solve
def commontrendstest(series, LagTrunc=4, determ = 'c', breakpoint=0.5):
```

```def test_ones():
assert_array_equal(np.matlib.ones((2, 3)),
np.matrix([[ 1.,  1.,  1.],
[ 1.,  1.,  1.]]))

assert_array_equal(np.matlib.ones(2), np.matrix([[ 1.,  1.]]))
```

```def test_ones():
assert_array_equal(np.matlib.ones((2, 3)),
np.matrix([[ 1.,  1.,  1.],
[ 1.,  1.,  1.]]))

assert_array_equal(np.matlib.ones(2), np.matrix([[ 1.,  1.]]))
```

```def test_ones():