Skip to content

Refactor detection input validation into helper function#600

Open
mani6409 wants to merge 2 commits intobrainglobe:mainfrom
mani6409:detection-validation-final
Open

Refactor detection input validation into helper function#600
mani6409 wants to merge 2 commits intobrainglobe:mainfrom
mani6409:detection-validation-final

Conversation

@mani6409
Copy link
Copy Markdown

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

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