From a03324c4afc555c77a64508e2d3c94dd9e5c746b Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Fri, 30 Aug 2024 18:16:28 +0100 Subject: [PATCH] Temporarily ignore 2 mypy type-var errors caused by the more precise type annotation of ``numpy.number`` comparison operators introduced in NumPy 2.1, see: https://github.com/python/typeshed/issues/12562 Fix the following errors when running test_galaxy_packages on Python >=3.10: ``` galaxy/tool_util/verify/__init__.py:503: error: Value of type variable "SupportsRichComparisonT" of "max" cannot be "floating[Any]" [type-var] iou_list.append(max(cc1_iou_list)) ^~~~~~~~~~~~~~~~~ galaxy/tool_util/verify/__init__.py:532: error: Value of type variable "SupportsRichComparisonT" of "min" cannot be "floating[Any]" [type-var] return min(_multiobject_intersection_over_union(mask1, mask2, pin_labels)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` --- lib/galaxy/tool_util/verify/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/tool_util/verify/__init__.py b/lib/galaxy/tool_util/verify/__init__.py index e54a70c9d7af..54b5eb80062b 100644 --- a/lib/galaxy/tool_util/verify/__init__.py +++ b/lib/galaxy/tool_util/verify/__init__.py @@ -455,14 +455,14 @@ def files_contains(file1, file2, attributes=None): def _multiobject_intersection_over_union( mask1: "numpy.typing.NDArray", mask2: "numpy.typing.NDArray", repeat_reverse: bool = True ) -> List["numpy.floating"]: - iou_list = [] + iou_list: List[numpy.floating] = [] for label1 in numpy.unique(mask1): cc1 = mask1 == label1 - cc1_iou_list = [] + cc1_iou_list: List[numpy.floating] = [] for label2 in numpy.unique(mask2[cc1]): cc2 = mask2 == label2 cc1_iou_list.append(intersection_over_union(cc1, cc2)) - iou_list.append(max(cc1_iou_list)) + iou_list.append(max(cc1_iou_list)) # type: ignore[type-var, unused-ignore] # https://github.com/python/typeshed/issues/12562 if repeat_reverse: iou_list.extend(_multiobject_intersection_over_union(mask2, mask1, repeat_reverse=False)) return iou_list @@ -475,7 +475,7 @@ def intersection_over_union(mask1: "numpy.typing.NDArray", mask2: "numpy.typing. if mask1.dtype == bool: return numpy.logical_and(mask1, mask2).sum() / numpy.logical_or(mask1, mask2).sum() else: - return min(_multiobject_intersection_over_union(mask1, mask2)) + return min(_multiobject_intersection_over_union(mask1, mask2)) # type: ignore[type-var, unused-ignore] # https://github.com/python/typeshed/issues/12562 def get_image_metric(