Skip to content

Commit

Permalink
fix builder incompatibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl committed Sep 18, 2022
1 parent 189b9fc commit 5d1bb3e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 31 deletions.
12 changes: 9 additions & 3 deletions boxtree/area_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,11 @@ def __call__(self, actx: PyOpenCLArrayContext, tree: Tree,
"Use 'build_area_query' instead.",
DeprecationWarning, stacklevel=2)

return build_area_query(
result = build_area_query(
actx, tree, ball_centers, ball_radii, peer_lists)

return result, None


@dataclass_array_container
@dataclass(frozen=True)
Expand Down Expand Up @@ -749,9 +751,11 @@ def __call__(self, actx: PyOpenCLArrayContext, tree: Tree,
"Use 'build_leaves_to_balls_lookup' instead.",
DeprecationWarning, stacklevel=2)

return build_leaves_to_balls_lookup(
result = build_leaves_to_balls_lookup(
actx, tree, ball_centers, ball_radii, peer_lists)

return result, None


@dataclass_array_container
@dataclass(frozen=True)
Expand Down Expand Up @@ -886,9 +890,11 @@ def __call__(self,
"Use 'build_space_invader_query' instead.",
DeprecationWarning, stacklevel=2)

return build_space_invader_query(
result = build_space_invader_query(
actx, tree, ball_centers, ball_radii, peer_lists)

return result, None


@memoize_on_first_arg
def get_space_invader_query_kernel(
Expand Down
3 changes: 2 additions & 1 deletion boxtree/rotation_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def __call__(self, actx, trav, tree, wait_for=None):
"Use 'build_rotation_classes' instead.",
DeprecationWarning, stacklevel=2)

return build_rotation_classes(actx, trav, tree)
result = build_rotation_classes(actx, trav, tree)
return result, None


@dataclass_array_container
Expand Down
4 changes: 3 additions & 1 deletion boxtree/translation_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,12 @@ def __call__(self, actx: PyOpenCLArrayContext,
"Use 'build_rotation_classes' instead.",
DeprecationWarning, stacklevel=2)

return build_translation_classes(
result = build_translation_classes(
actx, trav, tree,
is_translation_per_level=is_translation_per_level)

return result, None


@dataclass_array_container
@dataclass(frozen=True)
Expand Down
37 changes: 17 additions & 20 deletions boxtree/traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1667,29 +1667,10 @@ class TraversalKernelInfo:


class FMMTraversalBuilder:
"""
.. automethod:: __init__
"""

def __init__(self,
array_context: PyOpenCLArrayContext, *,
well_sep_is_n_away: int = 1,
from_sep_smaller_crit: Optional[str] = None) -> None:
"""
:arg well_sep_is_n_away: Either An integer 1 or greater.
(Only 1 and 2 are tested.)
The spacing between boxes that is considered "well-separated" for
:attr:`boxtree.traversal.FMMTraversalInfo.from_sep_siblings_starts`
(List 2).
:arg from_sep_smaller_crit: The criterion used to determine separation
box dimensions and separation for
:attr:`boxtree.traversal.FMMTraversalInfo.from_sep_smaller_by_level`
(List 3). May be one of ``"static_linf"`` (use the box square,
possibly enlarged by :attr:`boxtree.Tree.stick_out_factor`),
``"precise_linf"`` (use the precise extent of targets in the box,
including their radii), or ``"static_l2"`` (use the circumcircle of
the box, possibly enlarged by :attr:`boxtree.Tree.stick_out_factor`).
"""
self._setup_actx = array_context
self.well_sep_is_n_away = well_sep_is_n_away
self.from_sep_smaller_crit = from_sep_smaller_crit
Expand All @@ -1704,7 +1685,7 @@ def __call__(self, actx: PyOpenCLArrayContext, tree: Tree,
"Use 'build_traversal' instead.",
DeprecationWarning, stacklevel=2)

return build_traversal(actx, tree,
result = build_traversal(actx, tree,
well_sep_is_n_away=self.well_sep_is_n_away,
from_sep_smaller_crit=self.from_sep_smaller_crit,
source_boxes_mask=source_boxes_mask,
Expand All @@ -1714,6 +1695,8 @@ def __call__(self, actx: PyOpenCLArrayContext, tree: Tree,
debug=debug,
)

return result, None


# {{{ traversal kernels

Expand Down Expand Up @@ -1937,11 +1920,25 @@ def build_traversal(
_from_sep_smaller_min_nsources_cumul=None,
debug: bool = False) -> FMMTraversalInfo:
"""
:arg well_sep_is_n_away: Either An integer 1 or greater.
(Only 1 and 2 are tested.)
The spacing between boxes that is considered "well-separated" for
:attr:`boxtree.traversal.FMMTraversalInfo.from_sep_siblings_starts`
(List 2).
:arg from_sep_smaller_crit: The criterion used to determine separation
box dimensions and separation for
:attr:`boxtree.traversal.FMMTraversalInfo.from_sep_smaller_by_level`
(List 3). May be one of ``"static_linf"`` (use the box square,
possibly enlarged by :attr:`boxtree.Tree.stick_out_factor`),
``"precise_linf"`` (use the precise extent of targets in the box,
including their radii), or ``"static_l2"`` (use the circumcircle of
the box, possibly enlarged by :attr:`boxtree.Tree.stick_out_factor`).
:arg source_boxes_mask: Only boxes passing this mask will be considered for
`source_boxes`. Used by the distributed implementation.
:arg source_parent_boxes_mask: Only boxes passing this mask will be
considered for `source_parent_boxes`. Used by the distributed
implementation.
:return: A :class:`tuple` *(trav, event)*, where *trav* is a new instance of
:class:`FMMTraversalInfo` and *event* is a :class:`pyopencl.Event`
for dependency management.
Expand Down
9 changes: 3 additions & 6 deletions boxtree/tree_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ class MaxLevelsExceeded(RuntimeError):


class TreeBuilder:
"""
.. automethod:: __init__
.. automethod:: __call__
"""

morton_nr_dtype = np.dtype(np.int8)
box_level_dtype = np.dtype(np.uint8)
ROOT_EXTENT_STRETCH_FACTOR = 1e-4
Expand All @@ -72,7 +67,7 @@ def __call__(self, actx: PyOpenCLArrayContext, particles, kind="adaptive",
"Use 'build_tree' instead.",
DeprecationWarning, stacklevel=2)

return build_tree(
result = build_tree(
actx, particles,
kind=kind, max_particles_in_box=max_particles_in_box,
targets=targets, source_radii=source_radii, target_radii=target_radii,
Expand All @@ -85,6 +80,8 @@ def __call__(self, actx: PyOpenCLArrayContext, particles, kind="adaptive",
root_extent_stretch_factor=TreeBuilder.ROOT_EXTENT_STRETCH_FACTOR,
debug=debug, **kwargs)

return result, None


# {{{ build_tree

Expand Down

0 comments on commit 5d1bb3e

Please sign in to comment.