Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions _doc/notebooks/having_a_form_in_a_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1116,32 +1116,6 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
},
"widgets": {
"state": {
"6f6cf4a1f7df4a99ba95db615ec86dff": {
"views": [
{
"cell_index": 20
}
]
},
"c67410ee5aa443b9a6cb53d4f46becec": {
"views": [
{
"cell_index": 20
}
]
},
"dd3c00717e9d48b99bb5e34462b15fa0": {
"views": [
{
"cell_index": 20
}
]
}
},
"version": "1.2.0"
}
},
"nbformat": 4,
Expand Down
12 changes: 0 additions & 12 deletions _unittests/ut_helpgen/notebooks/td2a_cenonce_session_3A.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1636,18 +1636,6 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
},
"widgets": {
"state": {
"37694361e5da4eb38daa525f8bb2117c": {
"views": [
{
"cell_index": 9
}
]
}
},
"version": "1.2.0"
}
},
"nbformat": 4,
Expand Down
32 changes: 1 addition & 31 deletions _unittests/ut_helpgen/test_notebooks_bug.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,31 @@
import os
import unittest
import re
from pyquickhelper.loghelper import fLOG
from pyquickhelper.helpgen.sphinx_main import process_notebooks
from pyquickhelper.pycode import is_travis_or_appveyor, get_temp_folder, ExtTestCase


class TestNoteBooksBug(ExtTestCase):

def test_regex(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
exp = re.compile(r"(.{3}[\\]\$)")
s = ": [ ['$',"
fLOG(s)
r = exp.finditer(s)
nb = 0
for _ in r:
fLOG("1", _.groups())
nb += 1
nb1 = nb

s = r"\def\PYZdl{\char`\$}"
fLOG(s)
r = exp.finditer(s)
nb = 0
for _ in r:
fLOG("2", _.groups())
nb += 1

self.assertEqual(nb1, 0)
self.assertTrue(nb > 0)

def test_notebook(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
path = os.path.abspath(os.path.split(__file__)[0])
fold = os.path.normpath(os.path.join(path, "notebooks"))
nbs = [os.path.join(fold, _)
Expand All @@ -55,7 +42,6 @@ def test_notebook(self):
return

res = process_notebooks(nbs, temp, temp, formats=formats)
fLOG("*****", len(res))
for _ in res:
if not os.path.exists(_[0]):
raise Exception(_[0])
Expand All @@ -67,10 +53,6 @@ def test_notebook(self):
raise Exception(content)

def test_notebook_html(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
path = os.path.abspath(os.path.split(__file__)[0])
fold = os.path.normpath(os.path.join(path, "notebooks"))
nbs = [os.path.join(fold, _)
Expand All @@ -83,16 +65,11 @@ def test_notebook_html(self):
return

res = process_notebooks(nbs, temp, temp, formats=formats)
fLOG("*****", len(res))
for _ in res:
if not os.path.exists(_[0]):
raise Exception(_[0])

def test_notebook_slides(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
path = os.path.abspath(os.path.split(__file__)[0])
fold = os.path.normpath(os.path.join(path, "notebooks"))
nbs = [os.path.join(fold, _)
Expand All @@ -105,7 +82,6 @@ def test_notebook_slides(self):
return

res = process_notebooks(nbs, temp, temp, formats=formats)
fLOG("*****", len(res))
for _ in res:
if not os.path.exists(_[0]):
raise Exception(_[0])
Expand All @@ -117,10 +93,6 @@ def test_notebook_slides(self):
raise Exception(check)

def test_notebook_pdf(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
path = os.path.abspath(os.path.split(__file__)[0])
fold = os.path.normpath(os.path.join(path, "notebooks"))
nbs = [os.path.join(fold, _)
Expand All @@ -137,9 +109,7 @@ def test_notebook_pdf(self):
return

res = process_notebooks(nbs, temp, temp, formats=formats)
fLOG("*****", len(res))
for _ in res:
fLOG(_)
self.assertExists(_[0])

check = os.path.join(temp, "td1a_correction_session4.tex")
Expand All @@ -150,4 +120,4 @@ def test_notebook_pdf(self):


if __name__ == "__main__":
unittest.main()
unittest.main(verbosity=2)
14 changes: 12 additions & 2 deletions src/pyquickhelper/ipythonhelper/notebook_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ def remove_execution_number(infile, outfile=None, encoding="utf-8", indent=2, ru
@param indent indentation
@param rule determines the rule which specifies execution numbers,
'None' for None, 'int' for consectuive integers numbers.
@return modified string or None if outfile is not None and the file was not modified
@return modified string or None if outfile is not None
and the file was not modified

.. todoext::
:title: remove execution number from notebook facilitate git versionning
Expand All @@ -465,7 +466,8 @@ def remove_execution_number(infile, outfile=None, encoding="utf-8", indent=2, ru
Remove execution number from the notebook
to avoid commiting changes only about those numbers

`notebook 5.1.0 <https://jupyter-notebook.readthedocs.io/en/stable/changelog.html>`_
`notebook 5.1.0
<https://jupyter-notebook.readthedocs.io/en/stable/changelog.html>`_
introduced changes which are incompatible with
leaving the cell executing number empty.
"""
Expand Down Expand Up @@ -497,9 +499,17 @@ def fixup(adict, k, v, cellno=0, outputs="outputs"):
outputs=outputs)
return cellno

def widget(adict):
metadata = adict.get('metadata', None)
if metadata is None:
return
if 'widgets' in metadata:
del metadata['widgets']

content = read_content_ufs(infile)
js = json.loads(content)
fixup(js, "execution_count", None)
widget(js)
st = StringIO()
json.dump(js, st, indent=indent, sort_keys=True)
res = st.getvalue()
Expand Down
6 changes: 0 additions & 6 deletions src/pyquickhelper/sphinxext/sphinximages/sphinxtrib/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,6 @@ def configure_backend(app):
# because sphinx try to make a pickle from it.
app.sphinxtrib_images_backend = backend

logger = logging.getLogger("image")
logger.info(
'Initiated images backend: %s:%s',
backend.__class__.__module__,
backend.__class__.__name__)

def backend_methods(node, output_type):
"local function"
def backend_method(f):
Expand Down