Skip to content

Commit 8a6077e

Browse files
committed
use MAXfloat64 MINfloat64 for inf; reformat code
1 parent 739f01a commit 8a6077e

File tree

1 file changed

+39
-12
lines changed

1 file changed

+39
-12
lines changed

pandas/core/_numba/kernels/var_.py

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@
1616

1717
@numba.jit(nopython=True, nogil=True, parallel=False)
1818
def add_var(
19-
val: float, nobs: int, mean_x: float, ssqdm_x: float, compensation: float,
20-
num_consecutive_same_value: int, prev_value: float
19+
val: float,
20+
nobs: int,
21+
mean_x: float,
22+
ssqdm_x: float,
23+
compensation: float,
24+
num_consecutive_same_value: int,
25+
prev_value: float
2126
) -> tuple[int, float, float, float, int, float]:
2227
if not np.isnan(val):
2328

@@ -93,11 +98,22 @@ def sliding_var(
9398

9499
for j in range(s, e):
95100
val = values[j]
96-
nobs, mean_x, ssqdm_x, compensation_add, \
97-
num_consecutive_same_value, prev_value = add_var(
98-
val, nobs, mean_x, ssqdm_x, compensation_add,
99-
num_consecutive_same_value, prev_value
100-
)
101+
(
102+
nobs,
103+
mean_x,
104+
ssqdm_x,
105+
compensation_add,
106+
num_consecutive_same_value,
107+
prev_value,
108+
) = add_var(
109+
val,
110+
nobs,
111+
mean_x,
112+
ssqdm_x,
113+
compensation_add,
114+
num_consecutive_same_value,
115+
prev_value,
116+
)
101117
else:
102118
for j in range(start[i - 1], s):
103119
val = values[j]
@@ -107,11 +123,22 @@ def sliding_var(
107123

108124
for j in range(end[i - 1], e):
109125
val = values[j]
110-
nobs, mean_x, ssqdm_x, compensation_add, \
111-
num_consecutive_same_value, prev_value = add_var(
112-
val, nobs, mean_x, ssqdm_x, compensation_add,
113-
num_consecutive_same_value, prev_value
114-
)
126+
(
127+
nobs,
128+
mean_x,
129+
ssqdm_x,
130+
compensation_add,
131+
num_consecutive_same_value,
132+
prev_value,
133+
) = add_var(
134+
val,
135+
nobs,
136+
mean_x,
137+
ssqdm_x,
138+
compensation_add,
139+
num_consecutive_same_value,
140+
prev_value,
141+
)
115142

116143
if nobs >= min_periods and nobs > ddof:
117144
if nobs == 1 or num_consecutive_same_value >= nobs:

0 commit comments

Comments
 (0)