Refactor detection input validation into helper function#600
Open
mani6409 wants to merge 2 commits intobrainglobe:mainfrom
Open
Refactor detection input validation into helper function#600mani6409 wants to merge 2 commits intobrainglobe:mainfrom
mani6409 wants to merge 2 commits intobrainglobe:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
What is this PR
Bug fix
Addition of a new feature
Other
Refactor of detection input validation.
Why is this PR needed?
The validation logic for the detection pipeline parameters was previously embedded directly inside the main() function in detect.py. Keeping validation logic inside the main pipeline makes the function harder to read and maintain. Extracting this logic into a separate helper function improves code readability, maintainability, and separation of concerns while preserving the existing behaviour.
What does this PR do?
Introduces a helper function _validate_detection_inputs in cellfinder/core/detect/detect.py.
Moves input validation logic from the main() function into this helper function.
Preserves the original error messages to ensure compatibility with existing tests.
Improves code structure by separating validation logic from the main detection pipeline.
References
No related issue. This PR focuses on improving internal code structure and maintainability.
How has this PR been tested?
The full test suite was executed locally using pytest. All tests pass successfully after the refactor, confirming that the behaviour of the detection pipeline remains unchanged.
Is this a breaking change?
No. This change does not alter the external API or behaviour of the detection pipeline. Existing functionality and error messages are preserved.
Does this PR require an update to the documentation?
No documentation updates are required, as this change is an internal refactor and does not modify user-facing functionality.
Checklist:
The code has been tested locally
Tests have been added to cover all new functionality (not required for this refactor)
The documentation has been updated to reflect any changes (not required)
The code has been formatted with pre-commit