Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • ravi.k.ayyala/lbmpy
  • brendan-waters/lbmpy
  • anirudh.jonnalagadda/lbmpy
  • jbadwaik/lbmpy
  • alexander.reinauer/lbmpy
  • itischler/lbmpy
  • he66coqe/lbmpy
  • ev81oxyl/lbmpy
  • Bindgen/lbmpy
  • da15siwa/lbmpy
  • holzer/lbmpy
  • RudolfWeeber/lbmpy
  • pycodegen/lbmpy
13 results
Select Git revision
Show changes
Commits on Source (388)
Showing with 1561 additions and 114 deletions
[flake8] [flake8]
max-line-length=120 max-line-length=120
exclude=lbmpy/plot.py exclude=src/lbmpy/plot.py
lbmpy/session.py src/lbmpy/session.py
ignore = W293 W503 W291 ignore = W293 W503 W291 C901 E741
src/lbmpy/_version.py export-subst
__pycache__ __pycache__
.ipynb_checkpoints .ipynb_checkpoints
.coverage .coverage*
*.pyc *.pyc
*.vti *.vti
/build /build
/html_doc
/dist /dist
/*.egg-info *.egg-info
.cache .cache
_build _build
/.idea /.idea
.cache _local_tmp
_local_tmp **/.vscode
\ No newline at end of file **/pylintrc
*.bak
*.tmp
/tests/db
doc/bibtex.json
/db
/src/lbmpy/phasefield/simplex_projection.*.so
/src/lbmpy/phasefield/simplex_projection.c
test-report
report.xml
# macOS
**/.DS_Store
*.uuid
# benchmark database
/tests/benchmark/db
\ No newline at end of file
stages: stages:
- test - "Code Quality"
- "Tests"
- "Prerelease-Tests"
- integration
- nightly
- docs
- deploy - deploy
# -------------------------- Code Quality --------------------------------------------------------------------------------
# -------------------------- Tests ------------------------------------------------------------------------------------
# Linter for code formatting
flake8-lint:
stage: "Code Quality"
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:alpine
script:
- nox -s lint
tags:
- docker
# -------------------------- Tests --------------------------------------------------------------------------------
# Normal test - runs on every commit all but "long run" tests # Normal test - runs on every commit all but "long run" tests
tests-and-coverage: testsuite-cuda-py3.10:
stage: test stage: "Tests"
except: image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:ubuntu24.04-cuda12.6
variables: needs: []
- $ENABLE_NIGHTLY_BUILDS
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
script: script:
- export NUM_CORES=$(nproc --all)
- mkdir -p ~/.config/matplotlib - mkdir -p ~/.config/matplotlib
- echo "backend:template" > ~/.config/matplotlib/matplotlibrc - echo "backend:template" > ~/.config/matplotlib/matplotlibrc
- mkdir public - nox -s "testsuite_gpu-3.10(cupy12)"
- pip install git+https://gitlab-ci-token:${CI_JOB_TOKEN}@i10git.cs.fau.de/pycodegen/pystencils.git@master#egg=pystencils
- py.test -v -n $NUM_CORES --cov-report html --cov-report term --cov=. -m "not longrun"
tags: tags:
- docker - docker
- cuda - cuda
- cudaComputeCapability6.1
- AVX - AVX
coverage: /Total coverage:\s\d+.\d+\%/
artifacts: artifacts:
when: always when: always
paths: paths:
- coverage_report - coverage_report
- test-report
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
junit: report.xml
# Nightly test - runs "long run" jobs only
test-longrun: testsuite-cpu-py3.13:
stage: test stage: "Tests"
only: image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:alpine
variables: needs: []
- $ENABLE_NIGHTLY_BUILDS
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
script: script:
- export NUM_CORES=$(nproc --all)
- mkdir -p ~/.config/matplotlib - mkdir -p ~/.config/matplotlib
- echo "backend:template" > ~/.config/matplotlib/matplotlibrc - echo "backend:template" > ~/.config/matplotlib/matplotlibrc
- pip install git+https://gitlab-ci-token:${CI_JOB_TOKEN}@i10git.cs.fau.de/pycodegen/pystencils.git@master#egg=pystencils - nox -s "testsuite_cpu-3.13"
- py.test -v -n $NUM_CORES --cov-report html --cov-report term --cov=.
tags: tags:
- docker - docker
- cuda
- AVX - AVX
artifacts: artifacts:
when: always
paths: paths:
- coverage_report - test-report
reports:
junit: report.xml
# Minimal tests in windows environment
minimal-windows: # Normal test with longruns
stage: test tests-and-coverage-with-longrun:
except: stage: "Tests"
variables: when: manual
- $ENABLE_NIGHTLY_BUILDS allow_failure: true
tags: image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
- win
script: script:
- source /cygdrive/c/Users/build/Miniconda3/Scripts/activate # - pip install sympy --upgrade
- source activate pystencils_dev - export NUM_CORES=$(nproc --all)
- env - mkdir -p ~/.config/matplotlib
- conda env list - echo "backend:template" > ~/.config/matplotlib/matplotlibrc
- mkdir public
- pip install git+https://gitlab-ci-token:${CI_JOB_TOKEN}@i10git.cs.fau.de/pycodegen/pystencils.git@master#egg=pystencils - pip install git+https://gitlab-ci-token:${CI_JOB_TOKEN}@i10git.cs.fau.de/pycodegen/pystencils.git@master#egg=pystencils
- python -c "import numpy" - env
- python setup.py quicktest - pip list
- py.test -v -n $NUM_CORES
minimal-ubuntu: tags:
stage: test - docker
except: - cuda
variables: - cudaComputeCapability6.1
- $ENABLE_NIGHTLY_BUILDS - AVX
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/minimal_ubuntu
# -------------------------- Nightly and Pre-Release Tests --------------------------------------------------------------------------------
# Test against latest pystencils 2.0 development version
pystencils-2.0dev:
stage: "Prerelease-Tests"
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:ubuntu24.04-cuda12.6
allow_failure: true
needs: []
script: script:
- pip3 install git+https://gitlab-ci-token:${CI_JOB_TOKEN}@i10git.cs.fau.de/pycodegen/pystencils.git@master#egg=pystencils - mkdir -p ~/.config/matplotlib
- python3 setup.py quicktest - echo "backend:template" > ~/.config/matplotlib/matplotlibrc
- nox -s "testsuite_pystencils2(cupy12)"
tags: tags:
- docker - docker
- AVX
- cuda
- cudaComputeCapability6.1
artifacts:
when: always
paths:
- test-report
reports:
junit: report.xml
minimal-conda: minimal-sympy-master:
stage: test stage: "Prerelease-Tests"
except: needs: []
variables: image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:alpine
- $ENABLE_NIGHTLY_BUILDS
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/minimal_conda
script: script:
- pip install git+https://gitlab-ci-token:${CI_JOB_TOKEN}@i10git.cs.fau.de/pycodegen/pystencils.git@master#egg=pystencils - nox -s quicktest -P 3.13 -- --sympy-master
- python setup.py quicktest allow_failure: true
tags: tags:
- docker - docker
# pycodegen-integration:
# image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
# stage: integration
# when: manual
# allow_failure: true
# script:
# - env
# - pip list
# - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@i10git.cs.fau.de/pycodegen/pycodegen.git
# - cd pycodegen
# - git submodule sync --recursive
# - git submodule update --init --recursive
# - git submodule foreach git fetch origin # compare the latest master version!
# - git submodule foreach git reset --hard origin/master
# - cd lbmpy
# - git remote add test $CI_REPOSITORY_URL
# - git fetch test
# - git reset --hard $CI_COMMIT_SHA
# - cd ..
# - pip install -e pystencils/
# - pip install -e lbmpy/
# - ./install_walberla.sh
# # build all integration tests
# - cd walberla/build/
# - make -j $NUM_CORES MicroBenchmarkGpuLbm LbCodeGenerationExample
# - cd apps/benchmarks/UniformGridGPU
# - make -j $NUM_CORES
# - cd ../UniformGridCPU
# - make -j $NUM_CORES
# -------------------- Linter & Documentation -------------------------------------------------------------------------- # tags:
# - docker
# - cuda
# - cudaComputeCapability6.1
# - AVX
flake8-lint: # -------------------- Scheduled Tasks --------------------------------------------------------------------------
stage: test
except:
variables: nightly-sympy:
- $ENABLE_NIGHTLY_BUILDS stage: nightly
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/latest_python
before_script:
- pip install -e .
- pip install git+https://gitlab-ci-token:${CI_JOB_TOKEN}@i10git.cs.fau.de/pycodegen/pystencils.git@master#egg=pystencils
- pip install --upgrade --pre sympy
script: script:
- flake8 lbmpy - env
- pip list
- export NUM_CORES=$(nproc --all)
- mkdir -p ~/.config/matplotlib
- echo "backend:template" > ~/.config/matplotlib/matplotlibrc
- mkdir public
- pytest -v -n $NUM_CORES -m "not longrun" --junitxml=report.xml
tags: tags:
- docker - docker
- AVX
- cuda - cuda
- cudaComputeCapability6.1
artifacts:
when: always
reports:
junit: report.xml
# -------------------- Documentation and deploy ------------------------------------------------------------------------
build-documentation: build-documentation:
stage: test stage: docs
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full needs: []
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/documentation
before_script:
- pip install -e .
script: script:
- export PYTHONPATH=`pwd` - export PYTHONPATH=`pwd`
- pip install git+https://gitlab-ci-token:${CI_JOB_TOKEN}@i10git.cs.fau.de/pycodegen/pystencils.git@master#egg=pystencils - pip install git+https://gitlab-ci-token:${CI_JOB_TOKEN}@i10git.cs.fau.de/pycodegen/pystencils.git@master#egg=pystencils
- mkdir html_doc - mkdir html_doc
- sphinx-build -W -b html doc html_doc - sphinx-build -W -b html doc html_doc
tags: tags:
- docker - docker
- cuda - cuda
- cudaComputeCapability6.1
artifacts: artifacts:
paths: paths:
- html_doc - html_doc
...@@ -125,7 +216,10 @@ build-documentation: ...@@ -125,7 +216,10 @@ build-documentation:
pages: pages:
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
rules:
- if: '$CI_PIPELINE_SOURCE != "schedule" && $CI_PROJECT_PATH == "pycodegen/lbmpy" && $CI_COMMIT_BRANCH == "master"'
stage: deploy stage: deploy
needs: ["testsuite-cuda-py3.10", "build-documentation"]
script: script:
- ls -l - ls -l
- mv coverage_report html_doc - mv coverage_report html_doc
...@@ -135,5 +229,3 @@ pages: ...@@ -135,5 +229,3 @@ pages:
- public - public
tags: tags:
- docker - docker
only:
- master@pycodegen/lbmpy
Contributors:
-------------
- Martin Bauer <martin.bauer@fau.de>
- Markus Holzer <markus.holzer@fau.de>
- Michael Kuron <mkuron@icp.uni-stuttgart.de>
- Stephan Seitz <stephan.seitz@fau.de>
- Frederik Hennig <frederik.hennig@fau.de>
- Helen Schottenhamml <helen.schottenhamml@fau.de>
- Rudolf Weeber <weeber@icp.uni-stuttgart.de>
- Christian Godenschwager <christian.godenschwager@fau.de>
- Jan Hönig <jan.hoenig@fau.de>
- Philipp Suffa <philipp.suffa@fau.de>
# Change Log
## Unreleased
### Removed
* Removing OpenCL support because it is not supported by pystencils anymore
# Contributing
lbmpy is built on the open-source python framework [pystencils](https://pypi.org/project/pystencils/). Please consider the [contribution guideline](https://i10git.cs.fau.de/pycodegen/pystencils/-/blob/master/CONTRIBUTING.md) of pystencils for contributing to lbmpy.
\ No newline at end of file
include README.md include AUTHORS.txt
include COPYING.txt include CONTRIBUTING.md
include CHANGELOG.md
lbmpy lbmpy
===== =====
[![Docs](https://img.shields.io/badge/read-the_docs-brightgreen.svg)](http://pycodegen.pages.walberla.net/lbmpy) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/mabau/lbmpy/master?filepath=doc%2Fnotebooks)
[![Docs](https://img.shields.io/badge/read-the_docs-brightgreen.svg)](http://pycodegen.pages.i10git.cs.fau.de/lbmpy)
[![pipeline status](https://i10git.cs.fau.de/pycodegen/lbmpy/badges/master/pipeline.svg)](https://i10git.cs.fau.de/pycodegen/lbmpy/commits/master) [![pipeline status](https://i10git.cs.fau.de/pycodegen/lbmpy/badges/master/pipeline.svg)](https://i10git.cs.fau.de/pycodegen/lbmpy/commits/master)
[![coverage report](https://i10git.cs.fau.de/pycodegen/lbmpy/badges/master/coverage.svg)](http://pycodegen.pages.walberla.net/lbmpy/coverage_report) [![coverage report](https://i10git.cs.fau.de/pycodegen/lbmpy/badges/master/coverage.svg)](http://pycodegen.pages.i10git.cs.fau.de/lbmpy/coverage_report)
Run fast fluid simulations based on the lattice Boltzmann method in Python. Run fast fluid simulations based on the lattice Boltzmann method in Python on CPUs and GPUs.
lbmpy creates highly optimized LB compute kernels in C or CUDA, for a wide variety of different collision operators, including MRT,
entropic, and cumulant schemes.
![alt text](doc/img/logo.png) All collision operators can be easily adapted, for example, to integrate turbulence models, custom force terms, or multi-phase models.
It even comes with an integrated Chapman Enskog analysis based on sympy!
Common test scenarios can be set up quickly:
```python
from pystencils import Target
from lbmpy.session import *
ch = create_channel(domain_size=(300, 100, 100), force=1e-7, method=Method.TRT,
equilibrium_order=2, compressible=True,
relaxation_rates=[1.97, 1.6], optimization={'target': Target.GPU})
```
To find out more, check out the interactive [tutorial notebooks online with binder](https://mybinder.org/v2/gh/mabau/lbmpy/master?filepath=doc%2Fnotebooks).
Installation Installation
------------ ------------
For local installation use pip:
```bash ```bash
export PIP_EXTRA_INDEX_URL=https://www.walberla.net/pip
pip install lbmpy[interactive] pip install lbmpy[interactive]
``` ```
...@@ -23,7 +40,8 @@ pip install lbmpy[interactive] ...@@ -23,7 +40,8 @@ pip install lbmpy[interactive]
Without `[interactive]` you get a minimal version with very little dependencies. Without `[interactive]` you get a minimal version with very little dependencies.
All options: All options:
- `gpu`: use this if nVidia GPU is available and CUDA is installed - `gpu`: use this if a NVIDIA GPU is available and CUDA is installed
- `opencl`: use this to enable the target `opencl` (execution using OpenCL)
- `alltrafos`: pulls in additional dependencies for loop simplification e.g. libisl - `alltrafos`: pulls in additional dependencies for loop simplification e.g. libisl
- `interactive`: installs dependencies to work in Jupyter including image I/O, plotting etc. - `interactive`: installs dependencies to work in Jupyter including image I/O, plotting etc.
...@@ -36,5 +54,30 @@ pip install lbmpy[interactive,gpu,doc] ...@@ -36,5 +54,30 @@ pip install lbmpy[interactive,gpu,doc]
Documentation Documentation
------------- -------------
Read the docs [here](http://pycodegen.pages.walberla.net/lbmpy) and Read the docs [here](http://pycodegen.pages.i10git.cs.fau.de/lbmpy) and
check out the Jupyter notebooks in `doc/notebooks`. check out the Jupyter notebooks in `doc/notebooks`.
Contributing
-------
To see how to open issues, submit bug reports, create feature requests or submit your additions to lbmpy please refer to
[contribution documentation](https://i10git.cs.fau.de/pycodegen/pystencils/-/blob/master/CONTRIBUTING.md) of pystencils since lbmpy is heavily build on pystencils.
Many thanks go to the [contributors](https://i10git.cs.fau.de/pycodegen/lbmpy/-/blob/master/AUTHORS.txt) of lbmpy.
### Please cite us
If you use lbmpy in a publication, please cite the following articles:
Overview:
- F. Hennig et al, Advanced Automatic Code Generation for Multiple Relaxation-Time Lattice Boltzmann Methods. SIAM Journal on Scientific Computing, 2023. https://doi.org/10.1137/22M1531348 ([Preprint](https://arxiv.org/abs/2211.02435))
- M. Bauer et al, lbmpy: Automatic code generation for efficient parallel lattice Boltzmann methods. Journal of Computational Science, 2021. https://doi.org/10.1016/j.jocs.2020.101269 ([Preprint](https://arxiv.org/abs/2001.11806))
Multiphase:
- M. Holzer et al, Highly efficient lattice Boltzmann multiphase simulations of immiscible fluids at high-density ratios on CPUs and GPUs through code generation. The International Journal of High Performance Computing Applications, 2021. https://doi.org/10.1177/10943420211016525
### Further Reading
- F. Hennig et al, Automatic Code Generation for the Cumulant Lattice Boltzmann Method. ICMMES, 2021. [Poster Link](https://www.researchgate.net/publication/353224406_Automatic_Code_Generation_for_the_Cumulant_Lattice_Boltzmann_Method)
build-essential
graphviz
ffmpeg
# ----------------------------------------------------------------------------------------------------------------------
# Environment with all dependencies to use pystencils
#
#
# Download conda at https://conda.io/miniconda.html and create this environment by running:
# conda env create -f conda_environment_user.yml
# . activate pystencils
#
# If you have CUDA or ROCm installed and want to use your GPU, uncomment the last line to install cupy
#
# ----------------------------------------------------------------------------------------------------------------------
name: pystencils
dependencies:
# Basic dependencies:
- python >= 3.6
- numpy
- sympy >= 1.1
- appdirs # to find default cache directory on each platform
- joblib # caching on hard-disk, this is optional, but if not installed lbmpy is really slow
- cython # speed up boundary list computation (optional)
- matplotlib
- imageio
- pandas
- scipy
- pip
- pip:
- islpy # used to optimize staggered kernels
- py-cpuinfo # get cpu info like cache sizes, supported vector instruction sets, ...
- graphviz # can show abstract syntax trees as formatted graphs
- ipy_table # HTML tables for jupyter notebooks
- pyevtk # VTK output for serial simulations
- blitzdb # file-based No-SQL database to store simulation results
- pystencils
#- cupy # add this if you have CUDA or ROCm installed
#!/bin/bash
python3 setup.py develop
export MPMATH_NOGMPY=1
exec "$@"
\ No newline at end of file
...@@ -3,23 +3,40 @@ import pytest ...@@ -3,23 +3,40 @@ import pytest
import tempfile import tempfile
import runpy import runpy
import sys import sys
import warnings
import platform
import pathlib
import nbformat
import nbconvert
import sympy
from lbmpy._compat import IS_PYSTENCILS_2
# Trigger config file reading / creation once - to avoid race conditions when multiple instances are creating it # Trigger config file reading / creation once - to avoid race conditions when multiple instances are creating it
# at the same time # at the same time
from pystencils.cpu import cpujit if not IS_PYSTENCILS_2:
from pystencils.cpu import cpujit
# trigger cython imports - there seems to be a problem when multiple processes try to compile the same cython file # trigger cython imports - there seems to be a problem when multiple processes try to compile the same cython file
# at the same time # at the same time
try: try:
import pyximport import pyximport
pyximport.install(language_level=3) pyximport.install(language_level=3)
from lbmpy.phasefield.simplex_projection import simplex_projection_2d # NOQA
except ImportError: except ImportError:
pass pass
from lbmpy.phasefield.simplex_projection import simplex_projection_2d # NOQA
SCRIPT_FOLDER = os.path.dirname(os.path.realpath(__file__)) SCRIPT_FOLDER = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.abspath('lbmpy')) sys.path.insert(0, os.path.abspath('lbmpy'))
# the Ubuntu pipeline uses an older version of pytest which uses deprecated functionality.
# This leads to many warinings in the test and coverage pipeline.
pytest_numeric_version = [int(x, 10) for x in pytest.__version__.split('.')]
pytest_numeric_version.reverse()
pytest_version = sum(x * (100 ** i) for i, x in enumerate(pytest_numeric_version))
def add_path_to_ignore(path): def add_path_to_ignore(path):
if not os.path.exists(path): if not os.path.exists(path):
...@@ -30,21 +47,42 @@ def add_path_to_ignore(path): ...@@ -30,21 +47,42 @@ def add_path_to_ignore(path):
collect_ignore = [os.path.join(SCRIPT_FOLDER, "doc", "conf.py"), collect_ignore = [os.path.join(SCRIPT_FOLDER, "doc", "conf.py"),
os.path.join(SCRIPT_FOLDER, "doc", "img", "mb_discretization", "maxwell_boltzmann_stencil_plot.py")] os.path.join(SCRIPT_FOLDER, "doc", "img", "mb_discretization", "maxwell_boltzmann_stencil_plot.py")]
add_path_to_ignore('pystencils_tests/benchmark')
add_path_to_ignore('_local_tmp') add_path_to_ignore('_local_tmp')
if IS_PYSTENCILS_2:
# TODO: Fix these step-by-step
collect_ignore += [
os.path.join(SCRIPT_FOLDER, "doc", "notebooks", "10_tutorial_conservative_allen_cahn_two_phase.ipynb"),
os.path.join(SCRIPT_FOLDER, "tests", "test_compiled_in_boundaries.ipynb")
]
try: try:
import pycuda import cupy
except ImportError: except ImportError:
collect_ignore += [os.path.join(SCRIPT_FOLDER, "lbmpy_tests/test_cpu_gpu_equivalence.py")] collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_cpu_gpu_equivalence.py")]
try: try:
import waLBerla import waLBerla
except ImportError: except ImportError:
collect_ignore += [os.path.join(SCRIPT_FOLDER, "lbmpy_tests/test_serial_scenarios.py")] collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_datahandling_parallel.py")]
collect_ignore += [os.path.join(SCRIPT_FOLDER, "lbmpy_tests/test_datahandling_parallel.py")]
try:
import blitzdb
except ImportError:
collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/benchmark"),
os.path.join(SCRIPT_FOLDER,
"tests/full_scenarios/kida_vortex_flow/scenario_kida_vortex_flow.py"),
os.path.join(SCRIPT_FOLDER, "tests/full_scenarios/shear_wave/scenario_shear_wave.py"),
os.path.join(SCRIPT_FOLDER, "tests/test_json_serializer.py"),
os.path.join(SCRIPT_FOLDER, "src/lbmpy/db.py")]
if platform.system().lower() == 'windows':
collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_quicktests.py")]
sver = sympy.__version__.split(".")
if int(sver[0]) == 1 and int(sver[1]) < 2:
add_path_to_ignore('tests/phasefield')
collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_n_phase_boyer_noncoupled.ipynb")]
collect_ignore += [os.path.join(SCRIPT_FOLDER, 'setup.py')] collect_ignore += [os.path.join(SCRIPT_FOLDER, 'setup.py')]
...@@ -54,10 +92,6 @@ for root, sub_dirs, files in os.walk('.'): ...@@ -54,10 +92,6 @@ for root, sub_dirs, files in os.walk('.'):
collect_ignore.append(f) collect_ignore.append(f)
import nbformat
from nbconvert import PythonExporter
class IPythonMockup: class IPythonMockup:
def run_line_magic(self, *args, **kwargs): def run_line_magic(self, *args, **kwargs):
pass pass
...@@ -84,35 +118,60 @@ class IPyNbTest(pytest.Item): ...@@ -84,35 +118,60 @@ class IPyNbTest(pytest.Item):
# disable matplotlib output # disable matplotlib output
exec("import matplotlib.pyplot as p; " exec("import matplotlib.pyplot as p; "
"p.close('all'); "
"p.switch_backend('Template')", global_dict) "p.switch_backend('Template')", global_dict)
# in notebooks there is an implicit plt.show() - if this is not called a warning is shown when the next # in notebooks there is an implicit plt.show() - if this is not called a warning is shown when the next
# plot is created. This warning is suppressed here # plot is created. This warning is suppressed here
# Also animations cannot be shown, which also leads to a warning.
exec("import warnings;" exec("import warnings;"
"warnings.filterwarnings('ignore', 'Adding an axes using the same arguments as a previous.*')", "warnings.filterwarnings('ignore', 'Adding an axes using the same arguments as a previous.*');"
"warnings.filterwarnings('ignore', 'Animation was deleted without rendering anything.*');",
global_dict) global_dict)
with tempfile.NamedTemporaryFile() as f: with tempfile.NamedTemporaryFile() as f:
f.write(self.code.encode()) f.write(self.code.encode())
f.flush() f.flush()
runpy.run_path(f.name, init_globals=global_dict, run_name=self.name) runpy.run_path(f.name, init_globals=global_dict, run_name=self.name)
# Close any open figures
exec("import matplotlib.pyplot as p; "
"p.close('all')", global_dict)
class IPyNbFile(pytest.File): class IPyNbFile(pytest.File):
def collect(self): def collect(self):
exporter = PythonExporter() exporter = nbconvert.PythonExporter()
exporter.exclude_markdown = True exporter.exclude_markdown = True
exporter.exclude_input_prompt = True exporter.exclude_input_prompt = True
notebook_contents = self.fspath.open() notebook_contents = self.fspath.open(encoding='utf-8')
notebook = nbformat.read(notebook_contents, 4)
code, _ = exporter.from_notebook_node(notebook) with warnings.catch_warnings():
yield IPyNbTest(self.name, self, code) warnings.filterwarnings("ignore", "IPython.core.inputsplitter is deprecated")
notebook = nbformat.read(notebook_contents, 4)
code, _ = exporter.from_notebook_node(notebook)
if pytest_version >= 50403:
yield IPyNbTest.from_parent(name=self.name, parent=self, code=code)
else:
yield IPyNbTest(self.name, self, code)
def teardown(self): def teardown(self):
pass pass
def pytest_collect_file(path, parent): if pytest_version >= 70000:
glob_exprs = ["*demo*.ipynb", "*tutorial*.ipynb", "test_*.ipynb"] # Since pytest 7.0, usage of `py.path.local` is deprecated and `pathlib.Path` should be used instead
if any(path.fnmatch(g) for g in glob_exprs): import pathlib
return IPyNbFile(path, parent)
def pytest_collect_file(file_path: pathlib.Path, parent):
glob_exprs = ["*demo*.ipynb", "*tutorial*.ipynb", "test_*.ipynb"]
if any(file_path.match(g) for g in glob_exprs):
return IPyNbFile.from_parent(path=file_path, parent=parent)
else:
def pytest_collect_file(path, parent):
glob_exprs = ["*demo*.ipynb", "*tutorial*.ipynb", "test_*.ipynb"]
if any(path.fnmatch(g) for g in glob_exprs):
if pytest_version >= 50403:
return IPyNbFile.from_parent(fspath=path, parent=parent)
else:
return IPyNbFile(path, parent)
...@@ -5,9 +5,10 @@ import datetime ...@@ -5,9 +5,10 @@ import datetime
import sphinx_rtd_theme import sphinx_rtd_theme
import os import os
import sys import sys
import re
import lbmpy
sys.path.insert(0, os.path.abspath('.')) sys.path.insert(0, os.path.abspath('.'))
from version_from_git import version_number_from_git
extensions = [ extensions = [
'sphinx.ext.autodoc', 'sphinx.ext.autodoc',
...@@ -25,11 +26,14 @@ templates_path = ['_templates'] ...@@ -25,11 +26,14 @@ templates_path = ['_templates']
source_suffix = '.rst' source_suffix = '.rst'
master_doc = 'index' master_doc = 'index'
copyright = '{}, Martin Bauer'.format(datetime.datetime.now().year) copyright = f'{datetime.datetime.now().year}, Martin Bauer, Markus Holzer, Frederik Hennig'
author = 'Martin Bauer' author = 'Martin Bauer, Markus Holzer, Frederik Hennig'
version = version_number_from_git() # The short X.Y version (including .devXXXX, rcX, b1 suffixes if present)
release = version_number_from_git() version = re.sub(r'(\d+\.\d+)\.\d+(.*)', r'\1\2', lbmpy.__version__)
language = None version = re.sub(r'(\.dev\d+).*?$', r'\1', version)
# The full version, including alpha/beta/rc tags.
release = lbmpy.__version__
language = 'en'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints'] exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints']
default_role = 'any' default_role = 'any'
pygments_style = 'sphinx' pygments_style = 'sphinx'
...@@ -54,6 +58,7 @@ intersphinx_mapping = {'python': ('https://docs.python.org/3.6', None), ...@@ -54,6 +58,7 @@ intersphinx_mapping = {'python': ('https://docs.python.org/3.6', None),
} }
autodoc_member_order = 'bysource' autodoc_member_order = 'bysource'
bibtex_bibfiles = ['sphinx/lbmpy.bib']
project = 'lbmpy' project = 'lbmpy'
html_logo = "img/logo.png" html_logo = 'img/logo.png'
File added
This diff is collapsed.
File added
File added
doc/img/feature_optimization_overview.png

135 KiB

This diff is collapsed.