Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 21, 2026

Implementation Plan for WithinSubjectSplitter

  • Analyze existing splitter patterns and understand WithinSubjectSplitter requirements
  • Design WithinSubjectSplitter class following existing patterns
  • Implement WithinSubjectSplitter in moabb/evaluations/splitters.py
  • Add WithinSubjectSplitter to init.py exports
  • Create/update tests in test_splits.py to include WithinSubjectSplitter
  • Ensure pytest parametrization compatibility
  • Run tests to validate implementation (45 tests passed)
  • Request code review
  • Address code review feedback (fixed typo, improved docstring)
  • Run security checks (0 alerts)
  • Fix pre-commit formatting issues
  • Update api.rst documentation
  • Update whats_new.rst with Bruno Aristimunha's name

Summary

Successfully implemented WithinSubjectSplitter following the existing codebase patterns. The implementation:

Key Features:

  • Performs k-fold cross-validation within each subject across all their sessions
  • Compatible with pytest parametrization
  • Follows the same design patterns as existing splitters
  • Supports custom cv_class with StratifiedKFold as default
  • Supports shuffle and random_state parameters

Files Changed:

  • moabb/evaluations/splitters.py: Added WithinSubjectSplitter class (105 lines)
  • moabb/evaluations/__init__.py: Exported WithinSubjectSplitter
  • moabb/tests/test_splits.py: Added tests for WithinSubjectSplitter (48 lines)
  • docs/source/api.rst: Added WithinSubjectSplitter to API documentation
  • docs/source/whats_new.rst: Added enhancement entry with Bruno Aristimunha's name

Testing:

  • All 45 tests in test_splits.py pass successfully
  • Code review completed with all feedback addressed
  • Security scan completed with 0 alerts
  • Pre-commit checks all pass
  • Documentation updated
Original prompt

This section details on the original issue you should resolve

<issue_title>Implement WithinSubjectSplitter.</issue_title>
<issue_description>We need to follow the same style, and needs to just be compatible with the current test, i.e., pytest parametrization.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 21, 2026 12:02
Co-authored-by: bruAristimunha <42702466+bruAristimunha@users.noreply.github.com>
Co-authored-by: bruAristimunha <42702466+bruAristimunha@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement WithinSubjectSplitter with pytest compatibility Implement WithinSubjectSplitter Jan 21, 2026
Copilot AI requested a review from bruAristimunha January 21, 2026 12:10
@bruAristimunha bruAristimunha requested review from Copilot and removed request for bruAristimunha January 21, 2026 12:27
@bruAristimunha
Copy link
Collaborator

@copilot solve the precommit

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements WithinSubjectSplitter, a new cross-validation splitter that performs k-fold splits within each subject across all their sessions. This completes the splitter API alongside existing splitters for within-session, cross-session, and cross-subject evaluation strategies.

Changes:

  • Added WithinSubjectSplitter class with stratified k-fold cross-validation across all sessions within each subject
  • Exported the new splitter in the public API
  • Added comprehensive test coverage with parametrized tests for compatibility and split counting

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
moabb/evaluations/splitters.py Implemented WithinSubjectSplitter class following the same pattern as WithinSessionSplitter; fixed typo "cros-validation" → "cross-validation"
moabb/evaluations/init.py Exported WithinSubjectSplitter in the public API
moabb/tests/test_splits.py Added test_within_subject_compatibility, test_within_subject_get_n_splits, and extended test_custom_inner_cv parametrization; implemented eval_split_within_subject helper function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: bruAristimunha <42702466+bruAristimunha@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 21, 2026

@copilot solve the precommit

Fixed in commit 84dc538. Black reformatted the test file to split the long splitter list across multiple lines. All pre-commit checks now pass.

@bruAristimunha
Copy link
Collaborator

You are missing the api.rst documentation, can you update?

@bruAristimunha
Copy link
Collaborator

@copilot, you are missing the api, the RST documentation, and the What's New " file (put my name Bruno Aristimunha). Can you update?

Co-authored-by: bruAristimunha <42702466+bruAristimunha@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 21, 2026

@copilot, you are missing the api, the RST documentation, and the What's New " file (put my name Bruno Aristimunha). Can you update?

Updated in commit eebd49d. Added WithinSubjectSplitter to api.rst documentation and added enhancement entry in whats_new.rst with your name (Bruno Aristimunha).

@bruAristimunha bruAristimunha marked this pull request as ready for review January 21, 2026 19:34
@bruAristimunha bruAristimunha enabled auto-merge (squash) January 21, 2026 20:20
@bruAristimunha bruAristimunha enabled auto-merge (squash) January 21, 2026 20:20
@bruAristimunha bruAristimunha merged commit 45cd0f8 into develop Jan 21, 2026
13 of 14 checks passed
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.

Implement WithinSubjectSplitter.

2 participants