#!/usr/bin/env python

import myext
import numpy as np

# Test 1: Square calculation
print("=" * 60)
print("Test 1: Square calculation")
arr1 = np.array([1.0, 2.0, 3.0, 4.0, 5.0], dtype=np.float64)
print(f"Input array: {arr1}")
result1 = myext.square(arr1)
print(f"Square result: {result1}")

# Test 2: Element-wise multiplication of two 2D matrices
print("\n" + "=" * 60)
print("Test 2: Element-wise multiplication of two 2D matrices")
arr1 = np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], dtype=np.float64)
arr2 = np.array([[10.0, 20.0, 30.0], [40.0, 50.0, 60.0]], dtype=np.float64)
print(f"Array 1:\n{arr1}")
print(f"Array 2:\n{arr2}")
result2 = myext.ew_multiply(arr1, arr2)
print(f"Element-wise multiplication result:\n{result2}")

# Test 3: compute mean(axis=0) of a 2D array
print("\n" + "=" * 60)
print("Test 3: Mean calculationcompute mean(axis=0) of a 2D array")
arr = np.vstack([arr1, arr2])
print(f"Array:\n{arr}")
print(f"Mean of array:\n{myext.mean_row(arr)}")

# Test 4: In-place array modification   
print("\n" + "=" * 60)
print("Test 4: In-place array modification")
arr3 = np.array([1.0, 2.0, 3.0], dtype=np.float64)
print(f"Before modification:\n{arr3}")
myext.multiply_inplace(arr3)
print(f"After modification:\n{arr3}")


# Test 5: Double all elements in a list and return new list
print("\n" + "=" * 60)
print("Test 5: Double all elements in a list and return new list")
float_list = [1.5, 2.5, 3.5, 4.5]
print(f"\nFloat list: {float_list}")
doubled = myext.double_list(float_list)
print(f"Doubled values: {doubled}")

# Test 6: Calculate statistics from a tuple of numbers
print("\n" + "=" * 60)
print("Test 6: Calculate statistics from a tuple of numbers")
triplet = (10.0, 20.0, 30.0)
print(f"Input tuple: {triplet}")
sum_val, mean_val, product_val = myext.calculate_statistics(triplet)
print(f"Sum: {sum_val}, Mean: {mean_val}, Product: {product_val}")

# Test 7: Calculate area of a rectangle
print("\n" + "=" * 60)
print("Test 7: Calculate area of a rectangle")
length, width = 12.5, 8.3
area = myext.rectangle_area(length, width)
print(f"Rectangle area ({length} x {width}): {area}")

# Test 8: Dictionary operations
print("\n" + "=" * 60)
print("Test 8: ")
student = myext.create_student_record("Alice Johnson", 20, [85.5, 92.0, 78.5, 88.0])
print("Student record:")
for key, value in student.items():
    print(f"  {key}: {value}")

print("\n" + "=" * 60)
print("ALL TESTS COMPLETED SUCCESSFULLY")
print("=" * 60)