Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 9f9f0fa

Browse files
committed
new notebook on treant-js
1 parent da118a4 commit 9f9f0fa

10 files changed

+1146
-7
lines changed

_doc/notebooks/2016/pydata/big_datashader.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@
676676
" df = df [(df.Dropoff_longitude < -10) & (df.Pickup_longitude < -10)]\n",
677677
" df.sample(100000).to_csv(\"green_tripdata_2015-12_sample.csv\")\n",
678678
"else:\n",
679-
" df.read_csv(\"green_tripdata_2015-12_sample.csv\")\n",
679+
" df = pd.read_csv(\"green_tripdata_2015-12_sample.csv\")\n",
680680
"df.tail()"
681681
]
682682
},

_doc/notebooks/2016/pydata/im_missingno.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
" df = pandas.read_csv(\"NYPD_Motor_Vehicle_Collisions.csv\")\n",
193193
" df.sample(10000).to_csv(\"NYPD_Motor_Vehicle_Collisions_sample.csv\")\n",
194194
"\n",
195-
"df = pandas.read_csv(\"NYPD_Motor_Vehicle_Collisions_small.csv\")"
195+
"df = pandas.read_csv(\"NYPD_Motor_Vehicle_Collisions_sample.csv\")"
196196
]
197197
},
198198
{

_doc/notebooks/2016/pydata/jsonly_treant.ipynb

Lines changed: 882 additions & 0 deletions
Large diffs are not rendered by default.

_doc/sphinxdoc/source/2016/pydata2016.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ it involves a server (bqplot).
3939
* :ref:`jspythreejsrst`
4040
* :ref:`jsvegarst`
4141

42+
**Pure javascript**
43+
44+
: :ref:`jsonlytreantrst`
45+
4246
**Big Data**
4347

4448
* :ref:`bigdatashaderrst`
4549

46-
4750
**GUI**
4851

4952
* :ref:`guigeoplotlibrst`
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#-*- coding: utf-8 -*-
2+
"""
3+
@brief test log(time=12s)
4+
"""
5+
6+
import sys
7+
import os
8+
import unittest
9+
import shutil
10+
11+
12+
try:
13+
import pyquickhelper as skip_
14+
except ImportError:
15+
path = os.path.normpath(
16+
os.path.abspath(
17+
os.path.join(
18+
os.path.split(__file__)[0],
19+
"..",
20+
"..",
21+
"..",
22+
"pyquickhelper",
23+
"src")))
24+
if path not in sys.path:
25+
sys.path.append(path)
26+
import pyquickhelper as skip_
27+
28+
29+
try:
30+
import src
31+
except ImportError:
32+
path = os.path.normpath(
33+
os.path.abspath(
34+
os.path.join(
35+
os.path.split(__file__)[0],
36+
"..",
37+
"..")))
38+
if path not in sys.path:
39+
sys.path.append(path)
40+
import src
41+
42+
from pyquickhelper.loghelper import fLOG
43+
from pyquickhelper.pycode import get_temp_folder
44+
from pyquickhelper.ipythonhelper import execute_notebook_list
45+
from pyquickhelper.pycode import compare_module_version
46+
from pyquickhelper.ipythonhelper import install_python_kernel_for_unittest
47+
import IPython
48+
49+
50+
class TestRunNotebooksPyData2016_big(unittest.TestCase):
51+
52+
def test_run_notebook_big(self):
53+
fLOG(
54+
__file__,
55+
self._testMethodName,
56+
OutputPrint=__name__ == "__main__")
57+
58+
if sys.version_info[0] == 2:
59+
# notebooks are not converted into python 2.7, so not tested
60+
return
61+
62+
if compare_module_version(IPython.__version__, "4.0.0") < 0:
63+
# IPython is not recnt enough
64+
return
65+
66+
kernel_name = None if "travis" in sys.executable else install_python_kernel_for_unittest(
67+
"python3_module_template")
68+
69+
temp = get_temp_folder(__file__, "temp_run_notebooks_big")
70+
71+
# selection of notebooks
72+
fnb = os.path.normpath(os.path.join(
73+
os.path.abspath(os.path.dirname(__file__)), "..", "..", "_doc", "notebooks", "2016", "pydata"))
74+
keepnote = []
75+
for f in os.listdir(fnb):
76+
if os.path.splitext(f)[-1] == ".ipynb" and "big_" in f:
77+
keepnote.append(os.path.join(fnb, f))
78+
assert len(keepnote) > 0
79+
80+
# function to tell that a can be run
81+
def valid(cell):
82+
if "open_html_form" in cell:
83+
return False
84+
if "open_window_params" in cell:
85+
return False
86+
if '<div style="position:absolute' in cell:
87+
return False
88+
return True
89+
90+
# file to copy
91+
for cop in ["green_tripdata_2015-12_sample.csv",
92+
"NYPD_Motor_Vehicle_Collisions_sample.csv",
93+
"NYPD_Motor_Vehicle_Collisions_small.csv"]:
94+
fsrc = os.path.join(fnb, cop)
95+
if os.path.exists(fsrc):
96+
dest = temp
97+
shutil.copy(fsrc, dest)
98+
99+
# additionnal path to add
100+
addpaths = [os.path.normpath(os.path.join(
101+
os.path.abspath(os.path.dirname(__file__)), "..", "..", "src")),
102+
os.path.normpath(os.path.join(
103+
os.path.abspath(os.path.dirname(__file__)), "..", "..", "..", "pyquickhelper", "src"))
104+
]
105+
106+
# creation of a kernel
107+
kernel_name = None if "travis" in sys.executable else install_python_kernel_for_unittest(
108+
"python3_module_template")
109+
110+
# run the notebooks
111+
res = execute_notebook_list(
112+
temp, keepnote, fLOG=fLOG, valid=valid, additional_path=addpaths, kernel_name=kernel_name)
113+
114+
# final checkings
115+
assert len(res) > 0
116+
fails = [(os.path.split(k)[-1], v)
117+
for k, v in sorted(res.items()) if not v[0]]
118+
for f in fails:
119+
fLOG(f)
120+
for k, v in sorted(res.items()):
121+
name = os.path.split(k)[-1]
122+
fLOG(name, v[0], v[1])
123+
if len(fails) > 0:
124+
raise fails[0][1][-1]
125+
126+
if __name__ == "__main__":
127+
unittest.main()

_unittests/ut_documentation/test_run_notebooks_pydata_2016_gui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
class TestRunNotebooksPyData2016_gui(unittest.TestCase):
5050

51-
def test_run_notebook_im(self):
51+
def test_run_notebook_gui(self):
5252
fLOG(
5353
__file__,
5454
self._testMethodName,

_unittests/ut_documentation/test_run_notebooks_pydata_2016_im.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import sys
77
import os
88
import unittest
9+
import shutil
910

1011

1112
try:
@@ -86,6 +87,15 @@ def valid(cell):
8687
return False
8788
return True
8889

90+
# file to copy
91+
for cop in ["green_tripdata_2015-12_sample.csv",
92+
"NYPD_Motor_Vehicle_Collisions_sample.csv",
93+
"NYPD_Motor_Vehicle_Collisions_small.csv"]:
94+
fsrc = os.path.join(fnb, cop)
95+
if os.path.exists(fsrc):
96+
dest = temp
97+
shutil.copy(fsrc, dest)
98+
8999
# additionnal path to add
90100
addpaths = [os.path.normpath(os.path.join(
91101
os.path.abspath(os.path.dirname(__file__)), "..", "..", "src")),

_unittests/ut_documentation/test_run_notebooks_pydata_2016_js.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
import IPython
4747

4848

49-
class TestRunNotebooksPyData2016_im(unittest.TestCase):
49+
class TestRunNotebooksPyData2016_js(unittest.TestCase):
5050

51-
def test_run_notebook_im(self):
51+
def test_run_notebook_js(self):
5252
fLOG(
5353
__file__,
5454
self._testMethodName,
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#-*- coding: utf-8 -*-
2+
"""
3+
@brief test log(time=12s)
4+
"""
5+
6+
import sys
7+
import os
8+
import unittest
9+
10+
11+
try:
12+
import pyquickhelper as skip_
13+
except ImportError:
14+
path = os.path.normpath(
15+
os.path.abspath(
16+
os.path.join(
17+
os.path.split(__file__)[0],
18+
"..",
19+
"..",
20+
"..",
21+
"pyquickhelper",
22+
"src")))
23+
if path not in sys.path:
24+
sys.path.append(path)
25+
import pyquickhelper as skip_
26+
27+
28+
try:
29+
import src
30+
except ImportError:
31+
path = os.path.normpath(
32+
os.path.abspath(
33+
os.path.join(
34+
os.path.split(__file__)[0],
35+
"..",
36+
"..")))
37+
if path not in sys.path:
38+
sys.path.append(path)
39+
import src
40+
41+
from pyquickhelper.loghelper import fLOG
42+
from pyquickhelper.pycode import get_temp_folder
43+
from pyquickhelper.ipythonhelper import execute_notebook_list
44+
from pyquickhelper.pycode import compare_module_version
45+
from pyquickhelper.ipythonhelper import install_python_kernel_for_unittest
46+
import IPython
47+
48+
49+
class TestRunNotebooksPyData2016_jsonly(unittest.TestCase):
50+
51+
def test_run_notebook_jsonly(self):
52+
fLOG(
53+
__file__,
54+
self._testMethodName,
55+
OutputPrint=__name__ == "__main__")
56+
57+
if sys.version_info[0] == 2:
58+
# notebooks are not converted into python 2.7, so not tested
59+
return
60+
61+
if compare_module_version(IPython.__version__, "4.0.0") < 0:
62+
# IPython is not recnt enough
63+
return
64+
65+
kernel_name = None if "travis" in sys.executable else install_python_kernel_for_unittest(
66+
"python3_module_template")
67+
68+
temp = get_temp_folder(__file__, "temp_run_notebooks_jsonly")
69+
70+
# selection of notebooks
71+
fnb = os.path.normpath(os.path.join(
72+
os.path.abspath(os.path.dirname(__file__)), "..", "..", "_doc", "notebooks", "2016", "pydata"))
73+
keepnote = []
74+
for f in os.listdir(fnb):
75+
if os.path.splitext(f)[-1] == ".ipynb" and "jsonly_" in f:
76+
keepnote.append(os.path.join(fnb, f))
77+
assert len(keepnote) > 0
78+
79+
# function to tell that a can be run
80+
def valid(cell):
81+
if "open_html_form" in cell:
82+
return False
83+
if "open_window_params" in cell:
84+
return False
85+
if '<div style="position:absolute' in cell:
86+
return False
87+
return True
88+
89+
# additionnal path to add
90+
addpaths = [os.path.normpath(os.path.join(
91+
os.path.abspath(os.path.dirname(__file__)), "..", "..", "src")),
92+
os.path.normpath(os.path.join(
93+
os.path.abspath(os.path.dirname(__file__)), "..", "..", "..", "pyquickhelper", "src"))
94+
]
95+
96+
# creation of a kernel
97+
kernel_name = None if "travis" in sys.executable else install_python_kernel_for_unittest(
98+
"python3_module_template")
99+
100+
# run the notebooks
101+
res = execute_notebook_list(
102+
temp, keepnote, fLOG=fLOG, valid=valid, additional_path=addpaths, kernel_name=kernel_name)
103+
104+
# final checkings
105+
assert len(res) > 0
106+
fails = [(os.path.split(k)[-1], v)
107+
for k, v in sorted(res.items()) if not v[0]]
108+
for f in fails:
109+
fLOG(f)
110+
for k, v in sorted(res.items()):
111+
name = os.path.split(k)[-1]
112+
fLOG(name, v[0], v[1])
113+
if len(fails) > 0:
114+
raise fails[0][1][-1]
115+
116+
if __name__ == "__main__":
117+
unittest.main()

_unittests/ut_documentation/test_run_notebooks_pydata_2016_pyjs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
class TestRunNotebooksPyData2016_pyjs(unittest.TestCase):
5050

51-
def test_run_notebook_im(self):
51+
def test_run_notebook_pyjs(self):
5252
fLOG(
5353
__file__,
5454
self._testMethodName,

0 commit comments

Comments
 (0)