File: sphinx_reproducibility_and_ignore_errors.patch

package info (click to toggle)
statsmodels 0.14.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 49,940 kB
  • sloc: python: 253,284; f90: 612; sh: 560; javascript: 337; asm: 156; makefile: 145; ansic: 16; xml: 9
file content (79 lines) | stat: -rw-r--r-- 3,650 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Description: Be reproducible, and don't fail on examples exceptions

If example code outputs an error when run,
ipython (ipython:: blocks) now fails the whole build by default,
and tools/nbgenerate.py (.ipynb files) now leaves out that file
(leaving a broken link in the examples index).

As some examples use downloaded data and are hence expected to be
unrunnable on a Debian buildd, this instead keeps them
(::ipython with error output, .ipynb without output).

Also remove timestamps, ipykernel IDs, etc from examples output
for reproducibility.  (This is here not in debian/rules to do it
before building the search index.)

Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Forwarded: not-needed

--- a/examples/notebooks/stl_decomposition.ipynb
+++ b/examples/notebooks/stl_decomposition.ipynb
@@ -570,7 +570,7 @@
    "outputs": [],
    "source": [
     "mod = STL(y, period=period, seasonal=seasonal)\n",
-    "%timeit mod.fit()\n",
+    "# removed for reproducibility: %timeit mod.fit()\n",
     "res = mod.fit()\n",
     "fig = res.plot(observed=False, resid=False)"
    ]
@@ -598,7 +598,7 @@
     "    trend_jump=trend_jump,\n",
     "    low_pass_jump=low_pass_jump,\n",
     ")\n",
-    "%timeit mod.fit()\n",
+    "# removed for reproducibility: %timeit mod.fit()\n",
     "res = mod.fit()\n",
     "fig = res.plot(observed=False, resid=False)"
    ]
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -67,6 +67,7 @@ else:
 
 # nbsphinx options
 nbsphinx_allow_errors = True
+ipython_warning_is_error = False
 # sphinxcontrib-spelling options
 spelling_word_list_filename = ['spelling_wordlist.txt', 'names_wordlist.txt']
 spelling_ignore_pypi_package_names = True
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -16,6 +16,8 @@ NOTEBOOKBUILD = nbgenerate.py
 # Internal variables.
 PAPEROPT_a4     = -D latex_paper_size=a4
 PAPEROPT_letter = -D latex_paper_size=letter
+SOURCE_DATE:=$(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+%a, %d %b %Y" || echo "xxx, xx xxx xxxx")
+SOURCE_TIME:=$(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+%T" || echo "xx:xx:xx")
 
 # Put it first so that "make" without argument is like "make help".
 help:
@@ -34,6 +36,19 @@ html:
 	mkdir -p $(BUILDDIR)/source/examples/notebooks/generated
 	# Black list notebooks from doc build here
 	$(TOOLSPATH)$(NOTEBOOKBUILD) --parallel --report-errors --skip-existing --execute-only --execution-blacklist statespace_custom_models
+	@echo "Copying notebooks that failed execution (there are usually several in Debian because some need network and/or dependencies we don't have)"
+	cp -nav ../examples/notebooks/*.ipynb -t source/examples/notebooks/generated || true
+ifneq ($(SOURCE_DATE_EPOCH),)
+	@echo "Replacing timestamps and build paths in examples output for reproducibility"
+	for html in `find source/examples/notebooks/generated -name "*.html" -o -name "*.ipynb" -o -name "*.ipynb.txt"` ; do \
+	    sed -i -e 's#$(PYTHONPATH)/statsmodels/#/usr/lib/python3/dist-packages/statsmodels/#g' \
+	    -e 's# at 0x[0-9a-f]\{8,16\}\(&gt;\|>\)# at 0xadde5de1e8ed\1#g' \
+	    -e 's#tmp/ipykernel_[0-9]\+#tmp/ipykernel_nnnnnnn#g' \
+	    -e 's#^\s\+.\(iopub.execute_input\|iopub.status.busy\|iopub.status.idle\|shell.execute_reply\).:.*# #g' \
+	    -e 's#\(Date:.*\)[A-Z][a-z]\+, \+[0-9]\+,\? \+[A-Z][a-z]\+,\? \+[0-9]\+#\1$(SOURCE_DATE)#g' \
+	    -e 's#\(Time:.*\)[0-9][0-9]:[0-9][0-9]:[0-9][0-9]#\1$(SOURCE_TIME)#g' $${html} ; \
+	done
+endif
 	@echo "Running sphinx-build"
 	@echo @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(O)
 	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(O)