Skip to content

Comments

feat: add validation for duplicate structure acronyms#734

Merged
IgorTatarnikov merged 6 commits intobrainglobe:mainfrom
thisisrick25:thisisrick25/issue666
Jan 12, 2026
Merged

feat: add validation for duplicate structure acronyms#734
IgorTatarnikov merged 6 commits intobrainglobe:mainfrom
thisisrick25:thisisrick25/issue666

Conversation

@thisisrick25
Copy link
Contributor

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?

Closes #666

Duplicate structure acronyms are incompatible with the current implementation of brainglobe-atlasapi as acronyms are used as primary keys to fetch region details. This validation catches such issues during atlas generation.

What does this PR do?

Adds a validate_unique_acronyms function that checks for duplicate acronyms in atlas structures during validation and raises an AssertionError with a meaningful error message listing the duplicate acronyms.

References

How has this PR been tested?

  • Added test_validate_unique_acronyms_fail test that mocks atlas structures with duplicate acronyms and verifies the validation fails with the expected error message
  • The existing test_valid_atlas_passes_all_validations test will automatically verify the function passes on valid atlases

Is this a breaking change?

No!

Does this PR require an update to the documentation?

No, this is an internal validation function used during atlas generation.

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality (unit & integration)
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

Closes brainglobe#666

Added `validate_unique_acronyms` function that checks for duplicate
acronyms in atlas structures during validation. Duplicate acronyms
are incompatible with brainglobe-atlasapi as acronyms are used as
primary keys to fetch region details.

Changes:
- Add `validate_unique_acronyms` validation function
- Register function in `get_all_validation_functions()`
- Add test for failure case with duplicate acronyms
Copilot AI review requested due to automatic review settings January 3, 2026 21:00
Copy link

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 adds validation to detect duplicate structure acronyms during atlas generation. Duplicate acronyms are problematic because they're used as primary keys to fetch region details in brainglobe-atlasapi.

Key changes:

  • Added validate_unique_acronyms() function that checks for duplicate acronyms in atlas structures
  • Integrated the validation into the existing validation pipeline
  • Added test coverage for the duplicate detection failure case

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
brainglobe_atlasapi/atlas_generation/validate_atlases.py Implements the validate_unique_acronyms() function and adds it to validation function lists
tests/atlasgen/test_validation.py Adds test case for duplicate acronym detection failure scenario

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

Copy link
Member

@IgorTatarnikov IgorTatarnikov left a comment

Choose a reason for hiding this comment

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

This is great, thank you @thisisrick25!

I had a few comments regarding the implementation. We can decrease the time complexity of this code by adjusting the approach slightly.

Copy link
Member

@IgorTatarnikov IgorTatarnikov left a comment

Choose a reason for hiding this comment

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

LGTM 🚀 Thanks @thisisrick25

@IgorTatarnikov IgorTatarnikov merged commit 4bcbf69 into brainglobe:main Jan 12, 2026
13 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.

[Feature] Check for duplicate acronyms during validation of atlases

2 participants