Skip to content

Commit 0ab0389

Browse files
committed
clean up generated.pyx a bit
1 parent 6ba07d4 commit 0ab0389

File tree

2 files changed

+97
-56
lines changed

2 files changed

+97
-56
lines changed

pandas/src/generate_code.py

+6-20
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
return arr.asobject
7272
else:
7373
return np.array(arr, dtype=np.object_)
74-
7574
"""
7675

7776

@@ -93,7 +92,6 @@ def take_1d_%(name)s_%(dest)s(ndarray[%(c_type_in)s] values,
9392
out[i] = fv
9493
else:
9594
out[i] = %(preval)svalues[idx]%(postval)s
96-
9795
"""
9896

9997
inner_take_2d_axis0_template = """\
@@ -135,7 +133,6 @@ def take_1d_%(name)s_%(dest)s(ndarray[%(c_type_in)s] values,
135133
else:
136134
for j from 0 <= j < k:
137135
out[i, j] = %(preval)svalues[idx, j]%(postval)s
138-
139136
"""
140137

141138
take_2d_axis0_template = """\
@@ -242,7 +239,6 @@ def take_2d_multi_%(name)s_%(dest)s(ndarray[%(c_type_in)s, ndim=2] values,
242239
out[i, j] = fv
243240
else:
244241
out[i, j] = %(preval)svalues[idx, idx1[j]]%(postval)s
245-
246242
"""
247243

248244

@@ -333,7 +329,6 @@ def backfill_%(name)s(ndarray[%(c_type)s] old, ndarray[%(c_type)s] new,
333329
cur = prev
334330
335331
return indexer
336-
337332
"""
338333

339334

@@ -397,7 +392,6 @@ def pad_%(name)s(ndarray[%(c_type)s] old, ndarray[%(c_type)s] new,
397392
cur = next
398393
399394
return indexer
400-
401395
"""
402396

403397
pad_1d_template = """@cython.boundscheck(False)
@@ -432,7 +426,6 @@ def pad_inplace_%(name)s(ndarray[%(c_type)s] values,
432426
else:
433427
fill_count = 0
434428
val = values[i]
435-
436429
"""
437430

438431
pad_2d_template = """@cython.boundscheck(False)
@@ -657,7 +650,6 @@ def is_monotonic_%(name)s(ndarray[%(c_type)s] arr, bint timelike):
657650
result[index[i]] = i
658651
659652
return result
660-
661653
"""
662654

663655
groupby_template = """@cython.wraparound(False)
@@ -687,7 +679,6 @@ def groupby_%(name)s(ndarray[%(c_type)s] index, ndarray labels):
687679
result[key] = [idx]
688680
689681
return result
690-
691682
"""
692683

693684
group_last_template = """@cython.wraparound(False)
@@ -1286,8 +1277,6 @@ def group_count_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
12861277
for i in range(ncounts):
12871278
for j in range(K):
12881279
out[i, j] = nobs[i, j]
1289-
1290-
12911280
"""
12921281

12931282
group_count_bin_template = """@cython.wraparound(False)
@@ -1322,9 +1311,8 @@ def group_count_bin_%(name)s(ndarray[%(dest_type2)s, ndim=2] out,
13221311
for i in range(ngroups):
13231312
for j in range(K):
13241313
out[i, j] = nobs[i, j]
1325-
1326-
13271314
"""
1315+
13281316
# add passing bin edges, instead of labels
13291317

13301318

@@ -1788,7 +1776,6 @@ def arrmap_%(name)s(ndarray[%(c_type)s] index, object func):
17881776
result[i] = func(index[i])
17891777
17901778
return maybe_convert_objects(result)
1791-
17921779
"""
17931780

17941781
#----------------------------------------------------------------------
@@ -1840,7 +1827,6 @@ def left_join_indexer_unique_%(name)s(ndarray[%(c_type)s] left,
18401827
indexer[i] = -1
18411828
i += 1
18421829
return indexer
1843-
18441830
"""
18451831

18461832
# @cython.wraparound(False)
@@ -1947,7 +1933,6 @@ def left_join_indexer_%(name)s(ndarray[%(c_type)s] left,
19471933
j += 1
19481934
19491935
return result, lindexer, rindexer
1950-
19511936
"""
19521937

19531938

@@ -2043,7 +2028,6 @@ def inner_join_indexer_%(name)s(ndarray[%(c_type)s] left,
20432028
j += 1
20442029
20452030
return result, lindexer, rindexer
2046-
20472031
"""
20482032

20492033

@@ -2175,7 +2159,6 @@ def outer_join_indexer_%(name)s(ndarray[%(c_type)s] left,
21752159
j += 1
21762160
21772161
return result, lindexer, rindexer
2178-
21792162
"""
21802163

21812164
outer_join_template = """@cython.wraparound(False)
@@ -2273,7 +2256,6 @@ def outer_join_indexer_%(name)s(ndarray[%(c_type)s] left,
22732256
count += 1
22742257
22752258
return result, lindexer, rindexer
2276-
22772259
"""
22782260

22792261
# ensure_dtype functions
@@ -2287,7 +2269,6 @@ def outer_join_indexer_%(name)s(ndarray[%(c_type)s] left,
22872269
return arr.astype(np.%(dtype)s)
22882270
else:
22892271
return np.array(arr, dtype=np.%(dtype)s)
2290-
22912272
"""
22922273

22932274
ensure_functions = [
@@ -2362,6 +2343,7 @@ def generate_put_template(template, use_ints=True, use_floats=True,
23622343
'dest_type2': dest_type,
23632344
'dest_dtype': dest_dtype}
23642345
output.write(func)
2346+
output.write("\n")
23652347
return output.getvalue()
23662348

23672349
def generate_put_min_max_template(template, use_ints=True, use_floats=True,
@@ -2394,6 +2376,7 @@ def generate_put_min_max_template(template, use_ints=True, use_floats=True,
23942376
'nan_val': nan_val,
23952377
'inf_val': inf_val}
23962378
output.write(func)
2379+
output.write("\n")
23972380
return output.getvalue()
23982381

23992382
def generate_put_selection_template(template, use_ints=True, use_floats=True,
@@ -2426,6 +2409,7 @@ def generate_put_selection_template(template, use_ints=True, use_floats=True,
24262409
'dest_type2': dest_type,
24272410
'nan_val': nan_val}
24282411
output.write(func)
2412+
output.write("\n")
24292413
return output.getvalue()
24302414

24312415
def generate_take_template(template, exclude=None):
@@ -2464,6 +2448,7 @@ def generate_take_template(template, exclude=None):
24642448
'preval': preval, 'postval': postval,
24652449
'can_copy': 'True' if can_copy else 'False'}
24662450
output.write(func)
2451+
output.write("\n")
24672452
return output.getvalue()
24682453

24692454
def generate_from_template(template, exclude=None):
@@ -2486,6 +2471,7 @@ def generate_from_template(template, exclude=None):
24862471
'dtype': dtype,
24872472
'raise_on_na': 'False' if can_hold_na else 'True'}
24882473
output.write(func)
2474+
output.write("\n")
24892475
return output.getvalue()
24902476

24912477
put_2d = [diff_2d_template]

0 commit comments

Comments
 (0)