MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / component

Method component

linear_algebra/src/lib.py:135–143  ·  view source on GitHub ↗

input: index (0-indexed) output: the i-th component of the vector.

(self, i: int)

Source from the content-addressed store, hash-verified

133 return Vector(self.__components)
134
135 def component(self, i: int) -> float:
136 """
137 input: index (0-indexed)
138 output: the i-th component of the vector.
139 """
140 if isinstance(i, int) and -len(self.__components) <= i < len(self.__components):
141 return self.__components[i]
142 else:
143 raise Exception("index out of range")
144
145 def change_component(self, pos: int, value: float) -> None:
146 """

Callers 10

__eq__Method · 0.95
test_componentMethod · 0.95
__add__Method · 0.45
__sub__Method · 0.45
__mul__Method · 0.45
__add__Method · 0.45
__sub__Method · 0.45
__mul__Method · 0.45
test_addMethod · 0.45
test_subMethod · 0.45

Calls

no outgoing calls

Tested by 3

test_componentMethod · 0.76
test_addMethod · 0.36
test_subMethod · 0.36