Skip to content

Commit a16a31c

Browse files
committed
Track obj_array renames
1 parent 975c5d1 commit a16a31c

9 files changed

Lines changed: 27 additions & 36 deletions

File tree

sumpy/distributed.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from boxtree.distributed.calculation import DistributedExpansionWrangler
2727

2828
import pyopencl.array as cl_array
29+
import pytools.obj_array as obj_array
2930

3031
from sumpy.fmm import SumpyExpansionWrangler
3132

@@ -66,8 +67,7 @@ def gather_potential_results(self, potentials, tgt_idx_all_ranks):
6667
super().gather_potential_results(potentials_host, tgt_idx_all_ranks))
6768

6869
if mpi_rank == 0:
69-
from pytools.obj_array import make_obj_array
70-
return make_obj_array([
70+
return obj_array.new_1d([
7171
cl_array.to_device(potentials_dev.queue, gathered_potentials_host)
7272
for gathered_potentials_host, potentials_dev in
7373
zip(gathered_potentials_host_vec, potentials, strict=True)])
@@ -85,15 +85,14 @@ def reorder_potentials(self, potentials):
8585
if self.comm.Get_rank() == 0:
8686
import numpy as np
8787

88-
from pytools.obj_array import obj_array_vectorize
8988
assert (
9089
isinstance(potentials, np.ndarray)
9190
and potentials.dtype.char == "O")
9291

9392
def reorder(x):
9493
return x[self.global_traversal.tree.sorted_target_ids]
9594

96-
return obj_array_vectorize(reorder, potentials)
95+
return obj_array.vectorize(reorder, potentials)
9796
else:
9897
return None
9998

sumpy/fmm.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
import pyopencl as cl
4949
import pyopencl.array as cl_array
50+
import pytools.obj_array as obj_array
5051
from pytools import memoize_method
5152

5253
from sumpy import (
@@ -546,8 +547,7 @@ def output_zeros(self, template_ary):
546547
(e.g. :class:`pyopencl.CommandQueue`) the returned array should
547548
reuse.
548549
"""
549-
from pytools.obj_array import make_obj_array
550-
return make_obj_array([
550+
return obj_array.new_1d([
551551
cl_array.zeros(
552552
template_ary.queue,
553553
self.tree.ntargets,
@@ -560,15 +560,14 @@ def reorder_sources(self, source_array):
560560
def reorder_potentials(self, potentials):
561561
import numpy as np
562562

563-
from pytools.obj_array import obj_array_vectorize
564563
assert (
565564
isinstance(potentials, np.ndarray)
566565
and potentials.dtype.char == "O")
567566

568567
def reorder(x):
569568
return x[self.tree.sorted_target_ids]
570569

571-
return obj_array_vectorize(reorder, potentials)
570+
return obj_array.vectorize(reorder, potentials)
572571

573572
@property
574573
@memoize_method

sumpy/point_calculus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import numpy as np
2727
import numpy.linalg as la
2828

29+
import pytools.obj_array as obj_array
2930
from pytools import memoize_method
3031

3132

@@ -232,8 +233,7 @@ def curl(self, arg):
232233
:class:`numpy.ndarray`\ s with shape ``(npoints_total,)``.
233234
"""
234235
from pytools import levi_civita
235-
from pytools.obj_array import make_obj_array
236-
return make_obj_array([
236+
return obj_array.new_1d([
237237
sum(
238238
levi_civita((k, m, n)) * self.diff(m, arg[n])
239239
for m in range(3) for n in range(3))

sumpy/qbx.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from typing_extensions import override
3434

3535
import loopy as lp
36+
import pytools.obj_array as obj_array
3637
from loopy.version import MOST_RECENT_LANGUAGE_VERSION
3738
from pymbolic import parse, var
3839
from pytools import memoize_method
@@ -646,8 +647,7 @@ def normal(self):
646647
self.arguments["normal"] = (
647648
lp.GlobalArg("normal", self.geometry_dtype,
648649
shape=("ntargets", self.dim), order="C"))
649-
from pytools.obj_array import make_obj_array
650-
return make_obj_array([
650+
return obj_array.new_1d([
651651
parse(f"normal[itgt, {i}]")
652652
for i in range(self.dim)])
653653

@@ -657,8 +657,7 @@ def tangent(self):
657657
self.arguments["tangent"] = (
658658
lp.GlobalArg("tangent", self.geometry_dtype,
659659
shape=("ntargets", self.dim), order="C"))
660-
from pytools.obj_array import make_obj_array
661-
return make_obj_array([
660+
return obj_array.new_1d([
662661
parse(f"tangent[itgt, {i}]")
663662
for i in range(self.dim)])
664663

@@ -678,8 +677,7 @@ def src_derivative_dir(self):
678677
lp.GlobalArg("src_derivative_dir",
679678
self.geometry_dtype, shape=("ntargets", self.dim),
680679
order="C"))
681-
from pytools.obj_array import make_obj_array
682-
return make_obj_array([
680+
return obj_array.new_1d([
683681
parse(f"src_derivative_dir[itgt, {i}]")
684682
for i in range(self.dim)])
685683

@@ -690,8 +688,7 @@ def tgt_derivative_dir(self):
690688
lp.GlobalArg("tgt_derivative_dir",
691689
self.geometry_dtype, shape=("ntargets", self.dim),
692690
order="C"))
693-
from pytools.obj_array import make_obj_array
694-
return make_obj_array([
691+
return obj_array.new_1d([
695692
parse(f"tgt_derivative_dir[itgt, {i}]")
696693
for i in range(self.dim)])
697694

sumpy/tools.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from __future__ import annotations
22

3-
from pyopencl import MemoryObjectHolder
4-
53

64
__copyright__ = """
75
Copyright (C) 2012 Andreas Kloeckner
@@ -29,6 +27,7 @@
2927
THE SOFTWARE.
3028
"""
3129

30+
3231
import enum
3332
import logging
3433
import warnings
@@ -40,7 +39,9 @@
4039
import numpy as np
4140

4241
import loopy as lp
42+
import pytools.obj_array as obj_array
4343
from pymbolic.mapper import WalkMapper
44+
from pyopencl import MemoryObjectHolder
4445
from pytools import memoize_method
4546
from pytools.tag import Tag, tag_dataclass
4647

@@ -226,17 +227,14 @@ def build_matrix(op, dtype=None, shape=None):
226227

227228
def vector_to_device(queue, vec):
228229
from pyopencl.array import to_device
229-
from pytools.obj_array import obj_array_vectorize
230230

231231
def to_dev(ary):
232232
return to_device(queue, ary)
233233

234-
return obj_array_vectorize(to_dev, vec)
234+
return obj_array.vectorize(to_dev, vec)
235235

236236

237237
def vector_from_device(queue, vec):
238-
from pytools.obj_array import obj_array_vectorize
239-
240238
def from_dev(ary):
241239
from numbers import Number
242240
if isinstance(ary, np.number | Number):
@@ -245,7 +243,7 @@ def from_dev(ary):
245243

246244
return ary.get(queue=queue)
247245

248-
return obj_array_vectorize(from_dev, vec)
246+
return obj_array.vectorize(from_dev, vec)
249247

250248

251249
def _merge_kernel_arguments(dictionary, arg):

sumpy/toys.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from numbers import Number
3131
from typing import TYPE_CHECKING
3232

33+
import pytools.obj_array as obj_array
3334
from pytools import memoize_method
3435

3536
from sumpy.kernel import TargetTransformationRemover
@@ -309,8 +310,6 @@ def _e2p(psource, targets, e2p):
309310
queue,
310311
np.array(psource.center, dtype=np.float64).reshape(toy_ctx.kernel.dim, 1))
311312

312-
from pytools.obj_array import make_obj_array
313-
314313
from sumpy.tools import vector_to_device
315314

316315
coeffs = cl_array.to_device(queue, np.array([psource.coeffs]))
@@ -323,7 +322,7 @@ def _e2p(psource, targets, e2p):
323322
box_target_counts_nonchild=box_target_counts_nonchild,
324323
centers=centers,
325324
rscale=psource.rscale,
326-
targets=vector_to_device(queue, make_obj_array(targets)),
325+
targets=vector_to_device(queue, obj_array.new_1d(targets)),
327326
**toy_ctx.extra_kernel_kwargs)
328327

329328
return pot.get(queue)

test/test_fmm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import numpy.linalg as la
3333
import pytest
3434

35+
import pytools.obj_array as obj_array
3536
from arraycontext import pytest_generate_tests_for_array_contexts
3637

3738
from sumpy.array_context import PytestPyOpenCLArrayContextFactory, _acf # noqa: F401
@@ -142,8 +143,7 @@ def _test_sumpy_fmm(actx_factory, knl, local_expn_class, mpole_expn_class,
142143
from sumpy.visualization import FieldPlotter
143144
fp = FieldPlotter(np.array([0.5, 0]), extent=3, npoints=200)
144145

145-
from pytools.obj_array import make_obj_array
146-
targets = make_obj_array([fp.points[i] for i in range(knl.dim)])
146+
targets = obj_array.new_1d([fp.points[i] for i in range(knl.dim)])
147147

148148
from boxtree import TreeBuilder
149149
tb = TreeBuilder(actx.context)

test/test_kernels.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
import numpy.linalg as la
3232
import pytest
3333

34+
import pytools.obj_array as obj_array
3435
from arraycontext import pytest_generate_tests_for_array_contexts
3536
from pytools.convergence import PConvergenceVerifier
36-
from pytools.obj_array import make_obj_array
3737

3838
import sumpy.symbolic as sym
3939
import sumpy.toys as t
@@ -350,7 +350,7 @@ def test_p2e2p(actx_factory, base_knl, expn_class, order, with_source_derivative
350350
+ center[:, np.newaxis])
351351

352352
centers = actx.from_numpy(centers)
353-
targets = actx.from_numpy(make_obj_array(fp.points))
353+
targets = actx.from_numpy(obj_array.new_1d(fp.points))
354354

355355
rscale = 0.5 # pick something non-1
356356

test/test_matrixgen.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import numpy.linalg as la
3131
import pytest
3232

33+
import pytools.obj_array as obj_array
3334
from arraycontext import pytest_generate_tests_for_array_contexts
3435

3536
from sumpy.array_context import PytestPyOpenCLArrayContextFactory, _acf # noqa: F401
@@ -141,9 +142,8 @@ def test_qbx_direct(actx_factory, factor, lpot_id, visualize=False):
141142

142143
extra_kwargs = {}
143144
if lpot_id == 2:
144-
from pytools.obj_array import make_obj_array
145145
extra_kwargs["dsource_vec"] = (
146-
actx.from_numpy(make_obj_array(np.ones((ndim, n))))
146+
actx.from_numpy(obj_array.new_1d(np.ones((ndim, n))))
147147
)
148148

149149
_, (result_lpot,) = lpot(actx.queue,
@@ -229,9 +229,8 @@ def test_p2p_direct(actx_factory, exclude_self, factor, lpot_id, visualize=False
229229
actx.from_numpy(np.arange(n, dtype=np.int32))
230230
)
231231
if lpot_id == 2:
232-
from pytools.obj_array import make_obj_array
233232
extra_kwargs["dsource_vec"] = (
234-
actx.from_numpy(make_obj_array(np.ones((ndim, n)))))
233+
actx.from_numpy(obj_array.new_1d(np.ones((ndim, n)))))
235234

236235
_, (result_lpot,) = lpot(actx.queue,
237236
targets=targets,

0 commit comments

Comments
 (0)