Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12,358 changes: 11,137 additions & 1,221 deletions .basedpyright/baseline.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
curl -L -O https://tiker.net/ci-support-v0
. ci-support-v0
build_py_project
run_pylint "$(basename $GITHUB_REPOSITORY)" examples/*.py test/*.py
run_pylint "$(basename $GITHUB_REPOSITORY)" examples/*.py

docs:
name: Documentation
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Pylint:
- curl -L -O https://tiker.net/ci-support-v0
- . ci-support-v0
- build_py_project
- run_pylint "$(get_proj_name)" examples/*.py test/*.py
- run_pylint "$(get_proj_name)" examples/*.py
tags:
- python3
except:
Expand Down
1 change: 1 addition & 0 deletions .test-conda-env-py3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ channels:
dependencies:
- git
- numpy
- scipy
- sympy
- pocl
- pocl-cuda
Expand Down
2 changes: 1 addition & 1 deletion examples/curve-pot.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def map_to_curve(t: NDArray[np.floating]):

return x, y, w

from curve import CurveGrid
from sumpy.test.curve import CurveGrid

native_t = np.linspace(0, 1, nsrc, endpoint=False)
native_x, native_y, native_weights = map_to_curve(native_t)
Expand Down
26 changes: 0 additions & 26 deletions examples/curve.py

This file was deleted.

Empty file added sumpy/test/__init__.py
Empty file.
58 changes: 58 additions & 0 deletions sumpy/test/curve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from __future__ import annotations


__copyright__ = "Copyright (C) 2012 Andreas Kloeckner"

__license__ = """
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""

from typing import TYPE_CHECKING, final

import numpy as np
import scipy.fftpack as fftpack


if TYPE_CHECKING:
from numpy.typing import NDArray


@final
class CurveGrid:
pos: NDArray[np.floating]
mean_curvature: NDArray[np.floating]
normal: NDArray[np.floating]

def __init__(self, x: NDArray[np.floating], y: NDArray[np.floating]):
self.pos = np.vstack([x, y]).copy()
xp = self.xp = fftpack.diff(x, period=1)
yp = self.yp = fftpack.diff(y, period=1)
xpp = self.xpp = fftpack.diff(xp, period=1)
ypp = self.ypp = fftpack.diff(yp, period=1)
self.mean_curvature = (xp*ypp-yp*xpp)/((xp**2+yp**2)**(3/2))

speed = self.speed = np.sqrt(xp**2+yp**2)
self.normal = (np.vstack([yp, -xp])/speed).copy()

def __len__(self):
return len(self.pos)

def plot(self):
import matplotlib.pyplot as pt
pt.plot(self.pos[:, 0], self.pos[:, 1])
File renamed without changes.
File renamed without changes.
File renamed without changes.
50 changes: 37 additions & 13 deletions test/test_fmm.py → sumpy/test/test_fmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import pytest

import pytools.obj_array as obj_array
from arraycontext import pytest_generate_tests_for_array_contexts
from arraycontext import ArrayContextFactory, pytest_generate_tests_for_array_contexts

from sumpy.array_context import PytestPyOpenCLArrayContextFactory, _acf # noqa: F401
from sumpy.expansion.local import (
Expand All @@ -49,7 +49,13 @@
Y2DMultipoleExpansion,
)
from sumpy.fmm import SumpyExpansionWrangler, SumpyTreeIndependentDataForWrangler
from sumpy.kernel import BiharmonicKernel, HelmholtzKernel, LaplaceKernel, YukawaKernel
from sumpy.kernel import (
BiharmonicKernel,
HelmholtzKernel,
Kernel,
LaplaceKernel,
YukawaKernel,
)


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -92,9 +98,16 @@
(YukawaKernel(2), Y2DLocalExpansion, Y2DMultipoleExpansion,
False),
])
def test_sumpy_fmm(actx_factory, knl, local_expn_class, mpole_expn_class,
order_varies_with_level, use_translation_classes, use_fft,
fft_backend, visualize=False):
def test_sumpy_fmm(
actx_factory: ArrayContextFactory,
knl: Kernel,
local_expn_class,
mpole_expn_class,
order_varies_with_level,
use_translation_classes,
use_fft,
fft_backend,
visualize=False):
if fft_backend == "pyvkfft":
pytest.importorskip("pyvkfft")

Expand All @@ -120,9 +133,15 @@ def test_sumpy_fmm(actx_factory, knl, local_expn_class, mpole_expn_class,
fft_backend)


def _test_sumpy_fmm(actx_factory, knl, local_expn_class, mpole_expn_class,
order_varies_with_level, use_translation_classes, use_fft,
fft_backend):
def _test_sumpy_fmm(
actx_factory: ArrayContextFactory,
knl: Kernel,
local_expn_class,
mpole_expn_class,
order_varies_with_level,
use_translation_classes,
use_fft,
fft_backend):

actx = actx_factory()

Expand Down Expand Up @@ -264,7 +283,7 @@ def fmm_level_to_order(kernel, kernel_args, tree, lev):
# {{{ test_coeff_magnitude_rscale

@pytest.mark.parametrize("knl", [LaplaceKernel(2), BiharmonicKernel(2)])
def test_coeff_magnitude_rscale(actx_factory, knl):
def test_coeff_magnitude_rscale(actx_factory: ArrayContextFactory, knl):
"""Checks that the rscale used keeps the coefficient magnitude
difference small
"""
Expand Down Expand Up @@ -346,7 +365,7 @@ def fmm_level_to_order(kernel, kernel_args, tree, lev):

# {{{ test_unified_single_and_double

def test_unified_single_and_double(actx_factory, visualize=False):
def test_unified_single_and_double(actx_factory: ArrayContextFactory, visualize=False):
"""
Test that running one FMM for single layer + double layer gives the
same result as running one FMM for each and adding the results together
Expand Down Expand Up @@ -505,7 +524,7 @@ def test_sumpy_fmm_timing_data_collection(ctx_factory, use_fft, visualize=False)
assert timing_data


def test_sumpy_fmm_exclude_self(actx_factory, visualize=False):
def test_sumpy_fmm_exclude_self(actx_factory: ArrayContextFactory, visualize=False):
if visualize:
logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -573,7 +592,9 @@ def test_sumpy_fmm_exclude_self(actx_factory, visualize=False):

# {{{ test_sumpy_axis_source_derivative

def test_sumpy_axis_source_derivative(actx_factory, visualize=False):
def test_sumpy_axis_source_derivative(
actx_factory: ArrayContextFactory,
visualize=False):
if visualize:
logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -641,7 +662,10 @@ def test_sumpy_axis_source_derivative(actx_factory, visualize=False):
# {{{ test_sumpy_target_point_multiplier

@pytest.mark.parametrize("deriv_axes", [(), (0,), (1,)])
def test_sumpy_target_point_multiplier(actx_factory, deriv_axes, visualize=False):
def test_sumpy_target_point_multiplier(
actx_factory: ArrayContextFactory,
deriv_axes,
visualize=False):
if visualize:
logging.basicConfig(level=logging.INFO)

Expand Down
28 changes: 21 additions & 7 deletions test/test_kernels.py → sumpy/test/test_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import pytest

import pytools.obj_array as obj_array
from arraycontext import pytest_generate_tests_for_array_contexts
from arraycontext import ArrayContextFactory, pytest_generate_tests_for_array_contexts
from pytools.convergence import PConvergenceVerifier

import sumpy.symbolic as sym
Expand All @@ -58,6 +58,7 @@
BiharmonicKernel,
DirectionalSourceDerivative,
HelmholtzKernel,
Kernel,
LaplaceKernel,
StokesletKernel,
)
Expand All @@ -73,7 +74,7 @@
# {{{ test_p2p

@pytest.mark.parametrize("exclude_self", (True, False))
def test_p2p(actx_factory, exclude_self):
def test_p2p(actx_factory: ArrayContextFactory, exclude_self):
actx = actx_factory()

dimensions = 3
Expand Down Expand Up @@ -134,7 +135,10 @@ def test_p2p(actx_factory, exclude_self):
(LaplaceKernel(2), LinearPDEConformingVolumeTaylorLocalExpansion),
(LaplaceKernel(2), LinearPDEConformingVolumeTaylorMultipoleExpansion),
])
def test_p2e_multiple(actx_factory, base_knl, expn_class):
def test_p2e_multiple(
actx_factory: ArrayContextFactory,
base_knl: Kernel,
expn_class):
order = 4
actx = actx_factory()

Expand Down Expand Up @@ -275,7 +279,12 @@ def test_p2e_multiple(actx_factory, base_knl, expn_class):
False,
True
])
def test_p2e2p(actx_factory, base_knl, expn_class, order, with_source_derivative):
def test_p2e2p(
actx_factory: ArrayContextFactory,
base_knl,
expn_class,
order,
with_source_derivative):
actx = actx_factory()

res = 100
Expand Down Expand Up @@ -508,8 +517,13 @@ def test_p2e2p(actx_factory, base_knl, expn_class, order, with_source_derivative
(StokesletKernel(2, 0, 0), LinearPDEConformingVolumeTaylorLocalExpansion,
LinearPDEConformingVolumeTaylorMultipoleExpansion, False),
])
def test_translations(actx_factory, knl, local_expn_class, mpole_expn_class,
use_fft, visualize=False):
def test_translations(
actx_factory: ArrayContextFactory,
knl,
local_expn_class,
mpole_expn_class,
use_fft,
visualize=False):
if visualize:
logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -763,7 +777,7 @@ def test_m2l_toeplitz():

@pytest.mark.parametrize("dim", [2, 3])
@pytest.mark.parametrize("order", [2, 4, 6])
def test_m2m_compressed_error_helmholtz(actx_factory, dim, order):
def test_m2m_compressed_error_helmholtz(actx_factory: ArrayContextFactory, dim, order):
from sumpy import toys

actx = actx_factory()
Expand Down
15 changes: 12 additions & 3 deletions test/test_matrixgen.py → sumpy/test/test_matrixgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import pytest

import pytools.obj_array as obj_array
from arraycontext import pytest_generate_tests_for_array_contexts
from arraycontext import ArrayContextFactory, pytest_generate_tests_for_array_contexts

from sumpy.array_context import PytestPyOpenCLArrayContextFactory, _acf # noqa: F401

Expand Down Expand Up @@ -92,7 +92,11 @@ def _build_subset_indices(actx, ntargets, nsources, factor):

@pytest.mark.parametrize("factor", [1.0, 0.6])
@pytest.mark.parametrize("lpot_id", [1, 2])
def test_qbx_direct(actx_factory, factor, lpot_id, visualize=False):
def test_qbx_direct(
actx_factory: ArrayContextFactory,
factor,
lpot_id,
visualize=False):
if visualize:
logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -186,7 +190,12 @@ def test_qbx_direct(actx_factory, factor, lpot_id, visualize=False):
@pytest.mark.parametrize("exclude_self", [True, False])
@pytest.mark.parametrize("factor", [1.0, 0.6])
@pytest.mark.parametrize("lpot_id", [1, 2])
def test_p2p_direct(actx_factory, exclude_self, factor, lpot_id, visualize=False):
def test_p2p_direct(
actx_factory: ArrayContextFactory,
exclude_self,
factor,
lpot_id,
visualize=False):
if visualize:
logging.basicConfig(level=logging.INFO)

Expand Down
10 changes: 5 additions & 5 deletions test/test_misc.py → sumpy/test/test_misc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

from typing_extensions import override


__copyright__ = "Copyright (C) 2017 Andreas Kloeckner"

Expand All @@ -25,6 +23,7 @@
THE SOFTWARE.
"""


import logging
import sys
from dataclasses import dataclass
Expand All @@ -33,8 +32,9 @@
import numpy as np
import numpy.linalg as la
import pytest
from typing_extensions import override

from arraycontext import pytest_generate_tests_for_array_contexts
from arraycontext import ArrayContextFactory, pytest_generate_tests_for_array_contexts

import sumpy.symbolic as sym
import sumpy.toys as t
Expand Down Expand Up @@ -128,7 +128,7 @@ def nderivs(self):
KernelInfo(LineOfCompressionKernel(3, 0), mu=5, nu=0.2),
KernelInfo(LineOfCompressionKernel(3, 1), mu=5, nu=0.2),
])
def test_pde_check_kernels(actx_factory, knl_info, order=5):
def test_pde_check_kernels(actx_factory: ArrayContextFactory, knl_info, order=5):
actx = actx_factory()

dim = knl_info.kernel.dim
Expand Down Expand Up @@ -309,7 +309,7 @@ def dim(self):


@pytest.mark.parametrize("case", P2E2E2P_TEST_CASES)
def test_toy_p2e2e2p(actx_factory, case):
def test_toy_p2e2e2p(actx_factory: ArrayContextFactory, case):
dim = case.dim

src = case.source.reshape(dim, -1)
Expand Down
Loading
Loading