Skip to content

Commit

Permalink
Merge branch 'main' into production-pilot-update
Browse files Browse the repository at this point in the history
  • Loading branch information
MTCam committed Jul 24, 2024
2 parents 32124fa + 550920a commit fefadcf
Show file tree
Hide file tree
Showing 57 changed files with 1,831 additions and 1,164 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ jobs:
pip install ruff
ruff check
typos:
name: Typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@master

pylint:
name: Pylint
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from urllib.request import urlopen


_conf_url = \
"https://raw.githubusercontent.com/inducer/sphinxconfig/main/sphinxconfig.py"
with urlopen(_conf_url) as _inf:
Expand Down Expand Up @@ -42,6 +43,8 @@
# this needs a setting of the same name across all packages involved, that's
# why this name is as global-sounding as it is.
import sys


sys._BUILDING_SPHINX_DOCS = True

nitpick_ignore_regex = [
Expand Down
14 changes: 9 additions & 5 deletions examples/advection.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env python
import functools

import numpy as np
import pytest
import functools
from dg_tools import DGDiscr1D, integrate, DGOps1D, DGOps1DRef
from dg_tools import DGDiscr1D, DGOps1D, DGOps1DRef, integrate


memoized = functools.lru_cache(maxsize=None)


class AdvectionOperator(object):
class AdvectionOperator:
"""A class representing a DG advection operator."""

def __init__(self, discr, c, flux_type, dg_ops):
Expand Down Expand Up @@ -138,8 +140,9 @@ def test_advection_convergence(order, flux_type):
errors = []
hs = []

import pytato as pt
import pyopencl as cl

import pytato as pt
cl_ctx = cl.create_some_context()
queue = cl.CommandQueue(cl_ctx)

Expand Down Expand Up @@ -169,8 +172,9 @@ def test_advection_convergence(order, flux_type):


def main():
import pytato as pt
import pyopencl as cl

import pytato as pt
cl_ctx = cl.create_some_context()
queue = cl.CommandQueue(cl_ctx)

Expand Down
8 changes: 8 additions & 0 deletions examples/demo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env python

import numpy as np

import pytato as pt


n = pt.make_size_param("n")
a = pt.make_placeholder(name="a", shape=(n, n), dtype=np.float64)

Expand All @@ -15,6 +17,8 @@

import pyopencl as cl
import pyopencl.array as cla


ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)

Expand All @@ -27,6 +31,8 @@

# interface for efficient execution
import loopy as lp


prg = pt.generate_loopy(
result, options=lp.Options(no_numpy=True, return_dict=True)
).bind_to_context(ctx)
Expand All @@ -47,6 +53,8 @@
print("============= End Loopy code ===============")

import loopy as lp


print("============== OpenCL code =================")
print(lp.generate_code_v2(prg.program).device_code())
print("============ End OpenCL code ===============")
Expand Down
4 changes: 3 additions & 1 deletion examples/demo_distributed_node_duplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
partitioning routine is to recompute expressions that appear in multiple
partitions but are not materialized.
"""
import pytato as pt
import numpy as np
from mpi4py import MPI

import pytato as pt


comm = MPI.COMM_WORLD

size = 2
Expand Down
10 changes: 6 additions & 4 deletions examples/dg_tools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import contextlib

import numpy as np
import numpy.polynomial.legendre as leg
import numpy.linalg as la
import contextlib
import numpy.polynomial.legendre as leg


__doc__ = """
Notation convention for operator shapes
Expand Down Expand Up @@ -36,7 +38,7 @@ def ortholegval(x, c):
return leg.legval(x, c * factors)


class DGDiscr1D(object):
class DGDiscr1D:
"""A one-dimensional Discontinuous Galerkin discretization."""

def __init__(self, left, right, nelements, nnodes):
Expand Down Expand Up @@ -260,7 +262,7 @@ def elementwise(mat, vec):
return np.einsum("ij,kj->ki", mat, vec)


class AbstractDGOps1D(object):
class AbstractDGOps1D:
def __init__(self, discr):
self.discr = discr

Expand Down
4 changes: 3 additions & 1 deletion examples/einsum.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import numpy as np
import pytato as pt

import pyopencl as cl

import pytato as pt


ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)
Expand Down
19 changes: 13 additions & 6 deletions examples/mpi-distributed.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
#!/usr/bin/env python

from mpi4py import MPI # pylint: disable=import-error


comm = MPI.COMM_WORLD

import pytato as pt
import numpy as np

import pyopencl as cl
import pyopencl.array as cl_array
import numpy as np

from pytato import (find_distributed_partition, generate_code_for_partition,
number_distributed_tags,
execute_distributed_partition,
staple_distributed_send, make_distributed_recv)
import pytato as pt
from pytato import (
execute_distributed_partition,
find_distributed_partition,
generate_code_for_partition,
make_distributed_recv,
number_distributed_tags,
staple_distributed_send,
)


def main():
Expand Down
5 changes: 4 additions & 1 deletion examples/reduction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import numpy as np
import pytato as pt

import pyopencl as cl

import pytato as pt


ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)

Expand Down
3 changes: 2 additions & 1 deletion examples/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"""Demonstrates graph visualization with Graphviz."""

import logging
import numpy as np
import shutil
import subprocess

import numpy as np

import pytato as pt


Expand Down
32 changes: 28 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ extend-select = [
"C", # flake8-comprehensions
"E", # pycodestyle
"F", # pyflakes
# not yet
# "I", # flake8-isort
"I", # flake8-isort
"N", # pep8-naming
"Q", # flake8-quotes
"W", # pycodestyle
"NPY" # numpy
"NPY", # numpy
"RUF",
"UP",
]
extend-ignore = [
"E226",
Expand All @@ -26,15 +27,24 @@ extend-ignore = [
# numpy random generators---disable for now
"NPY002",
]

allowed-confusables = [
"", # union
" ", # nbsp
]

[tool.ruff.lint.per-file-ignores]
"examples/advection.py" = ["B023"]
"test/test_linalg.py" = ["N806"]
"doc/*.py" = ["I002"]
"examples/*.py" = ["I002"]

[tool.ruff.lint.isort]
known-first-party = ["pytools", "pymbolic", "loopy"]
known-first-party = ["pytools", "pymbolic", "loopy", "pyopencl"]
known-local-folder = ["pytato"]
lines-after-imports = 2
combine-as-imports = true
required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.flake8-quotes]
inline-quotes = "double"
Expand All @@ -59,3 +69,17 @@ module = [
"pytato.scalar_expr",
]
allow_subclassing_any = true


[tool.typos.default]
extend-ignore-re = [
"(?Rm)^.*(#|//)\\s*spellchecker:\\s*disable-line$"
]

[tool.typos.default.extend-words]
# like the numpy function, array range
arange = "arange"

[tool.typos.files]
extend-exclude = [
]
Loading

0 comments on commit fefadcf

Please sign in to comment.