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
exclude=src/pystencils/jupyter.py,
src/pystencils/plot.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__
.ipynb_checkpoints
.coverage*
coverage.xml
*.pyc
*.vti
/build
......
stages:
- pretest
- test
- "Code Quality"
- "Unit Tests"
- legacy_test
- docs
- deploy
# -------------------------- 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
# -------------------------- Legacy Tests ------------------------------------------------------------------------------------
# Normal test with longruns
tests-and-coverage-with-longrun:
stage: test
stage: legacy_test
when: manual
allow_failure: true
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
......@@ -64,7 +32,9 @@ tests-and-coverage-with-longrun:
# pipeline with latest python version
latest-python:
stage: test
stage: legacy_test
allow_failure: true
when: manual
except:
variables:
- $ENABLE_NIGHTLY_BUILDS
......@@ -107,7 +77,9 @@ latest-python:
# - py.test -v -m "not (notebook or longrun)"
ubuntu:
stage: test
stage: legacy_test
allow_failure: true
when: manual
except:
variables:
- $ENABLE_NIGHTLY_BUILDS
......@@ -133,7 +105,9 @@ ubuntu:
junit: report.xml
.multiarch_template:
stage: test
stage: legacy_test
allow_failure: true
when: manual
except:
variables:
- $ENABLE_NIGHTLY_BUILDS
......@@ -200,7 +174,9 @@ riscv64:
- sed -i 's/fopenmp/fopenmp=libgomp -I\/usr\/include\/riscv64-linux-gnu/g' ~/.config/pystencils/config.json
minimal-conda:
stage: pretest
stage: legacy_test
allow_failure: true
when: manual
except:
variables:
- $ENABLE_NIGHTLY_BUILDS
......@@ -215,7 +191,9 @@ minimal-conda:
minimal-sympy-master:
stage: test
stage: legacy_test
allow_failure: true
when: manual
except:
variables:
- $ENABLE_NIGHTLY_BUILDS
......@@ -225,7 +203,6 @@ minimal-sympy-master:
script:
- python -m pip install --upgrade git+https://github.com/sympy/sympy.git
- python quicktest.py
allow_failure: true
tags:
- docker
- cuda
......@@ -233,7 +210,7 @@ minimal-sympy-master:
pycodegen-integration:
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
stage: test
stage: legacy_test
when: manual
allow_failure: true
script:
......@@ -275,44 +252,100 @@ pycodegen-integration:
reports:
junit: pycodegen/*/report.xml
# -------------------- Linter & Documentation --------------------------------------------------------------------------
# -------------------- Code Quality ---------------------------------------------------------------------
flake8-lint:
stage: pretest
.qa-base:
stage: "Code Quality"
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:alpine
needs: []
except:
variables:
- $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:
- 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:
- docker
- AVX
# -------------------- Documentation ---------------------------------------------------------------------
build-documentation:
stage: test
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/documentation
before_script:
- pip install -e .
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/nox:ubuntu24.04-cuda12.6
stage: docs
needs: []
script:
- mkdir html_doc
- sphinx-build -b html doc html_doc
- sphinx-build -W -b html doc html_doc
- nox --session docs -- --fail-on-warnings
tags:
- docker
- cuda11
artifacts:
paths:
- html_doc
- docs/build/html
pages:
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
image: alpine:latest
stage: deploy
needs: ["testsuite-gpu-py3.10", "build-documentation"]
script:
- ls -l
- mv coverage_report html_doc
- mv html_doc public # folder has to be named "public" for gitlab to publish it
- mv docs/build/html public
- mv coverage_report public/coverage_report
artifacts:
paths:
- 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
==========
......
......@@ -3,91 +3,113 @@ import runpy
import sys
import tempfile
import warnings
import pathlib
import nbformat
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
# 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
# at the same time
try:
import pyximport
pyximport.install(language_level=3)
from pystencils.boundaries.createindexlistcython import * # NOQA
except ImportError:
pass
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.
# 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_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):
if not os.path.exists(path):
return
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"),
os.path.join(SCRIPT_FOLDER, "src", "pystencils", "opencl", "opencl.autoinit")]
add_path_to_ignore('tests/benchmark')
add_path_to_ignore('_local_tmp')
collect_ignore = [
os.path.join(SCRIPT_FOLDER, "doc", "conf.py"),
os.path.join(SCRIPT_FOLDER, "src", "pystencils", "opencl", "opencl.autoinit"),
]
add_path_to_ignore("tests/benchmark")
add_path_to_ignore("_local_tmp")
try:
import cupy
except ImportError:
collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_gpu.py")]
add_path_to_ignore('src/pystencils/gpu')
collect_ignore += [
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:
import waLBerla
except ImportError:
collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_aligned_array.py"),
os.path.join(SCRIPT_FOLDER, "tests/test_datahandling_parallel.py"),
os.path.join(SCRIPT_FOLDER, "doc/notebooks/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")]
collect_ignore += [
os.path.join(
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/runtime/test_datahandling_parallel.py"),
os.path.join(SCRIPT_FOLDER, "tests/runtime/test_small_block_benchmark.ipynb"),
]
try:
import blitzdb
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_json_serializer.py")]
try:
import islpy
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:
import graphviz
except ImportError:
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:
import pyevtk
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:
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)
......@@ -109,38 +131,50 @@ class IPyNbTest(pytest.Item):
def __init__(self, name, parent, code):
super(IPyNbTest, self).__init__(name, parent)
self.code = code
self.add_marker('notebook')
self.add_marker("notebook")
@pytest.mark.filterwarnings("ignore:IPython.core.inputsplitter is deprecated")
def runtest(self):
global_dict = {'get_ipython': lambda: IPythonMockup(),
'is_test_run': True}
global_dict = {"get_ipython": lambda: IPythonMockup(), "is_test_run": True}
# disable matplotlib output
exec("import matplotlib.pyplot as p; "
"p.switch_backend('Template')", global_dict)
exec(
"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
# plot is created. This warning is suppressed here
exec("import warnings;"
"warnings.filterwarnings('ignore', 'Adding an axes using the same arguments as a previous.*')",
global_dict)
exec(
"import warnings;"
"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:
f.write(self.code.encode())
f.flush()
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):
def collect(self):
from nbconvert import PythonExporter
exporter = PythonExporter()
exporter.exclude_markdown = 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():
warnings.filterwarnings("ignore", "IPython.core.inputsplitter is deprecated")
warnings.filterwarnings(
"ignore", "IPython.core.inputsplitter is deprecated"
)
notebook = nbformat.read(notebook_contents, 4)
code, _ = exporter.from_notebook_node(notebook)
if pytest_version >= 50403:
......@@ -152,10 +186,12 @@ class IPyNbFile(pytest.File):
pass
def pytest_collect_file(path, parent):
def pytest_collect_file(file_path: pathlib.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)
if any(file_path.match(g) for g in glob_exprs):
return IPyNbFile.from_parent(path=file_path, parent=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