Skip to content

Commit 758ca05

Browse files
Garrett-Rjreback
authored andcommitted
DOC: Add warning for newbs not to edit auto-generated file, #10456
1 parent b0946f0 commit 758ca05

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

pandas/src/generate_code.py

+23-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
"""
2+
This file generates `generated.pyx` which is then included in `../algos.pyx`
3+
during building. To regenerate `generated.pyx`, just run:
4+
5+
`python generate_code.py`.
6+
7+
"""
8+
19
from __future__ import print_function
2-
# we only need to be able to run this file on 2.7
3-
# don't introduce a pandas/pandas.compat import
4-
# or we get a bootstrapping problem
5-
from StringIO import StringIO
10+
import os
11+
from pandas.compat import StringIO
612
import numpy as np
713

814
_int64_max = np.iinfo(np.int64).max
915

16+
warning_to_new_contributors = """
17+
# DO NOT EDIT THIS FILE: This file was autogenerated from generate_code.py, so
18+
# please edit that file and then run `python2 generate_code.py` to re-generate
19+
# this file.
20+
"""
21+
1022
header = """
1123
cimport numpy as np
1224
cimport cython
@@ -2580,8 +2592,14 @@ def generate_from_template(template, exclude=None):
25802592
take_2d_multi_template]
25812593

25822594

2583-
def generate_take_cython_file(path='generated.pyx'):
2595+
def generate_take_cython_file():
2596+
# Put `generated.pyx` in the same directory as this file
2597+
directory = os.path.dirname(os.path.realpath(__file__))
2598+
filename = 'generated.pyx'
2599+
path = os.path.join(directory, filename)
2600+
25842601
with open(path, 'w') as f:
2602+
print(warning_to_new_contributors, file=f)
25852603
print(header, file=f)
25862604

25872605
print(generate_ensure_dtypes(), file=f)

pandas/src/generated.pyx

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
# DO NOT EDIT THIS FILE: This file was autogenerated from generate_code.py, so
3+
# please edit that file and then run `python2 generate_code.py` to re-generate
4+
# this file.
5+
6+
27
cimport numpy as np
38
cimport cython
49

0 commit comments

Comments
 (0)