Skip to content

Add NDR symmetry testing framework for cross-language validation#100

Merged
stevevanhooser merged 5 commits intomainfrom
claude/add-symmetry-tests-U0CE9
Apr 11, 2026
Merged

Add NDR symmetry testing framework for cross-language validation#100
stevevanhooser merged 5 commits intomainfrom
claude/add-symmetry-tests-U0CE9

Conversation

@stevevanhooser
Copy link
Copy Markdown
Contributor

Summary

This PR introduces a comprehensive symmetry testing framework for NDR that enables validation of data reading and artifact generation across MATLAB and Python implementations. The framework ensures numerical parity between language ports by generating standardized artifacts and verifying them against expected values.

Key Changes

  • GitHub Actions Workflow (test-symmetry.yml): Added automated CI/CD pipeline that:

    • Sets up MATLAB with required toolboxes (Signal Processing, Statistics and Machine Learning)
    • Installs MatBox for dependency management
    • Discovers and runs both makeArtifacts and readArtifacts test suites
    • Provides detailed test reporting with pass/fail/incomplete counts
    • Runs on push to main, pull requests, and manual dispatch
  • Artifact Generation Tests (+makeArtifacts/+reader/readData.m):

    • Reads example RHD data through ndr.reader.intan_rhd
    • Generates metadata.json with channel info, sample rates, time boundaries, and epoch clock types
    • Generates readData.json with a deterministic 100-sample chunk for numerical verification
    • Stores artifacts in standardized temp directory structure for cross-language access
  • Artifact Verification Tests (+readArtifacts/+reader/readData.m):

    • Parameterized tests that validate against both matlabArtifacts and pythonArtifacts
    • Gracefully skips when artifact sources are unavailable
    • Verifies sample rates, time boundaries, and raw data samples with appropriate tolerances
    • Enables bidirectional parity checking (MATLAB→Python and Python→MATLAB)
  • Documentation: Added comprehensive INSTRUCTIONS.md files explaining:

    • Directory structure conventions for artifact storage
    • Rules for artifact generation and persistence
    • Testing patterns using MATLAB's parameterized test framework
    • Examples and running instructions

Implementation Details

  • Artifacts are stored in tempdir()/NDR/symmetryTest/<sourceType>/<namespace>/<class>/<test>/ following a consistent convention
  • Tests use jsonencode/jsondecode for language-agnostic data exchange
  • Numerical comparisons use appropriate absolute tolerances (1e-9 for sample data, 1e-6 for time values)
  • Tests assume the presence of example_data/example.rhd in the NDR-matlab repository for deterministic inputs

https://claude.ai/code/session_01BWkrpUgzWSQx48s8Tk6fnT

Mirrors the symmetry test framework introduced in NDI-matlab /
NDI-python so that NDR-matlab and NDR-python can verify that they
read and interpret example data identically.

- Add +makeArtifacts and +readArtifacts sub-packages under
  tools/tests/+ndr/+symmetry with INSTRUCTIONS.md for each phase.
- Add an example reader.readData pair that dumps channel metadata
  and a short sample of Intan RHD data to JSON and verifies it
  against artifacts produced by either the MATLAB or Python suites.
Runs the MATLAB +makeArtifacts and +readArtifacts test packages on
pushes to main, pull requests targeting main, and manual dispatch.
This workflow is separate from the regular run_tests.yml CI so that
the cross-language symmetry suite can evolve independently.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 11, 2026

Test Results

126 tests  +3   126 ✅ +3   5s ⏱️ -1s
 16 suites +2     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 1a97cc6. ± Comparison against base commit 5c5c19e.

♻️ This comment has been updated with latest results.

github-actions bot and others added 2 commits April 11, 2026 21:10
Two issues were causing the workflow to fail before any tests ran:

1. `addpath(genpath("+ndr"))` is invalid because MATLAB namespace
   directories (anything starting with `+`) must not themselves
   appear on the path -- only their parent directories. Replace
   with `addpath(pwd)` plus `addpath(tools/tests)` so both the
   repo-root `+ndr` and the test `+ndr/+symmetry` packages are
   discoverable.

2. `ndr_Init` tried to `mkdir` a filecache path under `userpath`
   which isn't writable on the CI runner. The symmetry tests only
   need `ndr.fun.ndrpath()` (self-contained), so skip `ndr_Init`
   entirely.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 32.76%. Comparing base (5c5c19e) to head (1a97cc6).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #100      +/-   ##
==========================================
+ Coverage   31.95%   32.76%   +0.81%     
==========================================
  Files          92       92              
  Lines        4810     4810              
==========================================
+ Hits         1537     1576      +39     
+ Misses       3273     3234      -39     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The readData make-artifact test calls ndr.reader.intan_rhd methods
that depend on vlt.string.strcmp_substitution from
vhlab-toolbox-matlab. That dependency is declared in
tools/requirements.txt but nothing was installing it in the symmetry
CI. Call matbox.installRequirements(tools) to fetch and add it to
the path, matching how NDI-matlab's symmetry CI handles requirements.
@stevevanhooser stevevanhooser merged commit 0ec206b into main Apr 11, 2026
6 of 7 checks passed
@stevevanhooser stevevanhooser deleted the claude/add-symmetry-tests-U0CE9 branch April 11, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant