|
| 1 | +.. _pandas_development_faq: |
| 2 | + |
| 3 | +{{ header }} |
| 4 | + |
| 5 | +====================== |
| 6 | +Pandas Development FAQ |
| 7 | +====================== |
| 8 | + |
| 9 | +.. contents:: Table of contents: |
| 10 | + :local: |
| 11 | + |
| 12 | +Purpose |
| 13 | +======= |
| 14 | + |
| 15 | +Based on https://github.com/pydata/pandas/pull/4404#issuecomment-22864665 this |
| 16 | +wiki page gathers oft-asked questions/comments from contributors to make the |
| 17 | +contribution process a bit less painful. |
| 18 | + |
| 19 | +The aim is to make it easier for |
| 20 | + |
| 21 | +* Core developers to give advice & accept new code contributions. |
| 22 | +* New contributors to find an easier way in for quick and efficient bug-fixes |
| 23 | + or feature additions |
| 24 | + |
| 25 | +While some questions/comments/advice may be applicable to general programming, |
| 26 | +these are things that directly relate to ``pandas`` development. |
| 27 | + |
| 28 | +* `**PR == pull request** <https://help.github.com/articles/using-pull-requests>`_ |
| 29 | +* **core developer:** A person contributing on very high frequency & who is |
| 30 | + familiar with the code base and development process of ``pandas``. |
| 31 | +* **contributors:** The occasional contributor, maybe from a specific domain, |
| 32 | + contributes bug fixes, features or documentation with low frequency, may not |
| 33 | + be an every day programmer (e.g. programming scientists or engineer using |
| 34 | + pandas for data processing) and looks at things from an end-user perspective. |
| 35 | + |
| 36 | +Pandas Development & Release Process |
| 37 | +==================================== |
| 38 | + |
| 39 | +Testing |
| 40 | +------- |
| 41 | + |
| 42 | +**Q:** What are some recommendations for writing unit tests? |
| 43 | + |
| 44 | +**A:** Your test should be self-contained. That is, it should test preferably a |
| 45 | +single thing, e.g., a method that you've added to the ``DataFrame`` class. Your |
| 46 | +test function/method should start with ``test_`` and the rest of the name should |
| 47 | +be related to whatever functionality you're testing, like ``test_replace_with_dict_regex``. |
| 48 | + |
| 49 | +**Q:** Help! I can't get the tests to run! |
| 50 | + |
| 51 | +**A:** You probably either have multiple Python versions installed and there's |
| 52 | +an ABI (application binary interface) issue or you forgot to build the extension |
| 53 | +modules in place. The latter can be done with |
| 54 | + |
| 55 | +.. code-block:: shell |
| 56 | +
|
| 57 | + python setup.py build_ext --inplace |
| 58 | +
|
| 59 | +from the ``pandas`` directory. |
| 60 | + |
| 61 | +Travis |
| 62 | +------ |
| 63 | + |
| 64 | +**Q:** Where do I need to change the settings in my GitHub configuration and/or |
| 65 | +Travis configuration for the Travis to start builds from my fork? |
| 66 | + |
| 67 | +**A:** To be filled out. |
| 68 | + |
| 69 | +**Q:** Why do I need a Travis file in my repo if it's already in the head repository? |
| 70 | + |
| 71 | +**A:** Because we're not using subversion. Okay, seriously, it's because as far |
| 72 | +as ``git`` is concerned *your* repository is the *only* one that exists. There's |
| 73 | +really no such thing as a "head" repository in the eyes of ``git``, those are concepts |
| 74 | +that we impose on it to make collaboration more effective and easier. This is one |
| 75 | +of the nice aspects of `distributed version control <http://en.wikipedia.org/wiki/Distributed_revision_control>`_. |
| 76 | + |
| 77 | +Documentation |
| 78 | +------------- |
| 79 | + |
| 80 | +**Q:** Does Travis build documentation? |
| 81 | + |
| 82 | +**A:** Currently, no. There are some issues surrounding Sphinx error reporting. |
| 83 | +We are investigating ways to solve this problem. |
| 84 | + |
| 85 | +Workflow |
| 86 | +-------- |
| 87 | + |
| 88 | +* What is a typical workflow on my local fork? |
| 89 | +* Shall I work in a virtualenvironment? |
| 90 | +* Shall I work in a virtualenvironment and then copy my changes over into a |
| 91 | + clean local fork of my own repo? |
| 92 | + |
| 93 | +**Q:** Who will be responsible for evaluating my PR? |
| 94 | + |
| 95 | +**A:** Technically, anyone with push rights to the ``pydata/pandas`` can evaluate |
| 96 | +it. In practice, there are a handful of people who are constantly watching the ``pandas`` |
| 97 | +repo for new PRs, so most likely it'll be one of them that evaluates it. I'm not |
| 98 | +going to list names, but it's not that hard to figure out... |
| 99 | + |
| 100 | +Criteria for PR |
| 101 | +--------------- |
| 102 | + |
| 103 | +**Q:** What are the criteria for acceptance of a PR? |
| 104 | + |
| 105 | +**A:** First and foremost, your fix **must not break any existing functionality**, |
| 106 | +one indicator of this is that your Travis build passes. Second, just give it some |
| 107 | +time. Everyone is busy and @wesm has not (yet?) amassed a ``pandas`` development army. |
| 108 | + |
| 109 | +**Q:** Do I need to open an issue first? |
| 110 | + |
| 111 | +**A:** Not necessarily. If you want to submit a documentation change, e.g., a |
| 112 | +typo fix, then opening an issue is not necessary. |
| 113 | + |
| 114 | +Coding Style |
| 115 | +------------ |
| 116 | + |
| 117 | +**Q:** What level of commenting is accepted? |
| 118 | + |
| 119 | +**A:** The common sense level. Don't overdo it on the comments, and make sure |
| 120 | +if you *do* comment that your comments explain *what* your code is doing, not |
| 121 | +*how* it is doing it (that's what code is for). |
| 122 | + |
| 123 | +Obligatory example: |
| 124 | + |
| 125 | +BAD: |
| 126 | + |
| 127 | +.. code-block:: python |
| 128 | +
|
| 129 | + # increment i |
| 130 | + i += 1 |
| 131 | +
|
| 132 | +
|
| 133 | +GOOD: |
| 134 | + |
| 135 | +.. code-block:: python |
| 136 | +
|
| 137 | + # add a person to the person count |
| 138 | + i += 1 |
| 139 | +
|
| 140 | +
|
| 141 | +Debugging |
| 142 | +--------- |
| 143 | + |
| 144 | +**Q:** How can I debug without adding loads of ``print`` statements/calls everywhere? |
| 145 | + |
| 146 | +**A:** You can use the Python standard library's ``pdb`` and set a breakpoint. |
| 147 | +Put ``import pdb; pdb.set_trace()`` at the line where you want to stop. |
| 148 | +`ipdb <https://github.com/gotcha/ipdb>`_ is ``pdb`` with tab-completion and a few other |
| 149 | +bells and whistles, making debugging less painful. There's also `ipdbplugin <https://github.com/flavioamieiro/nose-ipdb>`_ which allows you to drop into ``ipdb`` from |
| 150 | +`nose <https://github.com/nose-devs/nose>`_ when a test fails via |
| 151 | + |
| 152 | +.. code-block:: shell |
| 153 | +
|
| 154 | + nosetests --ipdb # or --ipdb-failures |
| 155 | +
|
| 156 | +**Q:** Would a logging hook be a solution? |
| 157 | + |
| 158 | +**A:** That's probably a bit overkill. See the suggestions above. |
| 159 | + |
| 160 | +Pandas Library |
| 161 | +============== |
| 162 | + |
| 163 | +Source Comments |
| 164 | +--------------- |
| 165 | + |
| 166 | +* It would be nice to add more source comments to quickly understand the context |
| 167 | + when chiming in to fix an issue |
| 168 | + |
| 169 | +Testing |
| 170 | +------- |
| 171 | + |
| 172 | +**Q:** Why don't test functions have a docstring? |
| 173 | + |
| 174 | +**A:** If your tests are self-contained and aren't `sprawling ecosystems of spaghetti <http://cdn.memegenerator.net/instances/250x250/26336623.jpg>`_ then having a docstring |
| 175 | +is redundant. Also, the test name is usually (and should be!) very descriptive. |
| 176 | +Remember there's no character limit for variable names. We're not using FORTRAN. |
| 177 | + |
| 178 | +**Q:** ``DataFrame`` and other ``pandas`` objects often many properties/methods. |
| 179 | +What is the level of detail that I should consider when I'm writing my test(s)? |
| 180 | + |
| 181 | +**A:** See the previous question/answer. Strive to test one and only one thing. |
| 182 | +You could even separate out your tests by their formal parameters if you want |
| 183 | +things to be *really* self-contained. |
| 184 | + |
| 185 | +**Q:** Should I consider possible corner cases of my implementation? |
| 186 | + |
| 187 | +**A:** The answer is a resounding **YES**! In some cases you may come across |
| 188 | +something that is very pathological. In those cases you should ask a core developer. |
| 189 | + |
| 190 | +Complexity |
| 191 | +---------- |
| 192 | + |
| 193 | +* Some modules (e.g. io/parsers.py) seem to have grown into very high complexity. |
| 194 | + It is very time consuming to find out what is done where just for fixing a small bug. |
| 195 | +* a splitting into several modules would be good |
| 196 | +* more in-code comments telling why something is done and under which condition and |
| 197 | + for what expected result. |
| 198 | + |
| 199 | + |
| 200 | +Docstrings |
| 201 | +---------- |
| 202 | + |
| 203 | +* even internal functions shall have a simple 1-line docstring |
0 commit comments