Command Line Scripts#

This project includes standalone scripts located in the scripts/ directory.

Matrix Multiplier (run_matrix.py)#

This script demonstrates the usage of our internal mypkgs.math library.

Click to view the source code
 1"""
 2Example script demonstrating matrix multiplication from the mypkgs library.
 3
 4This script initializes two sample matrices and utilizes the custom 
 5`multiply_matrices` function to calculate and print their dot product.
 6"""
 7
 8import numpy as np
 9
10from mypkgs.math import multiply_matrices
11
12
13def main() -> None:
14    """
15    Execute a simple matrix multiplication demonstration.
16
17    Initializes two 2x2 matrices and computes their dot product using
18    the custom `multiply_matrices` function, handling any potential
19    dimension mismatch errors.
20
21    Parameters
22    ----------
23    None
24
25    Returns
26    -------
27    None
28    """
29    print("Initializing matrices...")
30
31    # Create two simple 2x2 matrices
32    a = np.array([
33        [1.0, 2.0],
34        [3.0, 4.0]
35    ])
36
37    b = np.array([
38        [2.0, 0.0],
39        [1.0, 2.0]
40    ])
41
42    print(f"Matrix A:\n{a}\n")
43    print(f"Matrix B:\n{b}\n")
44
45    # Perform multiplication using our custom module
46    try:
47        result = multiply_matrices(a, b)
48        print(f"Result of A @ B:\n{result}")
49    except ValueError as e:
50        print(f"Error: {e}")
51
52
53if __name__ == "__main__":
54    main()