MCPcopy Create free account
hub / github.com/numpy/numpy / asmatrix

Function asmatrix

numpy/matrixlib/defmatrix.py:38–70  ·  view source on GitHub ↗

Interpret the input as a matrix. Unlike `matrix`, `asmatrix` does not make a copy if the input is already a matrix or an ndarray. Equivalent to ``matrix(data, copy=False)``. Parameters ---------- data : array_like Input data. dtype : data-type Data-type

(data, dtype=None)

Source from the content-addressed store, hash-verified

36
37@set_module('numpy')
38def asmatrix(data, dtype=None):
39 """
40 Interpret the input as a matrix.
41
42 Unlike `matrix`, `asmatrix` does not make a copy if the input is already
43 a matrix or an ndarray. Equivalent to ``matrix(data, copy=False)``.
44
45 Parameters
46 ----------
47 data : array_like
48 Input data.
49 dtype : data-type
50 Data-type of the output matrix.
51
52 Returns
53 -------
54 mat : matrix
55 `data` interpreted as a matrix.
56
57 Examples
58 --------
59 >>> x = np.array([[1, 2], [3, 4]])
60
61 >>> m = np.asmatrix(x)
62
63 >>> x[0,0] = 5
64
65 >>> m
66 matrix([[5, 2],
67 [3, 4]])
68
69 """
70 return matrix(data, dtype=dtype, copy=False)
71
72
73@set_module('numpy')

Callers 11

eyeFunction · 0.90
randFunction · 0.90
randnFunction · 0.90
test_asmatrixMethod · 0.90
test_basicMethod · 0.90
test_scalar_indexingMethod · 0.90
test_boolean_indexingMethod · 0.90
test_list_indexingMethod · 0.90
__mul__Method · 0.85
IMethod · 0.85

Calls 1

matrixClass · 0.85

Tested by 6

test_asmatrixMethod · 0.72
test_basicMethod · 0.72
test_scalar_indexingMethod · 0.72
test_boolean_indexingMethod · 0.72
test_list_indexingMethod · 0.72