From f4bd92bdaaee1e6c5a47ecedfe944e35efa6007e Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Mon, 19 Jun 2023 17:44:30 +0100 Subject: [PATCH 1/2] fix numba typing --- pandas/core/_numba/kernels/mean_.py | 4 +++- pandas/core/_numba/kernels/var_.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pandas/core/_numba/kernels/mean_.py b/pandas/core/_numba/kernels/mean_.py index 8774ff72af852..809b939dc7c48 100644 --- a/pandas/core/_numba/kernels/mean_.py +++ b/pandas/core/_numba/kernels/mean_.py @@ -8,6 +8,8 @@ """ from __future__ import annotations +from typing import cast + import numba import numpy as np @@ -82,7 +84,7 @@ def sliding_mean( s = start[i] e = end[i] if i == 0 or not is_monotonic_increasing_bounds: - prev_value = values[s] + prev_value = cast(float, values[s]) num_consecutive_same_value = 0 for j in range(s, e): diff --git a/pandas/core/_numba/kernels/var_.py b/pandas/core/_numba/kernels/var_.py index e0f46ba6e3805..3f7e2f8dc0845 100644 --- a/pandas/core/_numba/kernels/var_.py +++ b/pandas/core/_numba/kernels/var_.py @@ -8,6 +8,8 @@ """ from __future__ import annotations +from typing import cast + import numba import numpy as np @@ -92,7 +94,7 @@ def sliding_var( s = start[i] e = end[i] if i == 0 or not is_monotonic_increasing_bounds: - prev_value = values[s] + prev_value = cast(float, values[s]) num_consecutive_same_value = 0 for j in range(s, e): From 9b200ad37868c17026f370a4604e655ae1c087ac Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Mon, 19 Jun 2023 19:23:10 +0100 Subject: [PATCH 2/2] type ignore --- pandas/core/_numba/kernels/mean_.py | 8 +++----- pandas/core/_numba/kernels/var_.py | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/pandas/core/_numba/kernels/mean_.py b/pandas/core/_numba/kernels/mean_.py index 809b939dc7c48..2903c7d81bbc0 100644 --- a/pandas/core/_numba/kernels/mean_.py +++ b/pandas/core/_numba/kernels/mean_.py @@ -8,8 +8,6 @@ """ from __future__ import annotations -from typing import cast - import numba import numpy as np @@ -84,7 +82,7 @@ def sliding_mean( s = start[i] e = end[i] if i == 0 or not is_monotonic_increasing_bounds: - prev_value = cast(float, values[s]) + prev_value = values[s] num_consecutive_same_value = 0 for j in range(s, e): @@ -103,7 +101,7 @@ def sliding_mean( neg_ct, compensation_add, num_consecutive_same_value, - prev_value, + prev_value, # pyright: ignore[reportGeneralTypeIssues] ) else: for j in range(start[i - 1], s): @@ -128,7 +126,7 @@ def sliding_mean( neg_ct, compensation_add, num_consecutive_same_value, - prev_value, + prev_value, # pyright: ignore[reportGeneralTypeIssues] ) if nobs >= min_periods and nobs > 0: diff --git a/pandas/core/_numba/kernels/var_.py b/pandas/core/_numba/kernels/var_.py index 3f7e2f8dc0845..763daada73b4d 100644 --- a/pandas/core/_numba/kernels/var_.py +++ b/pandas/core/_numba/kernels/var_.py @@ -8,8 +8,6 @@ """ from __future__ import annotations -from typing import cast - import numba import numpy as np @@ -94,7 +92,7 @@ def sliding_var( s = start[i] e = end[i] if i == 0 or not is_monotonic_increasing_bounds: - prev_value = cast(float, values[s]) + prev_value = values[s] num_consecutive_same_value = 0 for j in range(s, e): @@ -113,7 +111,7 @@ def sliding_var( ssqdm_x, compensation_add, num_consecutive_same_value, - prev_value, + prev_value, # pyright: ignore[reportGeneralTypeIssues] ) else: for j in range(start[i - 1], s): @@ -138,7 +136,7 @@ def sliding_var( ssqdm_x, compensation_add, num_consecutive_same_value, - prev_value, + prev_value, # pyright: ignore[reportGeneralTypeIssues] ) if nobs >= min_periods and nobs > ddof: