diff --git a/.basedpyright/baseline.json b/.basedpyright/baseline.json index 266f4680..dcc706ef 100644 --- a/.basedpyright/baseline.json +++ b/.basedpyright/baseline.json @@ -35504,50 +35504,50 @@ } }, { - "code": "reportUnknownArgumentType", + "code": "reportUnknownMemberType", "range": { - "startColumn": 21, - "endColumn": 34, + "startColumn": 4, + "endColumn": 17, "lineCount": 1 } }, { - "code": "reportUnknownMemberType", + "code": "reportUnknownArgumentType", "range": { - "startColumn": 8, - "endColumn": 21, + "startColumn": 42, + "endColumn": 52, "lineCount": 1 } }, { "code": "reportUnknownArgumentType", "range": { - "startColumn": 46, - "endColumn": 56, + "startColumn": 25, + "endColumn": 38, "lineCount": 1 } }, { - "code": "reportUnknownArgumentType", + "code": "reportUnknownMemberType", "range": { - "startColumn": 21, - "endColumn": 34, + "startColumn": 4, + "endColumn": 17, "lineCount": 1 } }, { - "code": "reportUnknownMemberType", + "code": "reportUnknownArgumentType", "range": { - "startColumn": 8, - "endColumn": 21, + "startColumn": 41, + "endColumn": 51, "lineCount": 1 } }, { "code": "reportUnknownArgumentType", "range": { - "startColumn": 45, - "endColumn": 55, + "startColumn": 25, + "endColumn": 38, "lineCount": 1 } }, diff --git a/boxtree/cost.py b/boxtree/cost.py index 6ef512f4..2c451d33 100644 --- a/boxtree/cost.py +++ b/boxtree/cost.py @@ -244,7 +244,6 @@ def process_form_multipoles(self, actx: ArrayContext, :return: an array of shape (nsource_boxes,), with each entry represents the cost of the box. """ - pass @abstractmethod def process_coarsen_multipoles(self, actx: ArrayContext, @@ -261,7 +260,6 @@ def process_coarsen_multipoles(self, actx: ArrayContext, immediate clear how per-box cost of upward propagation will be useful for distributed load balancing. """ - pass @abstractmethod def get_ndirect_sources_per_target_box(self, actx: ArrayContext, @@ -273,7 +271,6 @@ def get_ndirect_sources_per_target_box(self, actx: ArrayContext, :return: an array of shape (ntarget_boxes,), with each entry representing the number of direct evaluation sources for that target box. """ - pass @abstractmethod def process_direct(self, actx: ArrayContext, @@ -294,7 +291,6 @@ def process_direct(self, actx: ArrayContext, :return: an array of shape (ntarget_boxes,), with each entry represents the cost of the box. """ - pass @abstractmethod def process_list2(self, actx: ArrayContext, traversal, m2l_cost): @@ -306,7 +302,6 @@ def process_list2(self, actx: ArrayContext, traversal, m2l_cost): each entry representing the cost of multipole-to-local translations to this box. """ - pass @abstractmethod def process_list3(self, actx: ArrayContext, traversal, m2p_cost, @@ -324,7 +319,6 @@ def process_list3(self, actx: ArrayContext, traversal, m2p_cost, cost of evaluating all targets inside this box from multipole expansions of list-3 boxes. """ - pass @abstractmethod def process_list4(self, actx: ArrayContext, traversal, p2l_cost): @@ -337,7 +331,6 @@ def process_list4(self, actx: ArrayContext, traversal, p2l_cost): each entry representing the cost of point-to-local translations to this box. """ - pass @abstractmethod def process_eval_locals(self, actx: ArrayContext, traversal, l2p_cost, @@ -354,7 +347,6 @@ def process_eval_locals(self, actx: ArrayContext, traversal, l2p_cost, :return: an array of shape (ntarget_boxes,), the cost of evaluating the potentials of all targets inside this box from its local expansion. """ - pass @abstractmethod def process_refine_locals(self, actx: ArrayContext, traversal, l2l_cost): @@ -370,7 +362,6 @@ def process_refine_locals(self, actx: ArrayContext, traversal, l2l_cost): immediate clear how per-box cost of downward propagation will be useful for distributed load balancing. """ - pass @abstractmethod def aggregate_over_boxes(self, actx: ArrayContext, per_box_result): @@ -379,7 +370,6 @@ def aggregate_over_boxes(self, actx: ArrayContext, per_box_result): :arg per_box_result: an array to be sumed. :return: a :class:`float`, the result of the sum. """ - pass @staticmethod def cost_factors_to_dev(cost_factors, actx: ArrayContext | None): @@ -451,7 +441,6 @@ def zero_cost_per_box(self, actx: ArrayContext, nboxes): :param nboxes: the number of boxes :return: an array of shape (*nboxes*,), representing the zero per-box cost. """ - pass def cost_per_box(self, actx: ArrayContext, traversal, level_to_order, calibration_params, diff --git a/boxtree/fmm.py b/boxtree/fmm.py index dcad1f8b..b155a3cb 100644 --- a/boxtree/fmm.py +++ b/boxtree/fmm.py @@ -337,7 +337,6 @@ def communicate_mpoles(self, # noqa: B027 :returns: Statistics of the communication if *return_stats* is True. *None* otherwise. """ - pass # }}} diff --git a/boxtree/pyfmmlib_integration.py b/boxtree/pyfmmlib_integration.py index 5980bb97..db533d47 100644 --- a/boxtree/pyfmmlib_integration.py +++ b/boxtree/pyfmmlib_integration.py @@ -43,8 +43,7 @@ import numpy as np -import pytools.obj_array as obj_array -from pytools import log_process, memoize_method +from pytools import log_process, memoize_method, obj_array from boxtree.fmm import ExpansionWranglerInterface, TreeIndependentDataForWrangler diff --git a/boxtree/tools.py b/boxtree/tools.py index ce2c3791..cf0762b5 100644 --- a/boxtree/tools.py +++ b/boxtree/tools.py @@ -893,7 +893,7 @@ def run_mpi(script: str, num_processes: int, env: dict[str, Any]) -> None: def get_coord_vec_dtype( coord_dtype: np.dtype, dimensions: int) -> np.dtype: - import pyopencl.cltypes as cltypes + from pyopencl import cltypes if dimensions == 1: return coord_dtype else: diff --git a/boxtree/tree.py b/boxtree/tree.py index b36a459b..60bc17f5 100644 --- a/boxtree/tree.py +++ b/boxtree/tree.py @@ -272,8 +272,7 @@ def bounding_box(self) -> tuple[np.ndarray, np.ndarray]: def get_box_size(self, ibox): lev = self.box_levels[ibox] - box_size = self.root_extent * 0.5**lev - return box_size + return self.root_extent * 0.5**lev def get_box_extent(self, ibox): box_size = self.get_box_size(ibox) @@ -1059,7 +1058,7 @@ def get_filter_target_lists_in_user_order_kernel(self, particle_id_dtype, from boxtree.tools import VectorArg - builder = ListOfListsBuilder(self.context, + return ListOfListsBuilder(self.context, [("filt_tgt_list", particle_id_dtype)], Template("""//CL// typedef ${dtype_to_ctype(particle_id_dtype)} particle_id_t; @@ -1087,8 +1086,6 @@ def get_filter_target_lists_in_user_order_kernel(self, particle_id_dtype, VectorArg(particle_id_dtype, "box_target_counts_nonchild"), ]) - return builder - def filter_target_lists_in_user_order(self, actx, tree, flags): """ :arg flags: an array of length :attr:`boxtree.Tree.ntargets` of diff --git a/boxtree/tree_build_kernels.py b/boxtree/tree_build_kernels.py index a6b27af8..373b5930 100644 --- a/boxtree/tree_build_kernels.py +++ b/boxtree/tree_build_kernels.py @@ -165,11 +165,11 @@ def make_morton_bin_count_type(device, dimensions, particle_id_dtype, fields.append(("nonchild_srcntgts", particle_id_dtype)) from boxtree.tools import padded_bin - for mnr in range(2**dimensions): - fields.append((f"pcnt{padded_bin(mnr, dimensions)}", particle_id_dtype)) + fields.extend((f"pcnt{padded_bin(mnr, dimensions)}", particle_id_dtype) + for mnr in range(2**dimensions)) # Morton bin weight totals - for mnr in range(2**dimensions): - fields.append((f"pwt{padded_bin(mnr, dimensions)}", refine_weight_dtype)) + fields.extend((f"pwt{padded_bin(mnr, dimensions)}", refine_weight_dtype) + for mnr in range(2**dimensions)) dtype = np.dtype(fields) diff --git a/pyproject.toml b/pyproject.toml index 451c7b62..e1382e73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -116,6 +116,8 @@ required-imports = ["from __future__ import annotations"] [tool.ruff.lint.per-file-ignores] "doc/**/*.py" = ["I002"] "examples/**/*.py" = ["I002"] +"test/test_*.py" = ["S102"] +"doc/conf.py" = ["S102"] [tool.typos.default] extend-ignore-re = [ diff --git a/test/test_cost_model.py b/test/test_cost_model.py index 04b419af..50ed8fa1 100644 --- a/test/test_cost_model.py +++ b/test/test_cost_model.py @@ -583,11 +583,9 @@ def test_cost_model_op_counts_agree_with_constantone_wrangler( if not timing_data: return - mismatches = [] - for stage in timing_data: - if timing_data[stage]["ops_elapsed"] != modeled_time[stage]: - mismatches.append( - (stage, timing_data[stage]["ops_elapsed"], modeled_time[stage])) + mismatches = [(stage, timing_data[stage]["ops_elapsed"], modeled_time[stage]) + for stage in timing_data + if timing_data[stage]["ops_elapsed"] != modeled_time[stage]] assert not mismatches, "\n".join(str(s) for s in mismatches) diff --git a/test/test_fmm.py b/test/test_fmm.py index 1d6bbcb2..e9164e29 100644 --- a/test/test_fmm.py +++ b/test/test_fmm.py @@ -158,7 +158,6 @@ def _get_target_slice(self, ibox): (2, 10**5, None, "", p_normal, p_normal, "tree", "linf", "static_linf"), (3, 5 * 10**5, 4*10**4, "t", p_normal, p_normal, "tree", "linf", "static_linf"), # noqa: E501 - (3, 5 * 10**5, 4*10**4, "t", p_normal, p_normal, None, "linf", "static_linf"), # noqa: E501 (3, 5 * 10**5, 4*10**4, "t", p_normal, p_normal, None, "linf", "precise_linf"), # noqa: E501 (3, 5 * 10**5, 4*10**4, "t", p_normal, p_normal, None, "l2", "precise_linf"), # noqa: E501 (3, 5 * 10**5, 4*10**4, "t", p_normal, p_normal, None, "l2", "static_l2"), diff --git a/test/test_traversal.py b/test/test_traversal.py index 298cb3a4..96fc586d 100644 --- a/test/test_traversal.py +++ b/test/test_traversal.py @@ -29,8 +29,8 @@ import numpy.linalg as la import pytest -import pytools.obj_array as obj_array from arraycontext import pytest_generate_tests_for_array_contexts +from pytools import obj_array from boxtree.array_context import ( PytestPyOpenCLArrayContextFactory, diff --git a/test/test_tree.py b/test/test_tree.py index 57b17de4..edb1ba45 100644 --- a/test/test_tree.py +++ b/test/test_tree.py @@ -226,9 +226,7 @@ def run_build_test(builder, actx, dims, dtype, nparticles, visualize, def particle_tree_test_decorator(f): f = pytest.mark.opencl(f) f = pytest.mark.parametrize("dtype", [np.float64, np.float32])(f) - f = pytest.mark.parametrize("dims", [2, 3])(f) - - return f + return pytest.mark.parametrize("dims", [2, 3])(f) @particle_tree_test_decorator diff --git a/test/test_tree_of_boxes.py b/test/test_tree_of_boxes.py index 51a1e1be..109ec052 100644 --- a/test/test_tree_of_boxes.py +++ b/test/test_tree_of_boxes.py @@ -29,7 +29,6 @@ import numpy as np import pytest -import pytools.obj_array as obj_array from arraycontext import pytest_generate_tests_for_array_contexts # This means boxtree's tests have a hard dependency on meshmode. That's OK. @@ -38,6 +37,7 @@ PyOpenCLArrayContext, PytestPyOpenCLArrayContextFactory, ) +from pytools import obj_array from boxtree import ( make_meshmode_mesh_from_leaves,