Types: Adjust type hints to incorporate None as the targets #571
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.
This pull request introduces changes to improve type annotations, enhance readability, and ensure consistency across multiple files in the
pytorch_grad_cam
library. The most important changes include updating function signatures to useOptional
for nullable parameters, improving formatting for better readability, and refining type annotations for clarity.Type Annotation Improvements:
pytorch_grad_cam/ablation_cam.py
,pytorch_grad_cam/base_cam.py
,pytorch_grad_cam/feature_factorization/deep_feature_factorization.py
,pytorch_grad_cam/finer_cam.py
, andpytorch_grad_cam/utils/image.py
) to useOptional
for nullable parameters, such asreshape_transform
,targets
, andconcept_labels
. [1] [2] [3] [4] [5] [6]Code Formatting Enhancements:
__init__
,forward
, and other methods across several files. [1] [2] [3] [4]Import Statement Refinements:
Optional
to relevant imports and removed unused modules likemath
andmatplotlib
inpytorch_grad_cam/utils/image.py
. [1] [2] [3]These changes collectively improve the maintainability and clarity of the codebase while ensuring type safety for nullable parameters.