Skip to content

Issue I4: Unit Tests for Hello Synchrony Pipeline #8

@Ramdam17

Description

@Ramdam17

Description:

Add pytest unit tests for the Hello Synchrony notebook pipeline to ensure reproducibility.

Context:
Notebooks can silently break. Unit tests with shape checks and golden outputs ensure the pipeline keeps working.

Tasks:

  • Create tests/test_hello_synchrony.py
  • Test simulated data generation (shapes, dtypes)
  • Test synchrony computation (output shapes, value ranges)
  • Add "golden output" test: compare against saved expected values
  • Integrate with pytest

Acceptance Criteria:

  • At least 5 test functions
  • Tests cover: data generation, metric computation, output shapes
  • Golden output test with tolerance for floating-point
  • All tests pass with pytest tests/test_hello_synchrony.py

Example test structure:

import numpy as np
import pytest
from hypyp import analyses

def test_simulated_data_shape():
    data = generate_simulated_data(n_channels=32, n_epochs=10)
    assert data[0].shape == (10, 32, 1000)  # (epochs, channels, samples)

def test_plv_output_range():
    plv = analyses.compute_sync(data, metric='plv')
    assert np.all(plv >= 0) and np.all(plv <= 1)

def test_golden_output():
    result = run_hello_synchrony_pipeline(seed=42)
    expected = np.load('tests/golden/hello_synchrony_expected.npy')
    np.testing.assert_allclose(result, expected, rtol=1e-5)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions