Skip to content
Commits on Source (743)
# https://editorconfig.org/
# https://github.com/editorconfig/editorconfig-vim
# https://github.com/editorconfig/editorconfig-emacs
root = true
[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.py]
indent_size = 4
[*.rst]
indent_size = 4
[*.cpp]
indent_size = 2
[*.hpp]
indent_size = 2
# There may be one in doc/
[Makefile]
indent_style = tab
# https://github.com/microsoft/vscode/issues/1679
[*.md]
trim_trailing_whitespace = false
\ No newline at end of file
version: 2
updates:
# Set update schedule for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
# vim: sw=4
name: Gitlab mirror
on:
push:
branches:
- main
jobs:
autopush:
name: Automatic push to gitlab.tiker.net
if: startsWith(github.repository, 'inducer/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
curl -L -O https://tiker.net/ci-support-v0
. ./ci-support-v0
mirror_github_to_gitlab
env:
GITLAB_AUTOPUSH_KEY: ${{ secrets.GITLAB_AUTOPUSH_KEY }}
# vim: sw=4
name: CI
on:
push:
branches:
- main
pull_request:
paths-ignore:
- 'doc/*.rst'
schedule:
- cron: '17 3 * * 0'
concurrency:
group: ${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
ruff:
name: Ruff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: "Main Script"
run: |
pip install ruff
ruff check
typos:
name: Typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@master
validate_cff:
name: Validate CITATION.cff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- run: |
pip install cffconvert
cffconvert -i CITATION.cff --validate
pylint:
name: Pylint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
-
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: "Main Script"
run: |
EXTRA_INSTALL="numpy pymbolic orderedsets"
curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/prepare-and-run-pylint.sh
. ./prepare-and-run-pylint.sh "$(basename $GITHUB_REPOSITORY)"
mypy:
name: Mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
-
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: "Main Script"
run: |
EXTRA_INSTALL="numpy siphash24"
curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/prepare-and-run-mypy.sh
. ./prepare-and-run-mypy.sh python3 mypy
pytest:
name: Pytest on Py${{ matrix.python-version }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.10", "3.12", "3.x", "pypy3.10"]
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
-
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: "Main Script"
run: |
# untested, causes import error with Pytest >= 6.2.0
# AK, 2020-12-13
rm pytools/mpiwrap.py
EXTRA_INSTALL="numpy frozendict immutabledict orderedsets constantdict immutables pyrsistent attrs siphash24"
curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/build-and-test-py-project.sh
. ./build-and-test-py-project.sh
# Also run with optimizations turned on, since opt_frozen_dataclass
# depends on the __debug__ setting.
python -O -m pytest pytools/test/test_dataclasses.py
pytest_nonumpy:
name: Pytest without Numpy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
-
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: "Main Script"
run: |
EXTRA_INSTALL="siphash24"
rm pytools/{convergence,spatial_btree,obj_array,mpiwrap}.py
curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/build-and-test-py-project.sh
. ./build-and-test-py-project.sh
#examples:
# name: Examples Py3
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# -
# uses: actions/setup-python@v5
# with:
# python-version: '3.x'
# - name: "Main Script"
# run: |
# EXTRA_INSTALL="numpy pymbolic"
# curl -L -O https://tiker.net/ci-support-v0
# . ./ci-support-v0
# build_py_project_in_venv
# run_examples
downstream_tests:
strategy:
matrix:
downstream_project: [loopy, pytato]
name: Tests for downstream project ${{ matrix.downstream_project }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Main Script"
env:
DOWNSTREAM_PROJECT: ${{ matrix.downstream_project }}
run: |
curl -L -O https://tiker.net/ci-support-v0
. ./ci-support-v0
test_downstream "$DOWNSTREAM_PROJECT"
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
-
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: "Main Script"
run: |
EXTRA_INSTALL="numpy"
curl -L -O https://tiker.net/ci-support-v0
. ci-support-v0
build_py_project_in_venv
build_docs
# vim: sw=4
...@@ -13,3 +13,9 @@ distribute*egg ...@@ -13,3 +13,9 @@ distribute*egg
distribute*tar.gz distribute*tar.gz
.cache .cache
.mypy_cache
*.dat
.pylintrc.yml
.run-pylint.py
Python 2.6: Pytest:
script: script: |
- py_version=2.6 # untested, causes import error with Pytest >= 6.2.0
- export EXTRA_INSTALL="numpy" # AK, 2020-12-13
- curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh rm pytools/mpiwrap.py
- ". ./build-and-test-py-project.sh"
tags:
- python2.6
except:
- tags
artifacts:
reports:
junit: test/pytest.xml
Python 2.7: export EXTRA_INSTALL="numpy siphash24"
script: curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/build-and-test-py-project.sh
- py_version=2.7 . ./build-and-test-py-project.sh
- export EXTRA_INSTALL="numpy"
- curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh
- ". ./build-and-test-py-project.sh"
tags: tags:
- python2.7 - python3
except: except:
- tags - tags
artifacts: artifacts:
reports: reports:
junit: test/pytest.xml junit: test/pytest.xml
Python 3.6: Pytest without Numpy:
script: script: |
- py_version=3.6 EXTRA_INSTALL="siphash24"
- export EXTRA_INSTALL="numpy" rm pytools/{convergence,spatial_btree,obj_array,mpiwrap}.py
- curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/build-and-test-py-project.sh
- ". ./build-and-test-py-project.sh" . ./build-and-test-py-project.sh
tags: tags:
- python3.6 - python3
except: except:
- tags - tags
artifacts: artifacts:
reports: reports:
junit: test/pytest.xml junit: test/pytest.xml
Python 3.7: # Examples:
# script: |
# EXTRA_INSTALL="numpy pymbolic"
# curl -L -O https://tiker.net/ci-support-v0
# . ./ci-support-v0
# build_py_project_in_venv
# run_examples
# tags:
# - python3
# except:
# - tags
Ruff:
script: script:
- py_version=3.7 - pipx install ruff
- export EXTRA_INSTALL="numpy" - ruff check
- curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh
- ". ./build-and-test-py-project.sh"
tags: tags:
- python3.7 - docker-runner
except: except:
- tags - tags
artifacts:
reports:
junit: test/pytest.xml
Flake8: Mypy:
script: script:
- curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh - curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/prepare-and-run-mypy.sh
- ". ./prepare-and-run-flake8.sh pytools test" - ". ./prepare-and-run-mypy.sh python3 mypy"
tags: tags:
- python3.6 - python3
except: except:
- tags - tags
Pylint: Pylint:
script: script:
- EXTRA_INSTALL="pymbolic matplotlib mpi4py" - EXTRA_INSTALL="numpy pymbolic orderedsets siphash24"
- py_version=3.6 - py_version=3
- curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-pylint.sh - curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/prepare-and-run-pylint.sh
- ". ./prepare-and-run-pylint.sh pytools test/test_*.py" - . ./prepare-and-run-pylint.sh "$CI_PROJECT_NAME"
tags: tags:
- python3.6 - python3
except: except:
- tags - tags
Documentation: Documentation:
script: script:
- EXTRA_INSTALL="numpy" - EXTRA_INSTALL="numpy siphash24"
- curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-docs.sh - curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/build-docs.sh
- ". ./build-docs.sh" - ". ./build-docs.sh"
tags: tags:
- python3.5 - python3
only:
- master Downstream:
parallel:
matrix:
- DOWNSTREAM_PROJECT: [loopy, pytato]
tags:
- large-node
- "docker-runner"
script: |
curl -L -O https://tiker.net/ci-support-v0
. ./ci-support-v0
test_downstream "$DOWNSTREAM_PROJECT"
# vim: sw=2
- arg: ignore
val:
- mpiwrap.py
- arg: ignored-modules
val:
- matplotlib
- siphash24
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Kloeckner"
given-names: "Andreas"
orcid: "https://orcid.org/0000-0003-1228-519X"
- family-names: "Christensen"
given-names: "Nick"
- family-names: "Wala"
given-names: "Matt"
- family-names: "Fikl"
given-names: "Alex"
- family-names: "Stevens"
given-names: "James"
- family-names: "Diener"
given-names: "Matthias"
- family-names: "Kulkarni"
given-names: "Kaushik"
- family-names: "Witherden"
given-names: "Freddie"
- family-names: "Kempf"
given-names: "Dominic"
- family-names: "Gibson"
given-names: "Thomas H."
- family-names: "Fernando"
given-names: "Isuru"
- family-names: "Yu"
given-names: "Yichao"
- family-names: "Wei"
given-names: "Xiaoyu"
- family-names: "Drix"
given-names: "Damien"
- family-names: "Hoag"
given-names: "Ellis"
- family-names: "Gao"
given-names: "Hao"
- family-names: "Dercksen"
given-names: "Koen"
- family-names: "Kocak"
given-names: "Kubilay"
- family-names: "Ofitserov"
given-names: "Nikita"
title: "pytools"
version: 2022.1.7
doi: 10.5281/zenodo.6533949
date-released: 2022-05-04
url: "https://github.com/inducer/pytools"
license: MIT
include LICENSE
include doc/*rst
include doc/Makefile
include doc/conf.py
Pytools: Lots of Little Utilities
=================================
.. image:: https://gitlab.tiker.net/inducer/pytools/badges/main/pipeline.svg
:alt: Gitlab Build Status
:target: https://gitlab.tiker.net/inducer/pytools/commits/main
.. image:: https://github.com/inducer/pytools/workflows/CI/badge.svg?branch=main
:alt: Github Build Status
:target: https://github.com/inducer/pytools/actions?query=branch%3Amain+workflow%3ACI
.. image:: https://badge.fury.io/py/pytools.png
:alt: Python Package Index Release Page
:target: https://pypi.org/project/pytools/
.. image:: https://zenodo.org/badge/1575270.svg
:alt: Zenodo DOI for latest release
:target: https://zenodo.org/badge/latestdoi/1575270
Pytools is a big bag of things that are "missing" from the Python standard Pytools is a big bag of things that are "missing" from the Python standard
library. This is mainly a dependency of my other software packages, and is library. This is mainly a dependency of my other software packages, and is
probably of little interest to you unless you use those. If you're curious probably of little interest to you unless you use those. If you're curious
...@@ -5,14 +21,16 @@ nonetheless, here's what's on offer: ...@@ -5,14 +21,16 @@ nonetheless, here's what's on offer:
* A ton of small tool functions such as `len_iterable`, `argmin`, * A ton of small tool functions such as `len_iterable`, `argmin`,
tuple generation, permutation generation, ASCII table pretty printing, tuple generation, permutation generation, ASCII table pretty printing,
GvR's mokeypatch_xxx() hack, the elusive `flatten`, and much more. GvR's monkeypatch_xxx() hack, the elusive `flatten`, and much more.
* Michele Simionato's decorator module
* A time-series logging module, `pytools.log`.
* Batch job submission, `pytools.batchjob`. * Batch job submission, `pytools.batchjob`.
* A lexer, `pytools.lex`. * A lexer, `pytools.lex`.
* A persistent key-value store, `pytools.persistent_dict`.
Links: Links:
* `Documentation <https://documen.tician.de/pytools>`_ * `Documentation <https://documen.tician.de/pytools>`_
* `Github <https://github.com/inducer/pytools>`_ * `Github <https://github.com/inducer/pytools>`_
* ``pytools.log`` has been spun out into a separate project,
`logpyle <https://github.com/illinois-ceesd/logpyle>`__.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# You can set these variables from the command line. # You can set these variables from the command line.
SPHINXOPTS = SPHINXOPTS =
SPHINXBUILD = sphinx-build SPHINXBUILD = python $(shell which sphinx-build)
SPHINXPROJ = pytools SPHINXPROJ = pytools
SOURCEDIR = . SOURCEDIR = .
BUILDDIR = _build BUILDDIR = _build
...@@ -17,4 +17,4 @@ help: ...@@ -17,4 +17,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new # Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile %: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
\ No newline at end of file
.. automodule:: pytools.codegen
#!/usr/bin/env python3 from __future__ import annotations
# -*- coding: utf-8 -*-
#
# pytools documentation build configuration file, created by
# sphinx-quickstart on Wed Jun 14 16:28:43 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
from urllib.request import urlopen
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The master toctree document. _conf_url = \
master_doc = 'index' "https://raw.githubusercontent.com/inducer/sphinxconfig/main/sphinxconfig.py"
with urlopen(_conf_url) as _inf:
exec(compile(_inf.read(), _conf_url, "exec"), globals())
# General information about the project. copyright = "2009-21, Andreas Kloeckner"
project = 'pytools' author = "Andreas Kloeckner"
copyright = '2017, Andreas Kloeckner'
author = 'Andreas Kloeckner'
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
...@@ -59,119 +17,33 @@ author = 'Andreas Kloeckner' ...@@ -59,119 +17,33 @@ author = 'Andreas Kloeckner'
# #
# The short X.Y version. # The short X.Y version.
ver_dic = {} ver_dic = {}
exec(compile(open("../pytools/version.py").read(), "../pytools/version.py", 'exec'), ver_dic) exec(compile(open("../pytools/version.py").read(), "../pytools/version.py", "exec"),
ver_dic)
version = ".".join(str(x) for x in ver_dic["VERSION"]) version = ".".join(str(x) for x in ver_dic["VERSION"])
release = ver_dic["VERSION_TEXT"] release = ver_dic["VERSION_TEXT"]
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path # This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
# The name of the Pygments (syntax highlighting) style to use. intersphinx_mapping = {
pygments_style = 'sphinx' "loopy": ("https://documen.tician.de/loopy", None),
"numpy": ("https://numpy.org/doc/stable", None),
# If true, `todo` and `todoList` produce output, else they produce nothing. "pymbolic": ("https://documen.tician.de/pymbolic", None),
todo_include_todos = False "pytest": ("https://docs.pytest.org/en/stable", None),
"setuptools": ("https://setuptools.pypa.io/en/latest", None),
"python": ("https://docs.python.org/3", None),
# -- Options for HTML output ---------------------------------------------- "platformdirs": ("https://platformdirs.readthedocs.io/en/latest", None),
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme_options = {
"extra_nav_links": {
"🚀 Github": "https://github.com/inducer/pytools",
"💾 Download Releases": "https://pypi.python.org/pypi/pytools",
}
}
html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html',
'searchbox.html',
]
}
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# -- Options for HTMLHelp output ------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'pytoolsdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
} }
# Grouping the document tree into LaTeX files. List of tuples nitpicky = True
# (source start file, target name, title, nitpick_ignore_regex = [
# author, documentclass [howto, manual, or own class]). ["py:class", r"typing_extensions\.(.+)"],
latex_documents = [ ["py:class", r"ReadableBuffer"],
(master_doc, 'pytools.tex', 'pytools Documentation',
'Andreas Kloeckner', 'manual'),
] ]
autodoc_type_aliases = {
# -- Options for manual page output --------------------------------------- "GraphT": "pytools.graph.GraphT",
"NodeT": "pytools.graph.NodeT",
# One entry per manual page. List of tuples }
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'pytools', 'pytools Documentation',
[author], 1)
]
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'pytools', 'pytools Documentation',
author, 'pytools', 'One line description of project.',
'Miscellaneous'),
]
Testing convergence
-------------------
.. automodule:: pytools.convergence
.. automodule:: pytools.graph
...@@ -8,7 +8,14 @@ Welcome to pytools's documentation! ...@@ -8,7 +8,14 @@ Welcome to pytools's documentation!
reference reference
obj_array obj_array
persistent_dict persistent_dict
convergence
graph
tag
codegen
mpi
misc misc
🚀 Github <https://github.com/inducer/pytools>
💾 Download Releases <https://pypi.python.org/pypi/pytools>
Indices and tables Indices and tables
================== ==================
......
...@@ -20,7 +20,7 @@ and say:: ...@@ -20,7 +20,7 @@ and say::
User-visible changes User-visible changes
==================== ====================
Version 2017.4 Version 2020.4
-------------- --------------
.. note:: .. note::
...@@ -28,6 +28,14 @@ Version 2017.4 ...@@ -28,6 +28,14 @@ Version 2017.4
This version is currently under development. You can get snapshots from This version is currently under development. You can get snapshots from
Pytools's `git repository <https://github.com/inducer/pytools>`_ Pytools's `git repository <https://github.com/inducer/pytools>`_
* :mod:`pytools.codegen` was added.
Version 2020.3
--------------
* Type annotations were added.
* Python 2 support was dropped.
.. _license: .. _license:
License License
......
.. automodule:: pytools.mpi
.. automodule:: pytools .. automodule:: pytools
.. automodule:: pytools.datatable
.. automodule:: pytools.graphviz
.. automodule:: pytools.tag