Skip to content

Commit

Permalink
Add 'tests/' from commit '2efb9cad60ee5a26c4bed628f1b6a0be262eb040'
Browse files Browse the repository at this point in the history
git-subtree-dir: tests
git-subtree-mainline: 25eabab
git-subtree-split: 2efb9ca
  • Loading branch information
kangwonlee committed Oct 23, 2018
0 parents commit c6ef284
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 0 deletions.
109 changes: 109 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.idea/
*.cfg

# pytest
.pytest_cache/

# MS VS Code
.vscode/
16 changes: 16 additions & 0 deletions environment.3.6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ref : Francesco Mosconi, Travis + Anaconda + Jupyter, https://github.com/ghego/travis_anaconda_jupyter

name: travis_anaconda_jupyter
channels:
- defaults

dependencies:
- python<3.7
# Anaconda 5.0.1 python 3.6
- numpy=1.13.3
- scipy=0.19.1
- sympy=1.1.1
- jupyter=1.0.0
- pytest=3.2.1
- matplotlib=2.1.0
- pandas=0.23.4
18 changes: 18 additions & 0 deletions environment.3.7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ref : Francesco Mosconi, Travis + Anaconda + Jupyter, https://github.com/ghego/travis_anaconda_jupyter

name: travis_anaconda_jupyter
channels:
- defaults

dependencies:
- python<3.8
# Anaconda 5.3 python 3.7
# https://docs.anaconda.com/anaconda/packages/py3.7_win-64/
- jupyter=1.0.0
- matplotlib=2.2.3
- numpy=1.15.1
- pandas=0.23.4
- pytest=3.8.0
- scipy=1.1.0
- statsmodels=0.9.0
- sympy=1.1.1
16 changes: 16 additions & 0 deletions environment.nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ref : Francesco Mosconi, Travis + Anaconda + Jupyter, https://github.com/ghego/travis_anaconda_jupyter

name: travis_anaconda_jupyter
channels:
- defaults

dependencies:
- python>=3.7
- jupyter>=1.0.0
- matplotlib>=2.2.3
- numpy>=1.15.1
- pandas>=0.23.4
- pytest>=3.8.0
- scipy>=1.1.0
- statsmodels>=0.9.0
- sympy>=1.1.1
54 changes: 54 additions & 0 deletions test_nb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# ref : Francesco Mosconi, Travis + Anaconda + Jupyter, https://github.com/ghego/travis_anaconda_jupyter


import os
import pytest
import subprocess
import tempfile


def check_kernel_spec():
# https://jupyter-client.readthedocs.io/en/latest/api/kernelspec.html
import jupyter_client.kernelspec as jk

kernel_spec_manager = jk.KernelSpecManager()

print(kernel_spec_manager.get_all_specs())


def _exec_notebook(path):
# http://nbconvert.readthedocs.io/en/latest/execute_api.html
# ijstokes et al, Command line execution of a jupyter notebook fails in default Anaconda 4.1, https://github.com/Anaconda-Platform/nb_conda_kernels/issues/34
with tempfile.NamedTemporaryFile(suffix=".ipynb") as fout:
args = ["jupyter", "nbconvert", "--to", "notebook", "--execute",
"--ExecutePreprocessor.timeout=1000",
"--ExecutePreprocessor.kernel_name=python",
"--output", fout.name, path]
subprocess.check_call(args)


folder_list = (
'00_introduction',
'10_root_finding',
'20_interpolation',
'30_num_int',
'40_linear_algebra_1',
'50_ode',
'60_linear_algebra_2',
)


# https://docs.pytest.org/en/latest/example/parametrize.html
@pytest.mark.parametrize("folder", folder_list)
def test_ipynb_in_folder(folder):
path = os.path.join(os.pardir, folder)
ext = 'ipynb'

# recursive loop
for root, dirnames, filenames in os.walk(path):
if 'ipynb_checkpoints' not in root:
# files loop
for filename in filenames:
if os.path.splitext(filename)[-1].endswith(ext):
print('test() : %s %s' % (root, filename))
_exec_notebook(os.path.join(root, filename))

0 comments on commit c6ef284

Please sign in to comment.