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
_____________________________________________________ [doctest] pandas.io.formats.style_render._parse_latex_header_span _____________________________________________________
1329 ``wrap`` is used to enclose the `display_value` in braces which is needed for
1330 column headers using an siunitx package.
1331
1332 Requires the package {multirow}, whereas multicol support is usually built in
1333 to the {tabular} environment.
1334
1335 Examples
1336 --------
1337 >>> cell = {'display_vale':'text', 'attributes': 'colspan="3"'}
1338 >>> _parse_latex_header_span(cell, 't', 'c')
UNEXPECTED EXCEPTION: KeyError('display_value')
Traceback (most recent call last):
File "/home/mgarcia/miniconda3/envs/pandas-dev/lib/python3.8/doctest.py", line 1336, in __run
exec(compile(example.source, filename, "single",
File "<doctest pandas.io.formats.style_render._parse_latex_header_span[1]>", line 1, in <module>
File "/home/mgarcia/src/pandas/pandas/io/formats/style_render.py", line 1347, in _parse_latex_header_span
f"\\multicolumn{{{colspan}}}{{{multicol_align}}}"
KeyError: 'display_value'
/home/mgarcia/src/pandas/pandas/io/formats/style_render.py:1338: UnexpectedException
Detailed instructions
Python allows to have example code in the documentation, like in:
defadd(num1, num2):
""" Computes the sum of the two numbers. Examples -------- >>> add(2, 2) 4 """returnnum1+num2
In pandas, we use this to document most elements. And there are tools, like pytest,
that can run the examples, and make sure everything is correct.
For historical reasons, we have many examples where the code fails to run, or the
actual output is different from the expected output. For example, check the next
incorrect examples:
defadd(num1, num2):
""" Computes the sum of the two numbers. Examples -------- >>> add(2, 2) 5 >>> add(2, 2 4 >>> add(2, number) 4 ... """returnnum1+num2
All them will fail for different reasons. To test the docstring of an object,
the next command can be run:
Where pandas/core/frame.py is the file where the docstring is defined, and pandas.core.frame.DataFrame.info is the object. A whole file can also be tested
by removing the :: and the object from the command above.
In general, the errors in the examples can be fixed with things like:
Fixing a typo (a missing comma, an mispelled variable name...)
Adding an object that hasn't been defined (like, if df is used, but
no sample dataset df has been first defined)
Fixing the expected output, when it's wrong
In exceptional cases, examples shouldn't run, since they can't work.
For example, a function that connects to a private webservice. In
such cases, we can add # doctest: +SKIP at the end of the lines
that should not run
To be able to properly fix an example for the first time, the next steps
are needed:
Run the doctests for the object of interest (the one in this issue),
and make sure the examples are still broken in the master branch of
pandas
Fix the file locally, and run the doctests again, to make sure the
fix is working as expected
Optionally have a look and make sure that the code in the examples
follow PEP-8, and fix the style if it doesn't
Commit your changes, push your branch to a fork, and open a pull
request. Make sure you edit the line Closes #XXXX with the issue
number you are addressing, so the issue is automatically closed,
when the pull request is merged
Make sure the continuous integration of your pull request finishes
in green. If it doesn't, check if the problem is in your changes
(sometimes things break in master for technical problems, and in
that case you just need to wait for a core developer to fix the
problem)
Address any comment from the reviewers (just make changes locally,
commit, and push to your branch, no need to open new pull requests)
The text was updated successfully, but these errors were encountered:
Is an entry in whatsnew/v1.4.0.rst -> Styler section required, regarding the doctest fix?
I don't think it's relevant enough to be in the release notes. And we have many of those fixes, so it would be too much noise. Maybe at the end of fixing all them a note to say that all doctests are fixed could make sense, but not one for each.
this is a private method. the documentation is not strictly necessary but included to help other devs. many pandas private methods do not have complete doc strings. the changes are not public facing so no release note needed.
tl;dr
Fix the next doctest error:
Detailed instructions
Python allows to have example code in the documentation, like in:
In pandas, we use this to document most elements. And there are tools, like pytest,
that can run the examples, and make sure everything is correct.
For historical reasons, we have many examples where the code fails to run, or the
actual output is different from the expected output. For example, check the next
incorrect examples:
All them will fail for different reasons. To test the docstring of an object,
the next command can be run:
Where
pandas/core/frame.py
is the file where the docstring is defined, andpandas.core.frame.DataFrame.info
is the object. A whole file can also be testedby removing the
::
and the object from the command above.In general, the errors in the examples can be fixed with things like:
df
is used, butno sample dataset
df
has been first defined)For example, a function that connects to a private webservice. In
such cases, we can add
# doctest: +SKIP
at the end of the linesthat should not run
To be able to properly fix an example for the first time, the next steps
are needed:
simplified instructions in this page,
and more detailed information in pandas official contributing page.
and make sure the examples are still broken in the
master
branch ofpandas
fix is working as expected
follow PEP-8, and fix the style if it doesn't
request. Make sure you edit the line
Closes #XXXX
with the issuenumber you are addressing, so the issue is automatically closed,
when the pull request is merged
in green. If it doesn't, check if the problem is in your changes
(sometimes things break in master for technical problems, and in
that case you just need to wait for a core developer to fix the
problem)
commit, and push to your branch, no need to open new pull requests)
The text was updated successfully, but these errors were encountered: