You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/development/contributing_codebase.rst
+67-9
Original file line number
Diff line number
Diff line change
@@ -304,8 +304,8 @@ This is an example of a green build.
304
304
.. _contributing.tdd:
305
305
306
306
307
-
Test-driven development/code writing
308
-
------------------------------------
307
+
Test-driven development
308
+
-----------------------
309
309
310
310
pandas is serious about testing and strongly encourages contributors to embrace
311
311
`test-driven development (TDD) <https://en.wikipedia.org/wiki/Test-driven_development>`_.
@@ -337,19 +337,20 @@ pandas existing test structure is *mostly* class-based, meaning that you will ty
337
337
338
338
.. code-block:: python
339
339
340
-
classTestReallyCoolFeature:
341
-
pass
340
+
classTestReallyCoolFeature:
341
+
deftest_cool_feature_aspect(self):
342
+
pass
342
343
343
-
Going forward, we are moving to a more *functional* style using the `pytest <https://docs.pytest.org/en/latest/>`__ framework, which offers a richer testing
344
+
We prefer a more *functional* style using the `pytest <https://docs.pytest.org/en/latest/>`__ framework, which offers a richer testing
344
345
framework that will facilitate testing and developing. Thus, instead of writing test classes, we will write test functions like this:
345
346
346
347
.. code-block:: python
347
348
348
349
deftest_really_cool_feature():
349
350
pass
350
351
351
-
Preferred idioms
352
-
^^^^^^^^^^^^^^^^
352
+
Preferred ``pytest`` idioms
353
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
353
354
354
355
* Functional tests named ``def test_*`` and *only* take arguments that are either fixtures or parameters.
355
356
* Use a bare ``assert`` for testing scalars and truth-testing
@@ -387,9 +388,66 @@ xfail is not to be used for tests involving failure due to invalid user argument
387
388
For these tests, we need to verify the correct exception type and error message
388
389
is being raised, using ``pytest.raises`` instead.
389
390
390
-
If your test requires working with files or
391
-
network connectivity, there is more information on the :wiki:`Testing` of the wiki.
391
+
Testing a warning
392
+
^^^^^^^^^^^^^^^^^
393
+
394
+
Use ``tm.assert_produces_warning`` as a context manager to check that a block of code raises a warning.
395
+
396
+
.. code-block:: python
397
+
398
+
with tm.assert_produces_warning(DeprecationWarning):
399
+
pd.deprecated_function()
400
+
401
+
If a warning should specifically not happen in a block of code, pass ``False`` into the context manager.
402
+
403
+
.. code-block:: python
404
+
405
+
with tm.assert_produces_warning(False):
406
+
pd.no_warning_function()
407
+
408
+
Testing an exception
409
+
^^^^^^^^^^^^^^^^^^^^
410
+
411
+
Use `pytest.raises <https://docs.pytest.org/en/latest/reference/reference.html#pytest-raises>`_ as a context manager
412
+
with the specific exception subclass (i.e. never use :py:class:`Exception`) and the exception message in ``match``.
413
+
414
+
.. code-block:: python
415
+
416
+
with pytest.raises(ValueError, match="an error"):
417
+
raiseValueError("an error")
418
+
419
+
Testing involving files
420
+
^^^^^^^^^^^^^^^^^^^^^^^
421
+
422
+
The ``tm.ensure_clean`` context manager creates a temporary file for testing,
423
+
with a generated filename (or your filename if provided), that is automatically
424
+
deleted when the context block is exited.
425
+
426
+
.. code-block:: python
427
+
428
+
with tm.ensure_clean('my_file_path') as path:
429
+
# do something with the path
430
+
431
+
Testing involving network connectivity
432
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
433
+
434
+
It is highly discouraged to add a test that connects to the internet due to flakiness of network connections and
435
+
lack of ownership of the server that is being connected to. If network connectivity is absolutely required, use the
436
+
``tm.network`` decorator.
437
+
438
+
.. code-block:: python
439
+
440
+
@tm.network# noqa
441
+
deftest_network():
442
+
result = package.call_to_internet()
443
+
444
+
If the test requires data from a specific website, specify ``check_before_test=True`` and the site in the decorator.
Copy file name to clipboardExpand all lines: doc/source/development/maintaining.rst
+72-4
Original file line number
Diff line number
Diff line change
@@ -138,7 +138,7 @@ Reviewing pull requests
138
138
-----------------------
139
139
140
140
Anybody can review a pull request: regular contributors, triagers, or core-team
141
-
members. But only core-team members can merge pull requets when they're ready.
141
+
members. But only core-team members can merge pull requests when they're ready.
142
142
143
143
Here are some things to check when reviewing a pull request.
144
144
@@ -151,16 +151,37 @@ Here are some things to check when reviewing a pull request.
151
151
for regression fixes and small bug fixes, the next minor milestone otherwise)
152
152
* Changes should comply with our :ref:`policies.version`.
153
153
154
+
155
+
.. _maintaining.backporting:
156
+
154
157
Backporting
155
158
-----------
156
159
157
-
In the case you want to apply changes to a stable branch from a newer branch then you
158
-
can comment::
160
+
pandas supports point releases (e.g. ``1.4.3``) that aim to:
161
+
162
+
1. Fix bugs in new features introduced in the first minor version release.
163
+
164
+
* e.g. If a new feature was added in ``1.4`` and contains a bug, a fix can be applied in ``1.4.3``
165
+
166
+
2. Fix bugs that used to work in a few minor releases prior. There should be agreement between core team members that a backport is appropriate.
167
+
168
+
* e.g. If a feature worked in ``1.2`` and stopped working since ``1.3``, a fix can be applied in ``1.4.3``.
169
+
170
+
Since pandas minor releases are based on Github branches (e.g. point release of ``1.4`` are based off the ``1.4.x`` branch),
171
+
"backporting" means merging a pull request fix to the ``main`` branch and correct minor branch associated with the next point release.
172
+
173
+
By default, if a pull request is assigned to the next point release milestone within the Github interface,
174
+
the backporting process should happen automatically by the ``@meeseeksdev`` bot once the pull request is merged.
175
+
A new pull request will be made backporting the pull request to the correct version branch.
176
+
Sometimes due to merge conflicts, a manual pull request will need to be made addressing the code conflict.
177
+
178
+
If the bot does not automatically start the backporting process, you can also write a Github comment in the merged pull request
179
+
to trigger the backport::
159
180
160
181
@meeseeksdev backport version-branch
161
182
162
183
This will trigger a workflow which will backport a given change to a branch
163
-
(e.g. @meeseeksdev backport 1.2.x)
184
+
(e.g. @meeseeksdev backport 1.4.x)
164
185
165
186
Cleaning up old issues
166
187
----------------------
@@ -204,6 +225,18 @@ The full process is outlined in our `governance documents`_. In summary,
204
225
we're happy to give triage permissions to anyone who shows interest by
205
226
being helpful on the issue tracker.
206
227
228
+
The required steps for adding a maintainer are:
229
+
230
+
1. Contact the contributor and ask their interest to join.
231
+
2. Add the contributor to the appropriate `Github Team <https://github.com/orgs/pandas-dev/teams>`_ if accepted the invitation.
232
+
233
+
* ``pandas-core`` is for core team members
234
+
* ``pandas-triage`` is for pandas triage members
235
+
236
+
3. Add the contributor to the pandas Google group.
237
+
4. Create a pull request to add the contributor's Github handle to ``pandas-dev/pandas/web/pandas/config.yml``.
238
+
5. Create a pull request to add the contributor's name/Github handle to the `governance document <https://github.com/pandas-dev/pandas-governance/blob/master/people.md>`_.
@@ -236,5 +269,40 @@ a milestone before tagging, you can request the bot to backport it with:
236
269
@Meeseeksdev backport <branch>
237
270
238
271
272
+
.. _maintaining.asv-machine:
273
+
274
+
Benchmark machine
275
+
-----------------
276
+
277
+
The team currently owns dedicated hardware for hosting a website for pandas' ASV performance benchmark. The results
278
+
are published to http://pandas.pydata.org/speed/pandas/
279
+
280
+
Configuration
281
+
`````````````
282
+
283
+
The machine can be configured with the `Ansible <http://docs.ansible.com/ansible/latest/index.html>`_ playbook in https://github.com/tomaugspurger/asv-runner.
284
+
285
+
Publishing
286
+
``````````
287
+
288
+
The results are published to another Github repository, https://github.com/tomaugspurger/asv-collection.
289
+
Finally, we have a cron job on our docs server to pull from https://github.com/tomaugspurger/asv-collection, to serve them from ``/speed``.
290
+
Ask Tom or Joris for access to the webserver.
291
+
292
+
Debugging
293
+
`````````
294
+
295
+
The benchmarks are scheduled by Airflow. It has a dashboard for viewing and debugging the results. You'll need to setup an SSH tunnel to view them
.. _list of permissions: https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization
Copy file name to clipboardExpand all lines: doc/source/development/roadmap.rst
+45-1
Original file line number
Diff line number
Diff line change
@@ -128,7 +128,51 @@ We propose that it should only work with positional indexing, and the translatio
128
128
to positions should be entirely done at a higher level.
129
129
130
130
Indexing is a complicated API with many subtleties. This refactor will require care
131
-
and attention. More details are discussed at :wiki:`(Tentative)-rules-for-restructuring-indexing-code`
131
+
and attention. The following principles should inspire refactoring of indexing code and
132
+
should result on cleaner, simpler, and more performant code.
133
+
134
+
1. **Label indexing must never involve looking in an axis twice for the same label(s).**
135
+
This implies that any validation step must either:
136
+
137
+
* limit validation to general features (e.g. dtype/structure of the key/index), or
138
+
* reuse the result for the actual indexing.
139
+
140
+
2. **Indexers must never rely on an explicit call to other indexers.**
141
+
For instance, it is OK to have some internal method of ``.loc`` call some
142
+
internal method of ``__getitem__`` (or of their common base class),
143
+
but never in the code flow of ``.loc`` should ``the_obj[something]`` appear.
144
+
145
+
3. **Execution of positional indexing must never involve labels** (as currently, sadly, happens).
146
+
That is, the code flow of a getter call (or a setter call in which the right hand side is non-indexed)
147
+
to ``.iloc`` should never involve the axes of the object in any way.
148
+
149
+
4. **Indexing must never involve accessing/modifying values** (i.e., act on ``._data`` or ``.values``) **more than once.**
150
+
The following steps must hence be clearly decoupled:
151
+
152
+
* find positions we need to access/modify on each axis
153
+
* (if we are accessing) derive the type of object we need to return (dimensionality)
154
+
* actually access/modify the values
155
+
* (if we are accessing) construct the return object
156
+
157
+
5. As a corollary to the decoupling between 4.i and 4.iii, **any code which deals on how data is stored**
158
+
(including any combination of handling multiple dtypes, and sparse storage, categoricals, third-party types)
159
+
**must be independent from code that deals with identifying affected rows/columns**,
160
+
and take place only once step 4.i is completed.
161
+
162
+
* In particular, such code should most probably not live in ``pandas/core/indexing.py``
163
+
* ... and must not depend in any way on the type(s) of axes (e.g. no ``MultiIndex`` special cases)
164
+
165
+
6. As a corollary to point 1.i, **``Index`` (sub)classes must provide separate methods for any desired validity check of label(s) which does not involve actual lookup**,
166
+
on the one side, and for any required conversion/adaptation/lookup of label(s), on the other.
167
+
168
+
7. **Use of trial and error should be limited**, and anyway restricted to catch only exceptions
169
+
which are actually expected (typically ``KeyError``).
170
+
171
+
* In particular, code should never (intentionally) raise new exceptions in the ``except`` portion of a ``try... exception``
172
+
173
+
8. **Any code portion which is not specific to setters and getters must be shared**,
174
+
and when small differences in behavior are expected (e.g. getting with ``.loc`` raises for
175
+
missing labels, setting still doesn't), they can be managed with a specific parameter.
0 commit comments