fix(visualization): remove fields overiddes when set to None#3037
fix(visualization): remove fields overiddes when set to None#3037donnadamus wants to merge 6 commits intoopen-edge-platform:mainfrom
Conversation
I was trying to just visualize image+heatmap, but the current code overrides the fields and if set to None, it would set it ["image", "gt_mask"], forcing the user to also save the original image Signed-off-by: Marco Donnarumma <126296999+donnadamus@users.noreply.github.com>
Fix default fields initialization in visualizer
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where the fields parameter in the Visualizer class was being overridden with a default value ["image", "gt_mask"] when set to None, preventing users from visualizing only image+heatmap combinations without including the original image field.
Key changes:
- Removed the default fallback value for the
fieldsparameter when it is explicitly set toNone
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| ) -> None: | ||
| super().__init__() | ||
| self.fields = fields or ["image", "gt_mask"] | ||
| self.fields = fields |
There was a problem hiding this comment.
Setting self.fields = fields without a fallback allows None to be assigned directly. This could cause issues downstream if code expects self.fields to be a list. Consider checking whether fields being None is handled properly throughout the class, or document this behavior explicitly if None is a valid value for visualization logic.
| self.fields = fields | |
| self.fields = fields or ["image", "gt_mask"] |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
|
||
| def __init__( | ||
| self, | ||
| fields: list[str] | None = None, |
There was a problem hiding this comment.
Apologies for the super late review. Maybe it might be an idea to replace with
| fields: list[str] | None = ["image", "gt_mask"], |
This way the default behaviour remains the same
📝 Description
I was trying to just visualize image+heatmap, but the current code overrides the fields and if set to None, it would set it ["image", "gt_mask"], forcing the user to also save the original image
✨ Changes
Select what type of change your PR is:
✅ Checklist
Before you submit your pull request, please make sure you have completed the following steps:
For more information about code review checklists, see the Code Review Checklist.