Skip to content

DOC: Add warning for newbs not to edit auto-generated file #10456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions pandas/src/generate_code.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
"""This file generates `generated.pyx` which is then included in `../algos.pyx`
during building. To regenerate `generated.pyx`, just run:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this actually has to be run from pandas/src (so that generated.pyx is in the correct place), so either we need to fix this (e.g. the output path should be relative to the pandas tree), or provide this in the instructions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I fixed it so it can now be run from anywhere.


`python generate_code.py`.

"""

from __future__ import print_function
# we only need to be able to run this file on 2.7
# don't introduce a pandas/pandas.compat import
# or we get a bootstrapping problem
from StringIO import StringIO
import os
from pandas.compat import StringIO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I made it 2/3 compatible.

I didn't understand this warning here and the original commit had no more information about this. I tested this on Py2 and Py3 and it seemed to work fine...

import numpy as np

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

warning_to_new_contributors = """
# DO NOT EDIT THIS FILE: This file was autogenerated from generate_code.py, so
# please edit that file and then run `python2 generate_code.py` to re-generate
# this file.
"""

header = """
cimport numpy as np
cimport cython
Expand Down Expand Up @@ -2526,8 +2537,14 @@ def generate_from_template(template, exclude=None):
take_2d_multi_template]


def generate_take_cython_file(path='generated.pyx'):
def generate_take_cython_file():
# Put `generated.pyx` in the same directory as this file
directory = os.path.dirname(os.path.realpath(__file__))
filename = 'generated.pyx'
path = os.path.join(directory, filename)

with open(path, 'w') as f:
print(warning_to_new_contributors, file=f)
print(header, file=f)

print(generate_ensure_dtypes(), file=f)
Expand Down
5 changes: 5 additions & 0 deletions pandas/src/generated.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

# DO NOT EDIT THIS FILE: This file was autogenerated from generate_code.py, so
# please edit that file and then run `python2 generate_code.py` to re-generate
# this file.


cimport numpy as np
cimport cython

Expand Down