@@ -158,15 +158,15 @@ cdef class MockFixedWindowIndexer(WindowIndexer):
158
158
index of the input
159
159
floor: optional
160
160
unit for flooring
161
- l_closed : bint
161
+ left_closed : bint
162
162
left endpoint closedness
163
- r_closed : bint
163
+ right_closed : bint
164
164
right endpoint closedness
165
165
166
166
"""
167
167
def __init__ (self , ndarray input , int64_t win , int64_t minp ,
168
168
object index = None , object floor = None ,
169
- bint l_closed = False , bint r_closed = True ):
169
+ bint left_closed = False , bint right_closed = True ):
170
170
171
171
assert index is None
172
172
self .is_variable = 0
@@ -196,15 +196,15 @@ cdef class FixedWindowIndexer(WindowIndexer):
196
196
index of the input
197
197
floor: optional
198
198
unit for flooring the unit
199
- l_closed : bint
199
+ left_closed : bint
200
200
left endpoint closedness
201
- r_closed : bint
201
+ right_closed : bint
202
202
right endpoint closedness
203
203
204
204
"""
205
205
def __init__ (self , ndarray input , int64_t win , int64_t minp ,
206
206
object index = None , object floor = None ,
207
- bint l_closed = False , bint r_closed = True ):
207
+ bint left_closed = False , bint right_closed = True ):
208
208
cdef ndarray start_s, start_e, end_s, end_e
209
209
210
210
assert index is None
@@ -239,14 +239,16 @@ cdef class VariableWindowIndexer(WindowIndexer):
239
239
min number of obs in a window to consider non-NaN
240
240
index: ndarray
241
241
index of the input
242
- l_closed : bint
242
+ left_closed : bint
243
243
left endpoint closedness
244
- r_closed: bint
244
+ True if the left endpoint is closed, False if open
245
+ right_closed: bint
245
246
right endpoint closedness
247
+ True if the right endpoint is closed, False if open
246
248
247
249
"""
248
250
def __init__ (self , ndarray input , int64_t win , int64_t minp ,
249
- ndarray index , bint l_closed , bint r_closed ):
251
+ ndarray index , bint left_closed , bint right_closed ):
250
252
251
253
self .is_variable = 1
252
254
self .N = len (index)
@@ -258,13 +260,13 @@ cdef class VariableWindowIndexer(WindowIndexer):
258
260
self .end = np.empty(self .N, dtype = ' int64' )
259
261
self .end.fill(- 1 )
260
262
261
- self .build(index, win, l_closed, r_closed )
263
+ self .build(index, win, left_closed, right_closed )
262
264
263
265
# max window size
264
266
self .win = (self .end - self .start).max()
265
267
266
- def build (self , ndarray[int64_t] index , int64_t win , bint l_closed ,
267
- bint r_closed ):
268
+ def build (self , ndarray[int64_t] index , int64_t win , bint left_closed ,
269
+ bint right_closed ):
268
270
269
271
cdef:
270
272
ndarray[int64_t] start, end
@@ -277,9 +279,11 @@ cdef class VariableWindowIndexer(WindowIndexer):
277
279
278
280
start[0 ] = 0
279
281
280
- if r_closed: # right endpoint is closed
282
+ # right endpoint is closed
283
+ if right_closed:
281
284
end[0 ] = 1
282
- else : # right endpoint is open
285
+ # right endpoint is open
286
+ else :
283
287
end[0 ] = 0
284
288
285
289
with nogil:
@@ -290,7 +294,8 @@ cdef class VariableWindowIndexer(WindowIndexer):
290
294
end_bound = index[i]
291
295
start_bound = index[i] - win
292
296
293
- if l_closed: # left endpoint is closed
297
+ # left endpoint is closed
298
+ if left_closed:
294
299
start_bound -= 1
295
300
296
301
# advance the start bound until we are
@@ -309,7 +314,7 @@ cdef class VariableWindowIndexer(WindowIndexer):
309
314
end[i] = end[i - 1 ]
310
315
311
316
# right endpoint is open
312
- if not r_closed :
317
+ if not right_closed :
313
318
end[i] -= 1
314
319
315
320
@@ -325,7 +330,8 @@ def get_window_indexer(input, win, minp, index, closed,
325
330
minp: integer, minimum periods
326
331
index: 1d ndarray, optional
327
332
index to the input array
328
- closed: 'right', 'left', 'both', 'neither'
333
+ closed: string, default 'right'
334
+ {'right', 'left', 'both', 'neither'}
329
335
window endpoint closedness
330
336
floor: optional
331
337
unit for flooring the unit
@@ -343,26 +349,26 @@ def get_window_indexer(input, win, minp, index, closed,
343
349
"""
344
350
345
351
cdef:
346
- bint l_closed = False
347
- bint r_closed = False
352
+ bint left_closed = False
353
+ bint right_closed = False
348
354
349
355
assert closed in [' right' , ' left' , ' both' , ' neither' ]
350
356
351
357
if closed in [' right' , ' both' ]:
352
- r_closed = True
358
+ right_closed = True
353
359
354
360
if closed in [' left' , ' both' ]:
355
- l_closed = True
361
+ left_closed = True
356
362
357
363
if index is not None :
358
- indexer = VariableWindowIndexer(input , win, minp, index, l_closed ,
359
- r_closed )
364
+ indexer = VariableWindowIndexer(input , win, minp, index, left_closed ,
365
+ right_closed )
360
366
elif use_mock:
361
367
indexer = MockFixedWindowIndexer(input , win, minp, index, floor,
362
- l_closed, r_closed )
368
+ left_closed, right_closed )
363
369
else :
364
- indexer = FixedWindowIndexer(input , win, minp, index, floor, l_closed ,
365
- r_closed )
370
+ indexer = FixedWindowIndexer(input , win, minp, index, floor, left_closed ,
371
+ right_closed )
366
372
return indexer.get_data()
367
373
368
374
# ----------------------------------------------------------------------
0 commit comments