[rb-general] Addresses in (I)Python output
Rebecca N. Palmer
rebecca_palmer at zoho.com
Mon Sep 23 06:56:17 UTC 2019
In Python, objects that don't have an explicit string representation
have a default one that includes their memory address, which is very
likely to vary from run to run:
>>> lambda x:x
<function <lambda> at 0x7f80c9f937b8>
The documentation of some Python modules (e.g. pandas[0] and
statsmodels) includes examples that are run at build time, and hence may
be unreproducible for this reason. These may be standalone
IPython/Jupyter notebooks (.ipynb), or embedded ipython:: python
sections in Sphinx files.
This is related to but not the same as [1] (that was addresses in
Sphinx-generated API references, this is addresses in example output),
and does not appear to have a name at [2].
Potential solutions:
(a) Modify the documentation to not print these objects (if they're
IPython automatically printing the last line's result, adding ";" to the
end of the line suppresses it)
or (b) Run a search-and-replace to change them to something fixed:
for filename in `find examples -name "*.ipynb"` ; do
sed -i -e "s# at 0x[0-9a-f]+># at 0xde1e8ed>#g" $filename ; done
#(NOT tested; replace > by > if processing HTML output)
(b) is probably better, as it is both less work and less change to the
output.
[0]
https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/diffoscope-results/pandas.html
[1]
https://tests.reproducible-builds.org/debian/issues/unstable/randomness_in_documentation_generated_by_sphinx_issue.html
[2] https://tests.reproducible-builds.org/debian/index_issues.html
More information about the rb-general
mailing list