From f21f9a0ed87334bb040b9fe33ea8636cd933373d Mon Sep 17 00:00:00 2001 From: jorenham Date: Wed, 11 Jun 2025 16:19:09 +0200 Subject: [PATCH 1/3] TYP: Fix invalid inline annotations in ``lib._function_base_impl`` --- numpy/lib/_function_base_impl.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/numpy/lib/_function_base_impl.py b/numpy/lib/_function_base_impl.py index 63346088b6e2..a4c5a240abdf 100644 --- a/numpy/lib/_function_base_impl.py +++ b/numpy/lib/_function_base_impl.py @@ -4711,14 +4711,14 @@ def _inverted_cdf(n, quantiles): def _quantile_ureduce_func( - a: np.array, - q: np.array, - weights: np.array, - axis: int | None = None, - out=None, - overwrite_input: bool = False, - method="linear", -) -> np.array: + a: np.ndarray, + q: np.ndarray, + weights: np.ndarray, + axis: int | None = None, + out: np.ndarray | None = None, + overwrite_input: bool = False, + method: str = "linear", +) -> np.ndarray: if q.ndim > 2: # The code below works fine for nd, but it might not have useful # semantics. For now, keep the supported dimensions the same as it was @@ -4784,13 +4784,13 @@ def _get_indexes(arr, virtual_indexes, valid_values_count): def _quantile( - arr: np.array, - quantiles: np.array, - axis: int = -1, - method="linear", - out=None, - weights=None, -): + arr: np.typing.ArrayLike, + quantiles: np.ndarray, + axis: int = -1, + method: str= "linear", + out: np.ndarray | None = None, + weights: np.typing.ArrayLike | None = None, +) -> np.ndarray: """ Private function that doesn't support extended axis or keepdims. These methods are extended to this function using _ureduce From f52ece5faee8065386eb147abfa4d263bee08fc3 Mon Sep 17 00:00:00 2001 From: jorenham Date: Wed, 11 Jun 2025 16:23:27 +0200 Subject: [PATCH 2/3] TYP: ``ruff check --fix`` --- numpy/lib/_function_base_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/lib/_function_base_impl.py b/numpy/lib/_function_base_impl.py index a4c5a240abdf..54d6c7e7e6b5 100644 --- a/numpy/lib/_function_base_impl.py +++ b/numpy/lib/_function_base_impl.py @@ -4787,7 +4787,7 @@ def _quantile( arr: np.typing.ArrayLike, quantiles: np.ndarray, axis: int = -1, - method: str= "linear", + method: str = "linear", out: np.ndarray | None = None, weights: np.typing.ArrayLike | None = None, ) -> np.ndarray: From be41eb51e7c5755f5f93be927be3277cffce05c8 Mon Sep 17 00:00:00 2001 From: jorenham Date: Wed, 11 Jun 2025 16:36:29 +0200 Subject: [PATCH 3/3] TYP: prevent inline annotation from causing a circular import error --- numpy/lib/_function_base_impl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numpy/lib/_function_base_impl.py b/numpy/lib/_function_base_impl.py index 54d6c7e7e6b5..f217af64fb4b 100644 --- a/numpy/lib/_function_base_impl.py +++ b/numpy/lib/_function_base_impl.py @@ -4784,12 +4784,12 @@ def _get_indexes(arr, virtual_indexes, valid_values_count): def _quantile( - arr: np.typing.ArrayLike, + arr: "np.typing.ArrayLike", quantiles: np.ndarray, axis: int = -1, method: str = "linear", out: np.ndarray | None = None, - weights: np.typing.ArrayLike | None = None, + weights: "np.typing.ArrayLike | None" = None, ) -> np.ndarray: """ Private function that doesn't support extended axis or keepdims.