feat: Set up comprehensive Python testing infrastructure with Poetry #30
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.
Add Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the Vision Transformer (ViT) explainability project using Poetry as the package manager and pytest as the testing framework.
Changes Made
Package Management
pyproject.tomlwith Poetry setup as the primary package managerTesting Framework Setup
pytest Configuration:
unit,integration, andslowDirectory Structure:
Test Fixtures
Created comprehensive fixtures in
conftest.py:temp_dir: Temporary directory managementsample_image: Test image generationsample_tensor: PyTorch tensor creationmock_model: Mock Vision Transformer modelattention_rollout_config&grad_rollout_config: Test configurationsmock_attention_weights&mock_gradients: Mock data for testingoutput_dir: Test output directory managementreset_torch_hub_dir: Prevents model downloads during testsAdditional Configuration
poetry run testandpoetry run testscommandsHow to Use
Install dependencies:
Run all tests:
Run specific test types:
View coverage report:
# After running tests, open the HTML report open htmlcov/index.htmlNotes
Next Steps
Developers can now start writing unit and integration tests for the existing modules:
vit_explain.pyvit_grad_rollout.pyvit_rollout.py