Check if given indices are valid to pick element from matrix. Example: >>> a = Matrix(2, 6, 0) >>> a.validate_indices((2, 7)) False >>> a.validate_indices((0, 0)) True
(self, loc: tuple[int, int])
| 55 | return str(self) |
| 56 | |
| 57 | def validate_indices(self, loc: tuple[int, int]) -> bool: |
| 58 | """ |
| 59 | <method Matrix.validate_indicies> |
| 60 | Check if given indices are valid to pick element from matrix. |
| 61 | Example: |
| 62 | >>> a = Matrix(2, 6, 0) |
| 63 | >>> a.validate_indices((2, 7)) |
| 64 | False |
| 65 | >>> a.validate_indices((0, 0)) |
| 66 | True |
| 67 | """ |
| 68 | if not (isinstance(loc, (list, tuple)) and len(loc) == 2): # noqa: SIM114 |
| 69 | return False |
| 70 | elif not (0 <= loc[0] < self.row and 0 <= loc[1] < self.column): |
| 71 | return False |
| 72 | else: |
| 73 | return True |
| 74 | |
| 75 | def __getitem__(self, loc: tuple[int, int]) -> Any: |
| 76 | """ |
no outgoing calls
no test coverage detected