Skip to content

Commit 71a138f

Browse files
alexfiklinducer
authored andcommitted
feat: port to new obj_array functions
1 parent 307a898 commit 71a138f

24 files changed

Lines changed: 116 additions & 115 deletions

experiments/poisson.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from meshmode.discretization.visualization import make_visualizer
1313

1414
from pytential import bind, sym, norm # noqa
15-
from pytools.obj_array import make_obj_array
15+
from pytools import obj_array
1616

1717
import pytential.symbolic.primitives as p
1818

@@ -196,7 +196,7 @@ def get_kernel():
196196
p.area_element(mesh.ambient_dim, mesh.dim))
197197
(queue)).get())
198198

199-
centers = make_obj_array([ci.copy().reshape(vol_discr.nnodes) for ci in targets])
199+
centers = obj_array.new_1d([ci.copy().reshape(vol_discr.nnodes) for ci in targets])
200200
centers[2][:] = center_dist
201201

202202
print(center_dist)

experiments/qbx-tangential-deriv-jump.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ def main():
3434
qbx = QBXLayerPotentialSource(density_discr, 4*target_order,
3535
qbx_order, fmm_order=False)
3636

37-
from pytools.obj_array import join_fields
37+
from pytools import obj_array
3838
sig_sym = sym.var("sig")
3939
knl = LaplaceKernel(2)
40-
op = join_fields(
40+
op = obj_array.flat(
4141
sym.tangential_derivative(mesh.ambient_dim,
4242
sym.D(knl, sig_sym, qbx_forced_limit=+1)).as_scalar(),
4343
sym.tangential_derivative(mesh.ambient_dim,

experiments/stokes-2d-interior.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def main(nelements):
3333
logging.basicConfig(level=logging.INFO)
3434

3535
def get_obj_array(obj_array):
36-
from pytools.obj_array import make_obj_array
37-
return make_obj_array([
36+
from pytools import obj_array
37+
return obj_array.new_1d([
3838
ary.get()
3939
for ary in obj_array
4040
])
@@ -72,7 +72,6 @@ def get_obj_array(obj_array):
7272

7373
from sumpy.kernel import LaplaceKernel
7474
from pytential.symbolic.stokes import StressletWrapper
75-
from pytools.obj_array import make_obj_array
7675
dim=2
7776
cse = sym.cse
7877

experiments/two-domain-helmholtz.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import pyopencl.array # noqa
2828
import pyopencl.clmath # noqa
2929

30-
from pytools.obj_array import make_obj_array
30+
from pytools import obj_array
3131

3232
from meshmode.discretization import Discretization
3333
from meshmode.discretization.poly_element import \
@@ -105,7 +105,7 @@ def main():
105105
bound_pde_op = bind(qbx, pde_op.operator(op_unknown_sym))
106106

107107
# in inner domain
108-
sources_1 = make_obj_array(list(np.array([
108+
sources_1 = obj_array.new_1d(list(np.array([
109109
[-1.5, 0.5]
110110
]).T.copy()))
111111
strengths_1 = np.array([1])

pytential/linalg/direct_solver_symbolic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
THE SOFTWARE.
2121
"""
2222

23-
from pytools.obj_array import make_obj_array
23+
from pytools import obj_array
2424

2525
from pytential.symbolic.mappers import (
2626
IdentityMapper, OperatorCollector, LocationTagger)
@@ -44,7 +44,7 @@ class PROXY_SKELETONIZATION_TARGET: # noqa: N801
4444

4545
def prepare_expr(places, exprs, auto_where=None):
4646
from pytential.symbolic.execution import _prepare_expr
47-
return make_obj_array([
47+
return obj_array.new_1d([
4848
_prepare_expr(places, expr, auto_where=auto_where)
4949
for expr in exprs])
5050

@@ -60,7 +60,7 @@ def _prepare_expr(expr):
6060

6161
return expr
6262

63-
return make_obj_array([_prepare_expr(expr) for expr in exprs])
63+
return obj_array.new_1d([_prepare_expr(expr) for expr in exprs])
6464

6565
# }}}
6666

pytential/qbx/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,9 @@ def drive_cost_model(
485485
calibration_params
486486
)
487487

488-
from pytools.obj_array import obj_array_vectorize
489-
from functools import partial
488+
from pytools import obj_array
490489
return (
491-
obj_array_vectorize(
490+
obj_array.vectorize(
492491
partial(wrangler.finalize_potentials,
493492
template_ary=strengths[0]),
494493
wrangler.full_output_zeros(strengths[0])),
@@ -518,7 +517,6 @@ def _dispatch_compute_potential_insn(self, actx, insn, bound_expr,
518517

519518
@memoize_method
520519
def _tree_indep_data_for_wrangler(self, source_kernels, target_kernels):
521-
from functools import partial
522520
base_kernel = single_valued(kernel.get_base_kernel() for
523521
kernel in source_kernels)
524522
mpole_expn_class = \

pytential/qbx/fmm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ def output_zeros(self, template_ary):
143143

144144
nqbtl = self.geo_data.non_qbx_box_target_lists()
145145

146-
from pytools.obj_array import make_obj_array
147-
return make_obj_array([
146+
from pytools import obj_array
147+
return obj_array.new_1d([
148148
cl.array.zeros(
149149
template_ary.queue,
150150
nqbtl.nfiltered_targets,
@@ -596,8 +596,8 @@ def reorder_and_finalize_potentials(x):
596596
# potential back into a CL array.
597597
return wrangler.finalize_potentials(x[tree.sorted_target_ids], template_ary)
598598

599-
from pytools.obj_array import obj_array_vectorize
600-
result = obj_array_vectorize(
599+
from pytools import obj_array
600+
result = obj_array.vectorize(
601601
reorder_and_finalize_potentials, all_potentials_in_tree_order)
602602

603603
# }}}

pytential/qbx/fmmlib.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,16 @@ def output_zeros(self):
209209

210210
nqbtl = self.geo_data.non_qbx_box_target_lists()
211211

212-
from pytools.obj_array import make_obj_array
213-
return make_obj_array([
212+
from pytools import obj_array
213+
return obj_array.new_1d([
214214
np.zeros(nqbtl.nfiltered_targets, self.tree_indep.dtype)
215215
for k in self.tree_indep.outputs])
216216

217217
def full_output_zeros(self, template_ary):
218218
"""This includes QBX and non-QBX targets."""
219219

220-
from pytools.obj_array import make_obj_array
221-
return make_obj_array([
220+
from pytools import obj_array
221+
return obj_array.new_1d([
222222
np.zeros(self.tree.ntargets, self.tree_indep.dtype)
223223
for k in self.tree_indep.outputs])
224224

pytential/symbolic/compiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def _get_next_step(
394394

395395
# {{{ make sure results do not get discarded
396396

397-
from pytools.obj_array import obj_array_vectorize
397+
from pytools import obj_array
398398

399399
from pytential.symbolic.mappers import DependencyMapper
400400
dm = DependencyMapper(composite_leaves=False)
@@ -409,7 +409,7 @@ def remove_result_variable(result_expr):
409409
assert isinstance(var, Variable)
410410
discardable_vars.discard(var.name)
411411

412-
obj_array_vectorize(remove_result_variable, result)
412+
obj_array.vectorize(remove_result_variable, result)
413413

414414
# }}}
415415

pytential/symbolic/execution.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,8 @@ def unflatten(self, ary):
492492
components.append(component)
493493

494494
if self._operator_uses_obj_array:
495-
from pytools.obj_array import make_obj_array
496-
return make_obj_array(components)
495+
from pytools import obj_array
496+
return obj_array.new_1d(components)
497497
else:
498498
return components[0]
499499

@@ -651,8 +651,8 @@ def execute(code: Code, exec_mapper, pre_assign_check=None) -> np.ndarray:
651651
assert target in assignees
652652
context[target] = value
653653

654-
from pytools.obj_array import obj_array_vectorize
655-
return obj_array_vectorize(exec_mapper, code.result)
654+
from pytools import obj_array
655+
return obj_array.vectorize(exec_mapper, code.result)
656656

657657
# }}}
658658

@@ -967,8 +967,8 @@ def build_matrix(actx, places, exprs, input_exprs, domains=None,
967967
exprs = _prepare_expr(places, exprs, auto_where=auto_where)
968968

969969
if not (isinstance(exprs, np.ndarray) and exprs.dtype.char == "O"):
970-
from pytools.obj_array import make_obj_array
971-
exprs = make_obj_array([exprs])
970+
from pytools import obj_array
971+
exprs = obj_array.new_1d([exprs])
972972

973973
try:
974974
input_exprs = list(input_exprs)

0 commit comments

Comments
 (0)