Skip to content
Snippets Groups Projects
Commit 9de3da34 authored by Martin Bauer's avatar Martin Bauer
Browse files

pytest and coverage improvements

- notebooks are considered in coverage analysis now
   -> custom notebook runner plugin adapted
- added images for documentation
parent ae4bbde0
No related branches found
No related tags found
No related merge requests found
Showing
with 5361 additions and 34 deletions
...@@ -3,4 +3,15 @@ branch = True ...@@ -3,4 +3,15 @@ branch = True
source = pystencils source = pystencils
lbmpy lbmpy
pyphasefield pyphasefield
omit = setup_lbmpy.py
setup_lbmpy_walberla.py
setup_pyphasefield.py
setup_pystencils.py
doc/*
benchmark/*
pyphasefield_tests/*
lbmpy_tests/*
pystencils_tests/*
lbmpy_benchmarks/*
conftest.py
...@@ -6,3 +6,6 @@ __pycache__ ...@@ -6,3 +6,6 @@ __pycache__
/build /build
/dist /dist
/*.egg-info /*.egg-info
.cache
_build
/.idea
...@@ -2,12 +2,18 @@ ...@@ -2,12 +2,18 @@
tests-and-coverage: tests-and-coverage:
image: i10git.cs.fau.de:5005/software/pystencils image: i10git.cs.fau.de:5005/software/pystencils
script: script:
- py.test --doctest-modules -v --durations=10 -n 4 --cov-config .coveragerc --cov=. -m "not longrun" - export NUM_CORES=$(nproc --all)
- mkdir -p ~/.config/matplotlib
- echo "backend:template" > ~/.config/matplotlib/matplotlibrc
- py.test -n $NUM_CORES --cov-report html --cov-report term --cov=. -m "not longrun"
tags: tags:
- docker - docker
- cuda - cuda
- AVX - AVX
artifacts:
paths:
- htmlcov
build-documentation: build-documentation:
image: i10git.cs.fau.de:5005/software/pystencils image: i10git.cs.fau.de:5005/software/pystencils
......
...@@ -27,7 +27,7 @@ ENV LC_ALL en_US.UTF-8 ...@@ -27,7 +27,7 @@ ENV LC_ALL en_US.UTF-8
RUN conda uninstall --yes gmpy2 sympy RUN conda uninstall --yes gmpy2 sympy
RUN conda install --yes -c lssfau \ RUN conda install --yes -c lssfau \
appdirs pytest pytest-cov jupyter matplotlib joblib pillow scipy runipy sphinx sphinx_rtd_theme\ appdirs pytest pytest-cov jupyter matplotlib joblib pillow scipy sphinx sphinx_rtd_theme\
llvmlite walberla gitpython pyqt llvmlite walberla gitpython pyqt
RUN pip install pytest-xdist graphviz ipy_table \ RUN pip install pytest-xdist graphviz ipy_table \
......
...@@ -73,19 +73,40 @@ collect_ignore += [os.path.join(SCRIPT_FOLDER, 'setup_pystencils.py'), ...@@ -73,19 +73,40 @@ collect_ignore += [os.path.join(SCRIPT_FOLDER, 'setup_pystencils.py'),
os.path.join(SCRIPT_FOLDER, 'setup_pyphasefield.py'), os.path.join(SCRIPT_FOLDER, 'setup_pyphasefield.py'),
os.path.join(SCRIPT_FOLDER, 'setup_lbmpy_walberla.py')] os.path.join(SCRIPT_FOLDER, 'setup_lbmpy_walberla.py')]
from runipy.notebook_runner import NotebookRunner for root, sub_dirs, files in os.walk('.'):
from nbformat import read as readNotebook for f in files:
if f.endswith(".ipynb") and not any(f.startswith(k) for k in ['demo', 'tutorial', 'test', 'doc']):
collect_ignore.append(f)
import nbformat
from nbconvert import PythonExporter
class IPythonMockup:
def run_line_magic(self, *args, **kwargs):
pass
def run_cell_magic(self, *args, **kwargs):
pass
def magic(self, *args, **kwargs):
pass
def __bool__(self):
return False
class IPyNbTest(pytest.Item): class IPyNbTest(pytest.Item):
def __init__(self, name, parent, runner): def __init__(self, name, parent, code):
super(IPyNbTest, self).__init__(name, parent) super(IPyNbTest, self).__init__(name, parent)
self.runner = runner self.code = code
def runtest(self): def runtest(self):
try: globalDict = {'get_ipython': lambda: IPythonMockup()}
self.runner.run_notebook() exec("import matplotlib.pyplot as p; p.switch_backend('Template')", globalDict) # disable matplotlib output
except NotImplementedError: # skip exceptions triggered by jupyter widgets exec(self.code, globalDict)
pass
def repr_failure(self, excinfo): def repr_failure(self, excinfo):
""" called when self.runtest() raises an exception. """ """ called when self.runtest() raises an exception. """
...@@ -94,12 +115,17 @@ class IPyNbTest(pytest.Item): ...@@ -94,12 +115,17 @@ class IPyNbTest(pytest.Item):
class IPyNbFile(pytest.File): class IPyNbFile(pytest.File):
def collect(self): def collect(self):
exporter = PythonExporter()
exporter.exclude_markdown = True
exporter.exclude_input_prompt = True
notebookContents = self.fspath.open() notebookContents = self.fspath.open()
self.runner = NotebookRunner(readNotebook(notebookContents, 3)) notebook = nbformat.read(notebookContents, 4)
yield IPyNbTest(self.name, self, self.runner) code, _ = exporter.from_notebook_node(notebook)
yield IPyNbTest(self.name, self, code)
def teardown(self): def teardown(self):
self.runner.shutdown_kernel() pass
def pytest_collect_file(path, parent): def pytest_collect_file(path, parent):
......
This diff is collapsed.
doc/img/boundary_nosliplist.png

47.1 KiB

doc/img/boundary_ubblist.png

70.1 KiB

This diff is collapsed.
File moved
File moved
File moved
...@@ -9,7 +9,7 @@ This repository consists of three modules: ...@@ -9,7 +9,7 @@ This repository consists of three modules:
The pystencils module if the basis for the two advanced modules *lbmpy* (lattice Boltzmann methods) The pystencils module if the basis for the two advanced modules *lbmpy* (lattice Boltzmann methods)
and *pyphasefield* (phase-field models with finite differences). and *pyphasefield* (phase-field models with finite differences).
.. image:: moduleOverview.svg .. image:: img/moduleOverview.svg
Table of contents Table of contents
......
%% Cell type:markdown id: tags:
# Get demo notebooks of newest version
The interactive demo site your currently on, regularly updates the pystencils/lbmpy installation.
These updates might introduce API changes, so the demo and tutorial notebooks in your home directory that have been created there on your first login may be outdated.
We do not overwrite them automatically, since you might have changed them or created new notebooks in these demo folders.
Run this notebook to get the newest demos and tutorials. Your old folder is moved - not deleted.
%% Cell type:code id: tags:
``` python
import shutil, glob, os, datetime, socket
newNotebooks = "/opt/notebooks"
home = os.path.expanduser("~")
if os.path.exists(newNotebooks): # safeguard - when executed in another environment
backupPath = os.path.join(home, 'backup_' + str(datetime.datetime.now()))
os.mkdir(backupPath)
for file in glob.glob(os.path.join(home, '*')):
shutil.move(file, backupPath)
print("Files have been moved from your home to ", backupPath)
os.system("cp -r %s/* %s" % (newNotebooks,home))
```
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.2" "version": "3.6.4"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="215.91653mm"
height="136.50279mm"
viewBox="0 0 765.05858 483.67131"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="containerScenario.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="356.63429"
inkscape:cy="453.36919"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="20"
fit-margin-left="20"
fit-margin-right="20"
fit-margin-bottom="20"
inkscape:window-width="2560"
inkscape:window-height="1371"
inkscape:window-x="4480"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-5.3692855,-59.353126)">
<g
id="g4213"
transform="translate(0,-7.7074907e-5)"
inkscape:export-xdpi="92.410004"
inkscape:export-ydpi="92.410004">
<rect
ry="0"
y="130.21935"
x="80"
height="45.714287"
width="101.42857"
id="rect4136"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
ry="0"
y="130.21935"
x="252.61903"
height="45.714287"
width="101.42857"
id="rect4136-3"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
ry="0"
y="130.21935"
x="425.23807"
height="45.714287"
width="101.42857"
id="rect4136-6"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
ry="0"
y="130.21935"
x="597.85712"
height="45.714287"
width="101.42857"
id="rect4136-93"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g>
<g
transform="translate(0.2760347,98.7415)"
id="g4213-6"
inkscape:export-xdpi="92.410004"
inkscape:export-ydpi="92.410004">
<rect
ry="0"
y="130.21935"
x="80"
height="45.714287"
width="101.42857"
id="rect4136-0"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
ry="0"
y="130.21935"
x="252.61903"
height="45.714287"
width="101.42857"
id="rect4136-3-6"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
ry="0"
y="130.21935"
x="425.23807"
height="45.714287"
width="101.42857"
id="rect4136-6-2"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
ry="0"
y="130.21935"
x="597.85712"
height="45.714287"
width="101.42857"
id="rect4136-93-6"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g>
<g
transform="translate(-1.7442682,197.48308)"
id="g4213-1"
inkscape:export-xdpi="92.410004"
inkscape:export-ydpi="92.410004">
<rect
ry="0"
y="130.21935"
x="80"
height="45.714287"
width="101.42857"
id="rect4136-8"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
ry="0"
y="130.21935"
x="252.61903"
height="45.714287"
width="101.42857"
id="rect4136-3-7"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
ry="0"
y="130.21935"
x="425.23807"
height="45.714287"
width="101.42857"
id="rect4136-6-9"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
ry="0"
y="130.21935"
x="597.85712"
height="45.714287"
width="101.42857"
id="rect4136-93-2"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g>
<g
transform="translate(-3.7645728,296.22465)"
id="g4213-0"
inkscape:export-xdpi="92.410004"
inkscape:export-ydpi="92.410004">
<rect
ry="0"
y="130.21935"
x="80"
height="45.714287"
width="101.42857"
id="rect4136-2"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
ry="0"
y="130.21935"
x="252.61903"
height="45.714287"
width="101.42857"
id="rect4136-3-3"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
ry="0"
y="130.21935"
x="425.23807"
height="45.714287"
width="101.42857"
id="rect4136-6-7"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
ry="0"
y="130.21935"
x="597.85712"
height="45.714287"
width="101.42857"
id="rect4136-93-5"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g>
</g>
</svg>
This diff is collapsed.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
doc/modules/lbmpy/materials/arteryTree.png

386 KiB

doc/modules/lbmpy/materials/d3q19.png

39.9 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment