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

Target

Select target project
No results found
Show changes
Commits on Source (249)
Showing
with 213 additions and 8097 deletions
...@@ -3,4 +3,5 @@ max-line-length=120 ...@@ -3,4 +3,5 @@ max-line-length=120
exclude=src/pystencils/jupyter.py, exclude=src/pystencils/jupyter.py,
src/pystencils/plot.py src/pystencils/plot.py
src/pystencils/session.py src/pystencils/session.py
ignore = W293 W503 W291 C901 E741 src/pystencils/old
ignore = W293 W503 W291 C901 E741 E704
pystencils/_version.py export-subst src/pystencils/_version.py export-subst
__pycache__ __pycache__
.ipynb_checkpoints .ipynb_checkpoints
.coverage* .coverage*
coverage.xml
*.pyc *.pyc
*.vti *.vti
/build /build
......
stages: stages:
- pretest - "Code Quality"
- test - "Unit Tests"
- legacy_test
- docs
- deploy - deploy
# -------------------------- Tests ------------------------------------------------------------------------------------ # -------------------------- Legacy Tests ------------------------------------------------------------------------------------
# Normal test - runs on every commit all but "long run" tests
tests-and-coverage:
stage: pretest
except:
variables:
- $ENABLE_NIGHTLY_BUILDS
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
before_script:
- pip install -e .
script:
- 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 --cov-report html --cov-report xml --cov-report term --cov=. -m "not longrun" --html test-report/index.html --junitxml=report.xml
- python -m coverage xml
tags:
- docker
- cuda11
- AVX
coverage: /Total coverage:\s\d+.\d+\%/
artifacts:
when: always
paths:
- coverage_report
- test-report
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
junit: report.xml
# Normal test with longruns # Normal test with longruns
tests-and-coverage-with-longrun: tests-and-coverage-with-longrun:
stage: test stage: legacy_test
when: manual when: manual
allow_failure: true allow_failure: true
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
...@@ -64,7 +32,9 @@ tests-and-coverage-with-longrun: ...@@ -64,7 +32,9 @@ tests-and-coverage-with-longrun:
# pipeline with latest python version # pipeline with latest python version
latest-python: latest-python:
stage: test stage: legacy_test
allow_failure: true
when: manual
except: except:
variables: variables:
- $ENABLE_NIGHTLY_BUILDS - $ENABLE_NIGHTLY_BUILDS
...@@ -107,7 +77,9 @@ latest-python: ...@@ -107,7 +77,9 @@ latest-python:
# - py.test -v -m "not (notebook or longrun)" # - py.test -v -m "not (notebook or longrun)"
ubuntu: ubuntu:
stage: test stage: legacy_test
allow_failure: true
when: manual
except: except:
variables: variables:
- $ENABLE_NIGHTLY_BUILDS - $ENABLE_NIGHTLY_BUILDS
...@@ -133,7 +105,9 @@ ubuntu: ...@@ -133,7 +105,9 @@ ubuntu:
junit: report.xml junit: report.xml
.multiarch_template: .multiarch_template:
stage: test stage: legacy_test
allow_failure: true
when: manual
except: except:
variables: variables:
- $ENABLE_NIGHTLY_BUILDS - $ENABLE_NIGHTLY_BUILDS
...@@ -200,7 +174,9 @@ riscv64: ...@@ -200,7 +174,9 @@ riscv64:
- sed -i 's/fopenmp/fopenmp=libgomp -I\/usr\/include\/riscv64-linux-gnu/g' ~/.config/pystencils/config.json - sed -i 's/fopenmp/fopenmp=libgomp -I\/usr\/include\/riscv64-linux-gnu/g' ~/.config/pystencils/config.json
minimal-conda: minimal-conda:
stage: pretest stage: legacy_test
allow_failure: true
when: manual
except: except:
variables: variables:
- $ENABLE_NIGHTLY_BUILDS - $ENABLE_NIGHTLY_BUILDS
...@@ -215,7 +191,9 @@ minimal-conda: ...@@ -215,7 +191,9 @@ minimal-conda:
minimal-sympy-master: minimal-sympy-master:
stage: test stage: legacy_test
allow_failure: true
when: manual
except: except:
variables: variables:
- $ENABLE_NIGHTLY_BUILDS - $ENABLE_NIGHTLY_BUILDS
...@@ -225,7 +203,6 @@ minimal-sympy-master: ...@@ -225,7 +203,6 @@ minimal-sympy-master:
script: script:
- python -m pip install --upgrade git+https://github.com/sympy/sympy.git - python -m pip install --upgrade git+https://github.com/sympy/sympy.git
- python quicktest.py - python quicktest.py
allow_failure: true
tags: tags:
- docker - docker
- cuda - cuda
...@@ -233,7 +210,7 @@ minimal-sympy-master: ...@@ -233,7 +210,7 @@ minimal-sympy-master:
pycodegen-integration: pycodegen-integration:
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
stage: test stage: legacy_test
when: manual when: manual
allow_failure: true allow_failure: true
script: script:
...@@ -275,44 +252,100 @@ pycodegen-integration: ...@@ -275,44 +252,100 @@ pycodegen-integration:
reports: reports:
junit: pycodegen/*/report.xml junit: pycodegen/*/report.xml
# -------------------- Linter & Documentation -------------------------------------------------------------------------- # -------------------- Code Quality ---------------------------------------------------------------------
flake8-lint: .qa-base:
stage: pretest stage: "Code Quality"
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:alpine
needs: []
except: except:
variables: variables:
- $ENABLE_NIGHTLY_BUILDS - $ENABLE_NIGHTLY_BUILDS
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full tags:
- docker
lint:
extends: .qa-base
script:
- nox --session lint
typecheck:
extends: .qa-base
script:
- nox --session typecheck
# -------------------- Unit Tests ---------------------------------------------------------------------
.testsuite-base:
stage: "Unit Tests"
needs: []
coverage: /Total coverage:\s\d+.\d+\%/
artifacts:
when: always
paths:
- coverage_report
- test-report
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
junit: report.xml
"testsuite-gpu-py3.10":
extends: .testsuite-base
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:ubuntu24.04-cuda12.6
script: script:
- flake8 src/pystencils - mkdir -p ~/.config/matplotlib
- echo "backend:template" > ~/.config/matplotlib/matplotlibrc
- mkdir public
- nox --session "testsuite-3.10(cupy12)"
tags:
- docker
- cuda11
- AVX
"testsuite-cpu-py3.13":
extends: .testsuite-base
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:alpine
script:
- nox --session "testsuite-3.13(cpu)"
tags:
- docker
- AVX
"testsuite-experimental-jit-py3.10":
extends: .testsuite-base
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:alpine
script:
- nox -s "testsuite-3.10(cpu)" -- --experimental-cpu-jit
tags: tags:
- docker - docker
- AVX
# -------------------- Documentation ---------------------------------------------------------------------
build-documentation: build-documentation:
stage: test image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:ubuntu24.04-cuda12.6
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/documentation stage: docs
before_script: needs: []
- pip install -e .
script: script:
- mkdir html_doc - nox --session docs -- --fail-on-warnings
- sphinx-build -b html doc html_doc
- sphinx-build -W -b html doc html_doc
tags: tags:
- docker - docker
- cuda11
artifacts: artifacts:
paths: paths:
- html_doc - docs/build/html
pages: pages:
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full image: alpine:latest
stage: deploy stage: deploy
needs: ["testsuite-gpu-py3.10", "build-documentation"]
script: script:
- ls -l - mv docs/build/html public
- mv coverage_report html_doc - mv coverage_report public/coverage_report
- mv html_doc public # folder has to be named "public" for gitlab to publish it
artifacts: artifacts:
paths: paths:
- public - public
......
# pystencils 2.0 Development Branch
You are currently viewing the development branch `v2.0-dev` for *pystencils 2.0*.
This version marks a complete redesign of pystencil's internal structure.
The type system, code generators, and just-in-time-compilers are being completely rebuilt here.
## Early Adoption
The development version of pystencils is now ready for early adoption by users.
Install the current pre-release version either directly through pip:
```
pip install "git+https://i10git.cs.fau.de/pycodegen/pystencils.git@v2.0-dev"
```
Or clone the repository locally and do an editable install:
```
git clone -b v2.0-dev https://i10git.cs.fau.de/pycodegen/pystencils.git
pip install -e pystencils
```
## Documentation
- Documentation for the current development version can be found [here](https://pycodegen.pages.i10git.cs.fau.de/docs/pystencils/2.0dev/)
- Progress toward the 2.0 release is being tracked [here](https://i10git.cs.fau.de/pycodegen/pystencils/-/milestones/3#tab-issues)
## Contributing
Please refer to [the contribution guide](https://pycodegen.pages.i10git.cs.fau.de/docs/pystencils/2.0dev/contributing/index.html).
---
pystencils pystencils
========== ==========
......
...@@ -3,91 +3,113 @@ import runpy ...@@ -3,91 +3,113 @@ import runpy
import sys import sys
import tempfile import tempfile
import warnings import warnings
import pathlib
import nbformat import nbformat
import pytest import pytest
from nbconvert import PythonExporter
from pystencils.boundaries.createindexlist import * # NOQA
# 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 # TODO: replace with new backend
# 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 pystencils.boundaries.createindexlistcython import * # NOQA
except ImportError: except ImportError:
pass pass
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('pystencils')) sys.path.insert(0, os.path.abspath("pystencils"))
# the Ubuntu pipeline uses an older version of pytest which uses deprecated functionality. # the Ubuntu pipeline uses an older version of pytest which uses deprecated functionality.
# This leads to many warinings in the test and coverage pipeline. # 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 = [int(x, 10) for x in pytest.__version__.split(".")]
pytest_numeric_version.reverse() pytest_numeric_version.reverse()
pytest_version = sum(x * (100 ** i) for i, x in enumerate(pytest_numeric_version)) 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):
return return
global collect_ignore global collect_ignore
collect_ignore += [os.path.join(SCRIPT_FOLDER, path, f) for f in os.listdir(os.path.join(SCRIPT_FOLDER, path))] collect_ignore += [
os.path.join(SCRIPT_FOLDER, path, f)
for f in os.listdir(os.path.join(SCRIPT_FOLDER, path))
]
collect_ignore = [os.path.join(SCRIPT_FOLDER, "doc", "conf.py"), collect_ignore = [
os.path.join(SCRIPT_FOLDER, "src", "pystencils", "opencl", "opencl.autoinit")] os.path.join(SCRIPT_FOLDER, "doc", "conf.py"),
add_path_to_ignore('tests/benchmark') os.path.join(SCRIPT_FOLDER, "src", "pystencils", "opencl", "opencl.autoinit"),
add_path_to_ignore('_local_tmp') ]
add_path_to_ignore("tests/benchmark")
add_path_to_ignore("_local_tmp")
try: try:
import cupy import cupy
except ImportError: except ImportError:
collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_gpu.py")] collect_ignore += [
add_path_to_ignore('src/pystencils/gpu') os.path.join(SCRIPT_FOLDER, "tests/kernelcreation/test_gpu.py"),
os.path.join(SCRIPT_FOLDER, "src/pystencils/backend/jit/gpu_cupy.py"),
]
add_path_to_ignore("src/pystencils/gpu")
try: try:
import waLBerla import waLBerla
except ImportError: except ImportError:
collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_aligned_array.py"), collect_ignore += [
os.path.join(SCRIPT_FOLDER, "tests/test_datahandling_parallel.py"), os.path.join(
os.path.join(SCRIPT_FOLDER, "doc/notebooks/03_tutorial_datahandling.ipynb"), SCRIPT_FOLDER, "docs/source/tutorials/03_tutorial_datahandling.ipynb"
os.path.join(SCRIPT_FOLDER, "src/pystencils/datahandling/parallel_datahandling.py"), ),
os.path.join(SCRIPT_FOLDER, "tests/test_small_block_benchmark.ipynb")] os.path.join(
SCRIPT_FOLDER, "src/pystencils/datahandling/parallel_datahandling.py"
),
os.path.join(SCRIPT_FOLDER, "tests/runtime/test_datahandling_parallel.py"),
os.path.join(SCRIPT_FOLDER, "tests/runtime/test_small_block_benchmark.ipynb"),
]
try: try:
import blitzdb import blitzdb
except ImportError: except ImportError:
add_path_to_ignore('src/pystencils/runhelper') add_path_to_ignore("src/pystencils/runhelper")
collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_parameterstudy.py")] collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_parameterstudy.py")]
collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_json_serializer.py")] collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_json_serializer.py")]
try: try:
import islpy import islpy
except ImportError: except ImportError:
collect_ignore += [os.path.join(SCRIPT_FOLDER, "src/pystencils/integer_set_analysis.py")] collect_ignore += [
os.path.join(SCRIPT_FOLDER, "src/pystencils/integer_set_analysis.py")
]
try: try:
import graphviz import graphviz
except ImportError: except ImportError:
collect_ignore += [os.path.join(SCRIPT_FOLDER, "src/pystencils/backends/dot.py")] collect_ignore += [os.path.join(SCRIPT_FOLDER, "src/pystencils/backends/dot.py")]
collect_ignore += [os.path.join(SCRIPT_FOLDER, "doc/notebooks/01_tutorial_getting_started.ipynb")] collect_ignore += [
os.path.join(SCRIPT_FOLDER, "doc/notebooks/01_tutorial_getting_started.ipynb")
]
try: try:
import pyevtk import pyevtk
except ImportError: except ImportError:
collect_ignore += [os.path.join(SCRIPT_FOLDER, "src/pystencils/datahandling/vtk.py")] collect_ignore += [
os.path.join(SCRIPT_FOLDER, "src/pystencils/datahandling/vtk.py")
]
collect_ignore += [os.path.join(SCRIPT_FOLDER, 'setup.py')] collect_ignore += [os.path.join(SCRIPT_FOLDER, "setup.py")]
for root, sub_dirs, files in os.walk('.'): for root, sub_dirs, files in os.walk("."):
for f in files: for f in files:
if f.endswith(".ipynb") and not any(f.startswith(k) for k in ['demo', 'tutorial', 'test', 'doc']): if f.endswith(".ipynb") and not any(
f.startswith(k) for k in ["demo", "tutorial", "test", "doc"]
):
collect_ignore.append(f) collect_ignore.append(f)
...@@ -109,38 +131,50 @@ class IPyNbTest(pytest.Item): ...@@ -109,38 +131,50 @@ class IPyNbTest(pytest.Item):
def __init__(self, name, parent, code): def __init__(self, name, parent, code):
super(IPyNbTest, self).__init__(name, parent) super(IPyNbTest, self).__init__(name, parent)
self.code = code self.code = code
self.add_marker('notebook') self.add_marker("notebook")
@pytest.mark.filterwarnings("ignore:IPython.core.inputsplitter is deprecated")
def runtest(self): def runtest(self):
global_dict = {'get_ipython': lambda: IPythonMockup(), global_dict = {"get_ipython": lambda: IPythonMockup(), "is_test_run": True}
'is_test_run': True}
# disable matplotlib output # disable matplotlib output
exec("import matplotlib.pyplot as p; " exec(
"p.switch_backend('Template')", global_dict) "import matplotlib.pyplot as p; "
"p.close('all'); "
"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
exec("import warnings;" exec(
"warnings.filterwarnings('ignore', 'Adding an axes using the same arguments as a previous.*')", "import warnings;"
global_dict) "warnings.filterwarnings('ignore', 'Adding an axes using the same arguments as a previous.*');"
"warnings.filterwarnings('ignore', 'Animation was deleted without rendering anything.*');",
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):
from nbconvert import PythonExporter
exporter = PythonExporter() exporter = PythonExporter()
exporter.exclude_markdown = True exporter.exclude_markdown = True
exporter.exclude_input_prompt = True exporter.exclude_input_prompt = True
notebook_contents = self.fspath.open(encoding='utf-8') notebook_contents = self.path.open(encoding="utf-8")
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.filterwarnings("ignore", "IPython.core.inputsplitter is deprecated") warnings.filterwarnings(
"ignore", "IPython.core.inputsplitter is deprecated"
)
notebook = nbformat.read(notebook_contents, 4) notebook = nbformat.read(notebook_contents, 4)
code, _ = exporter.from_notebook_node(notebook) code, _ = exporter.from_notebook_node(notebook)
if pytest_version >= 50403: if pytest_version >= 50403:
...@@ -152,10 +186,12 @@ class IPyNbFile(pytest.File): ...@@ -152,10 +186,12 @@ class IPyNbFile(pytest.File):
pass pass
def pytest_collect_file(path, parent): def pytest_collect_file(file_path: pathlib.Path, parent):
glob_exprs = ["*demo*.ipynb", "*tutorial*.ipynb", "test_*.ipynb"] glob_exprs = ["*demo*.ipynb", "*tutorial*.ipynb", "test_*.ipynb"]
if any(path.fnmatch(g) for g in glob_exprs): if any(file_path.match(g) for g in glob_exprs):
if pytest_version >= 50403: return IPyNbFile.from_parent(path=file_path, parent=parent)
return IPyNbFile.from_parent(fspath=path, parent=parent)
else:
return IPyNbFile(path, parent) # Fixtures
from tests.fixtures import *
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import datetime
import sphinx_rtd_theme
import os
import re
import sys
sys.path.insert(0, os.path.abspath('.'))
import pystencils
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
'nbsphinx',
'sphinxcontrib.bibtex',
'sphinx_autodoc_typehints',
]
add_module_names = False
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
copyright = f'{datetime.datetime.now().year}, Martin Bauer, Markus Holzer, Frederik Hennig'
author = 'Martin Bauer, Markus Holzer, Frederik Hennig'
# The short X.Y version (including .devXXXX, rcX, b1 suffixes if present)
version = re.sub(r'(\d+\.\d+)\.\d+(.*)', r'\1\2', pystencils.__version__)
version = re.sub(r'(\.dev\d+).*?$', r'\1', version)
# The full version, including alpha/beta/rc tags.
release = pystencils.__version__
language = 'en'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints']
default_role = 'any'
pygments_style = 'sphinx'
todo_include_todos = False
# Options for HTML output
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
html_theme = 'sphinx_rtd_theme'
htmlhelp_basename = 'pystencilsdoc'
html_sidebars = {'**': ['globaltoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html']}
# NbSphinx configuration
nbsphinx_execute = 'never'
nbsphinx_codecell_lexer = 'python3'
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'python': ('https://docs.python.org/3.8', None),
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
'matplotlib': ('https://matplotlib.org/', None),
'sympy': ('https://docs.sympy.org/latest/', None),
}
autodoc_member_order = 'bysource'
bibtex_bibfiles = ['sphinx/pystencils.bib']
project = 'pystencils'
html_logo = 'img/logo.png'
pystencils
==========
Welcome to the documentation of the pystencils code generation tool for stencil codes.
pystencils can help you to generate blazingly fast code for image processing, numerical simulations or any other task involving numpy arrays.
.. toctree::
:maxdepth: 2
sphinx/tutorials.rst
sphinx/api.rst
.. image:: /img/pystencils_arch_block_diagram.svg
:height: 450px
:align: center
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
API Reference
=============
.. toctree::
:maxdepth: 3
kernel_compile_and_call.rst
enums.rst
simplifications.rst
datahandling.rst
configuration.rst
field.rst
stencil.rst
finite_differences.rst
plot.rst
ast.rst