Skip to content

Conversation

@Jiaqi-Lv
Copy link
Collaborator

@Jiaqi-Lv Jiaqi-Lv commented May 1, 2025

Revisited some of the files from tools/ and utils/, updated typing for them.

@Jiaqi-Lv Jiaqi-Lv self-assigned this May 1, 2025
@Jiaqi-Lv Jiaqi-Lv added the dev tools Changes/Updates in Development tools label May 1, 2025
@Jiaqi-Lv Jiaqi-Lv requested a review from Copilot May 1, 2025 15:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request revisits several files in the tools and utils directories to update type annotations and improve type safety. Key changes include the adoption of explicit type annotations for contour arrays in visualization, refined output size handling in transforms, and improved type annotations for feature extraction and patch extraction components.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tiatoolbox/utils/visualization.py Updated contour type annotation and replaced numpy array conversion with cv2.Mat for drawing functions.
tiatoolbox/utils/transforms.py Modified cv2.resize dsize parameter to explicitly construct a size tuple.
tiatoolbox/tools/registration/wsi_registration.py Updated type annotations and cast usages for feature extraction components.
tiatoolbox/tools/patchextraction.py Revised input_mask type declarations to include AnnotationStore.
Comments suppressed due to low confidence (3)

tiatoolbox/tools/registration/wsi_registration.py:341

  • [nitpick] Consider whether using torch.Tensor() as a placeholder is appropriate; if these feature tensors are uninitialized, an Optional type (or using None) might better convey the intended semantics.
self.features: dict[str, torch.Tensor] = dict.fromkeys(output_layers_key, torch.Tensor())

tiatoolbox/utils/visualization.py:485

  • Ensure that using cv2.Mat for converting contours is supported by your target OpenCV version, as the Python API typically expects numpy arrays for cv2.drawContours.
[cv2.Mat(inst_contour)]

tiatoolbox/utils/visualization.py:886

  • Verify that converting the contour to cv2.Mat here is intentional and compatible with cv2.polylines in your OpenCV version; traditionally, numpy arrays are used.
[cv2.Mat(cnt)]

@Jiaqi-Lv Jiaqi-Lv changed the title mypy type check tools/ and utils/ 🔧 mypy type check tools/ and utils/ May 1, 2025
@codecov
Copy link

codecov bot commented May 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.70%. Comparing base (7ba7394) to head (d3700d3).
⚠️ Report is 17 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #931   +/-   ##
========================================
  Coverage    99.70%   99.70%           
========================================
  Files           71       71           
  Lines         8847     8851    +4     
  Branches      1154     1154           
========================================
+ Hits          8821     8825    +4     
  Misses          23       23           
  Partials         3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Jiaqi-Lv Jiaqi-Lv marked this pull request as ready for review May 2, 2025 09:56
@Jiaqi-Lv Jiaqi-Lv requested a review from Copilot May 2, 2025 09:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates type annotations and typing usage in the tools and utils directories to improve mypy type checking.

  • Adds explicit type annotations in visualization and transforms modules.
  • Revises type declarations and cast usage in the wsi_registration module.
  • Adjusts input type handling in the patchextraction module.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tiatoolbox/utils/visualization.py Added explicit type annotations for contours and polylines in visualization.
tiatoolbox/utils/transforms.py Refined the dsize parameter by converting output_size_array to a tuple.
tiatoolbox/tools/registration/wsi_registration.py Updated type annotations, cast usage, and function signatures in feature extraction.
tiatoolbox/tools/patchextraction.py Improved input_mask type checks and updated imports for AnnotationStore.

@shaneahmed shaneahmed added this to the Release v1.7.0 milestone May 2, 2025
@shaneahmed shaneahmed merged commit c05a6b7 into develop May 2, 2025
15 checks passed
@shaneahmed shaneahmed deleted the mypy-update-old-files branch May 2, 2025 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev tools Changes/Updates in Development tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants