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

Method __setitem__

matrix/sherman_morrison.py:87–100  ·  view source on GitHub ↗

Set array[row][column] = value where loc = (row, column). Example: >>> a = Matrix(2, 3, 1) >>> a[1, 2] = 51 >>> a Matrix consist of 2 rows and 3 columns [ 1, 1, 1] [ 1, 1, 51]

(self, loc: tuple[int, int], value: float)

Source from the content-addressed store, hash-verified

85 return self.array[loc[0]][loc[1]]
86
87 def __setitem__(self, loc: tuple[int, int], value: float) -> None:
88 """
89 <method Matrix.__setitem__>
90 Set array[row][column] = value where loc = (row, column).
91 Example:
92 >>> a = Matrix(2, 3, 1)
93 >>> a[1, 2] = 51
94 >>> a
95 Matrix consist of 2 rows and 3 columns
96 [ 1, 1, 1]
97 [ 1, 1, 51]
98 """
99 assert self.validate_indices(loc)
100 self.array[loc[0]][loc[1]] = value
101
102 def __add__(self, another: Matrix) -> Matrix:
103 """

Callers

nothing calls this directly

Calls 1

validate_indicesMethod · 0.95

Tested by

no test coverage detected