MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __init__

Method __init__

matrix/matrix_class.py:110–128  ·  view source on GitHub ↗
(self, rows: list[list[int]])

Source from the content-addressed store, hash-verified

108 """
109
110 def __init__(self, rows: list[list[int]]):
111 error = TypeError(
112 "Matrices must be formed from a list of zero or more lists containing at "
113 "least one and the same number of values, each of which must be of type "
114 "int or float."
115 )
116 if len(rows) != 0:
117 cols = len(rows[0])
118 if cols == 0:
119 raise error
120 for row in rows:
121 if len(row) != cols:
122 raise error
123 for value in row:
124 if not isinstance(value, (int, float)):
125 raise error
126 self.rows = rows
127 else:
128 self.rows = []
129
130 # MATRIX INFORMATION
131 def columns(self) -> list[list[int]]:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected