This repository contains a Python implementation of a cursor for NumPy matrices. The cursor allows you to conveniently move through a matrix and read or modify its values.
The cursor class has the following methods:
__init__(self, matrix): Initializes the cursor with a NumPy matrix.left(self, steps=1): Moves the cursor left bystepscolumns.right(self, steps=1): Moves the cursor right bystepscolumns.up(self, steps=1): Moves the cursor up bystepsrows.down(self, steps=1): Moves the cursor down bystepsrows.move(self, row_steps, col_steps): Moves the cursor byrow_stepsrows andcol_stepscolumns.set(self, row, col): Set the cursor byrowrows andcolcolumns.coordinates: Returns the current row and column coordinates of the cursor.isEmpty: ReturnsTrueif the value of the matrix at the current cursor position is zero, andFalseotherwise.setItem(self, item): Setting the value of the cursor cell byitem.__repr__(self): Returns a string representation of the value of the matrix at the current cursor position.__str__(self): Returns a string representation of the value of the matrix at the current cursor position.
The implementation also includes error checking to prevent moving the cursor beyond the boundaries of the matrix.