MCPcopy Index your code
hub / github.com/numpy/numpy / asmatrix

Function asmatrix

numpy/matrixlib/defmatrix.py:37–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

35
36@set_module('numpy')
37def asmatrix(data, dtype=None):
38 """
39 Interpret the input as a matrix.
40
41 Unlike `matrix`, `asmatrix` does not make a copy if the input is already
42 a matrix or an ndarray. Equivalent to ``matrix(data, copy=False)``.
43
44 Parameters
45 ----------
46 data : array_like
47 Input data.
48 dtype : data-type
49 Data-type of the output matrix.
50
51 Returns
52 -------
53 mat : matrix
54 `data` interpreted as a matrix.
55
56 Examples
57 --------
58 >>> import numpy as np
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 12

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
test_returntypeMethod · 0.90
__mul__Method · 0.85
IMethod · 0.85

Calls 1

matrixClass · 0.85

Tested by 7

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…