from okrolearn.src.okrolearn import *
def test_conv1d_layer():
    # Initialize layer
    in_channels, out_channels, kernel_size = 3, 2, 3
    conv1d = Conv1DLayer(in_channels, out_channels, kernel_size, stride=1, padding=0)
    
    # Set deterministic weights and biases for testing
    conv1d.weights.data = np.array([[[1, 2, 3],
                                     [4, 5, 6],
                                     [7, 8, 9]],
                                    [[9, 8, 7],
                                     [6, 5, 4],
                                     [3, 2, 1]]])
    conv1d.biases.data = np.array([[1], [2]])
    
    # Create input
    input_data = np.array([[[ 1,  2,  3,  4,  5],
                            [ 6,  7,  8,  9, 10],
                            [11, 12, 13, 14, 15]]])
    inputs = Tensor(input_data)
    
    # Forward pass
    output = conv1d.forward(inputs)
    
    # Print output for debugging
    print("Conv1D Output:")
    print(output.data)
    
    # Expected output (calculated manually)
    expected_output = np.array([[[339, 369, 399],
                                 [255, 276, 297]]])
    
    # Print expected output for comparison
    print("Expected Output:")
    print(expected_output)
    
    # Check if forward pass is correct with a tolerance
    if np.allclose(output.data, expected_output, atol=1e-3):
        print("Conv1D forward pass succeeded!")
    else:
        print("Conv1D forward pass failed. Difference:")
        print(output.data - expected_output)
    
    # Rest of the test remains the same...

# Run the test
test_conv1d_layer()
