Skip to content

Commit fcd94b3

Browse files
authored
DOC: Move all relevant wiki items to docs (#47277)
1 parent ed7467c commit fcd94b3

File tree

5 files changed

+184
-18
lines changed

5 files changed

+184
-18
lines changed

doc/source/development/contributing_codebase.rst

+67-9
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ This is an example of a green build.
304304
.. _contributing.tdd:
305305

306306

307-
Test-driven development/code writing
308-
------------------------------------
307+
Test-driven development
308+
-----------------------
309309

310310
pandas is serious about testing and strongly encourages contributors to embrace
311311
`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
337337

338338
.. code-block:: python
339339
340-
class TestReallyCoolFeature:
341-
pass
340+
class TestReallyCoolFeature:
341+
def test_cool_feature_aspect(self):
342+
pass
342343
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
344345
framework that will facilitate testing and developing. Thus, instead of writing test classes, we will write test functions like this:
345346

346347
.. code-block:: python
347348
348349
def test_really_cool_feature():
349350
pass
350351
351-
Preferred idioms
352-
^^^^^^^^^^^^^^^^
352+
Preferred ``pytest`` idioms
353+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
353354

354355
* Functional tests named ``def test_*`` and *only* take arguments that are either fixtures or parameters.
355356
* 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
387388
For these tests, we need to verify the correct exception type and error message
388389
is being raised, using ``pytest.raises`` instead.
389390

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+
raise ValueError("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+
def test_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.
445+
446+
.. code-block:: python
392447
448+
@tm.network("https://www.somespecificsite.com", check_before_test=True)
449+
def test_network():
450+
result = pd.read_html("https://www.somespecificsite.com")
393451
394452
Example
395453
^^^^^^^

doc/source/development/maintaining.rst

+72-4
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Reviewing pull requests
138138
-----------------------
139139

140140
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.
142142

143143
Here are some things to check when reviewing a pull request.
144144

@@ -151,16 +151,37 @@ Here are some things to check when reviewing a pull request.
151151
for regression fixes and small bug fixes, the next minor milestone otherwise)
152152
* Changes should comply with our :ref:`policies.version`.
153153

154+
155+
.. _maintaining.backporting:
156+
154157
Backporting
155158
-----------
156159

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::
159180

160181
@meeseeksdev backport version-branch
161182

162183
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)
164185

165186
Cleaning up old issues
166187
----------------------
@@ -204,6 +225,18 @@ The full process is outlined in our `governance documents`_. In summary,
204225
we're happy to give triage permissions to anyone who shows interest by
205226
being helpful on the issue tracker.
206227

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>`_.
239+
207240
The current list of core-team members is at
208241
https://github.com/pandas-dev/pandas-governance/blob/master/people.md
209242

@@ -236,5 +269,40 @@ a milestone before tagging, you can request the bot to backport it with:
236269
@Meeseeksdev backport <branch>
237270
238271
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
296+
297+
ssh -L 8080:localhost:8080 [email protected]
298+
299+
300+
.. _maintaining.release:
301+
302+
Release process
303+
---------------
304+
305+
The process for releasing a new version of pandas can be found at https://github.com/pandas-dev/pandas-release
306+
239307
.. _governance documents: https://github.com/pandas-dev/pandas-governance
240308
.. _list of permissions: https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization

doc/source/development/roadmap.rst

+45-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,51 @@ We propose that it should only work with positional indexing, and the translatio
128128
to positions should be entirely done at a higher level.
129129

130130
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.
132176

133177
Numba-accelerated operations
134178
----------------------------

pandas/_testing/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
round_trip_localpath,
5555
round_trip_pathlib,
5656
round_trip_pickle,
57-
with_connectivity_check,
5857
write_to_compressed,
5958
)
6059
from pandas._testing._random import ( # noqa:F401

pandas/_testing/_io.py

-3
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,6 @@ def wrapper(*args, **kwargs):
250250
return wrapper
251251

252252

253-
with_connectivity_check = network
254-
255-
256253
def can_connect(url, error_classes=None):
257254
"""
258255
Try to connect to the given url. True if succeeds, False if OSError

0 commit comments

Comments
 (0)