diff --git a/loki/transformations/tests/test_hoist_variables.py b/loki/transformations/tests/test_hoist_variables.py index 6e2d5a1fb..b3d1eff91 100644 --- a/loki/transformations/tests/test_hoist_variables.py +++ b/loki/transformations/tests/test_hoist_variables.py @@ -16,7 +16,7 @@ Scheduler, SchedulerConfig, is_iterable, FindInlineCalls ) from loki.build import jit_compile_lib, Builder -from loki.frontend import available_frontends, OMNI +from loki.frontend import available_frontends from loki.ir import nodes as ir, FindNodes from loki.transformations.hoist_variables import ( HoistVariablesAnalysis, HoistVariablesTransformation, diff --git a/loki/transformations/tests/test_idempotence.py b/loki/transformations/tests/test_idempotence.py index a5fb1e524..4b4c84cb0 100644 --- a/loki/transformations/tests/test_idempotence.py +++ b/loki/transformations/tests/test_idempotence.py @@ -15,7 +15,7 @@ @pytest.mark.parametrize('frontend', available_frontends()) -def test_transform_idempotence(frontend, tmp_path): +def test_transform_idempotence(frontend): """ Test the do-nothing equivalence of :any:`IdemTransformations` """ fcode_driver = """ diff --git a/loki/transformations/tests/test_parametrise.py b/loki/transformations/tests/test_parametrise.py index 484b5bcd3..0f4de1466 100644 --- a/loki/transformations/tests/test_parametrise.py +++ b/loki/transformations/tests/test_parametrise.py @@ -356,7 +356,7 @@ def stop_execution(**kwargs): abort_callbacks = (error_stop, stop_execution) - for i, abort_callback in enumerate(abort_callbacks): + for _, abort_callback in enumerate(abort_callbacks): scheduler = Scheduler( paths=[proj], config=config, seed_routines=['driver', 'another_driver'], frontend=frontend, xmods=[tmp_path] @@ -380,8 +380,6 @@ def test_parametrise_modified_callback_wrong_input(tmp_path, testdir, frontend, proj = testdir/'sources/projParametrise' dic2p = {'a': 12, 'b': 11} - a = dic2p['a'] - b = dic2p['b'] def only_warn(**kwargs): msg = kwargs.get("msg") diff --git a/loki/transformations/tests/test_raw_stack_allocator.py b/loki/transformations/tests/test_raw_stack_allocator.py index fc9ed0822..49e6f2346 100644 --- a/loki/transformations/tests/test_raw_stack_allocator.py +++ b/loki/transformations/tests/test_raw_stack_allocator.py @@ -8,7 +8,7 @@ import pytest from loki.backend import fgen -from loki.batch import Scheduler, SchedulerConfig, ProcedureItem +from loki.batch import Scheduler, SchedulerConfig from loki.dimension import Dimension from loki.expression import DeferredTypeSymbol, InlineCall, IntLiteral from loki.frontend import available_frontends, OMNI diff --git a/loki/transformations/tests/test_transform_loop.py b/loki/transformations/tests/test_transform_loop.py index a2209f4c3..52c7dc571 100644 --- a/loki/transformations/tests/test_transform_loop.py +++ b/loki/transformations/tests/test_transform_loop.py @@ -13,7 +13,7 @@ from loki import Subroutine from loki.build import jit_compile, clean_test from loki.expression import symbols as sym -from loki.frontend import available_frontends, OMNI +from loki.frontend import available_frontends from loki.ir import ( is_loki_pragma, pragmas_attached, FindNodes, Loop, Conditional, Assignment @@ -1631,7 +1631,7 @@ def test_transform_loop_unroll(tmp_path, frontend): # Test the reference solution s = np.zeros(1) function(s=s) - assert s == sum([x + 1 for x in range(1, 11)]) + assert s == sum(x + 1 for x in range(1, 11)) # Apply transformation assert len(FindNodes(Loop).visit(routine.body)) == 1 @@ -1644,7 +1644,7 @@ def test_transform_loop_unroll(tmp_path, frontend): # Test transformation s = np.zeros(1) unrolled_function(s=s) - assert s == sum([x + 1 for x in range(1, 11)]) + assert s == sum(x + 1 for x in range(1, 11)) clean_test(filepath) clean_test(unrolled_filepath) @@ -1673,7 +1673,7 @@ def test_transform_loop_unroll_step(tmp_path, frontend): # Test the reference solution s = np.zeros(1) function(s=s) - assert s == sum([x + 1 for x in range(1, 11, 2)]) + assert s == sum(x + 1 for x in range(1, 11, 2)) # Apply transformation assert len(FindNodes(Loop).visit(routine.body)) == 1 @@ -1686,7 +1686,7 @@ def test_transform_loop_unroll_step(tmp_path, frontend): # Test transformation s = np.zeros(1) unrolled_function(s=s) - assert s == sum([x + 1 for x in range(1, 11, 2)]) + assert s == sum(x + 1 for x in range(1, 11, 2)) clean_test(filepath) clean_test(unrolled_filepath) @@ -1717,7 +1717,7 @@ def test_transform_loop_unroll_non_literal_range(tmp_path, frontend): # Test the reference solution s = np.zeros(1) function(s=s) - assert s == sum([x + 1 for x in range(1, 11)]) + assert s == sum(x + 1 for x in range(1, 11)) # Apply transformation assert len(FindNodes(Loop).visit(routine.body)) == 1 @@ -1730,7 +1730,7 @@ def test_transform_loop_unroll_non_literal_range(tmp_path, frontend): # Test transformation s = np.zeros(1) unrolled_function(s=s) - assert s == sum([x + 1 for x in range(1, 11)]) + assert s == sum(x + 1 for x in range(1, 11)) clean_test(filepath) clean_test(unrolled_filepath) @@ -1762,7 +1762,7 @@ def test_transform_loop_unroll_nested(tmp_path, frontend): # Test the reference solution s = np.zeros(1) function(s=s) - assert s == sum([a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))]) + assert s == sum(a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))) # Apply transformation assert len(FindNodes(Loop).visit(routine.body)) == 2 @@ -1775,7 +1775,7 @@ def test_transform_loop_unroll_nested(tmp_path, frontend): # Test transformation s = np.zeros(1) unrolled_function(s=s) - assert s == sum([a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))]) + assert s == sum(a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))) clean_test(filepath) clean_test(unrolled_filepath) @@ -1807,7 +1807,7 @@ def test_transform_loop_unroll_nested_restricted_depth(tmp_path, frontend): # Test the reference solution s = np.zeros(1) function(s=s) - assert s == sum([a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))]) + assert s == sum(a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))) # Apply transformation assert len(FindNodes(Loop).visit(routine.body)) == 2 @@ -1820,7 +1820,7 @@ def test_transform_loop_unroll_nested_restricted_depth(tmp_path, frontend): # Test transformation s = np.zeros(1) unrolled_function(s=s) - assert s == sum([a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))]) + assert s == sum(a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))) clean_test(filepath) clean_test(unrolled_filepath) @@ -1854,7 +1854,7 @@ def test_transform_loop_unroll_nested_restricted_depth_unrollable(tmp_path, fron # Test the reference solution s = np.zeros(1) function(s=s) - assert s == sum([a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))]) + assert s == sum(a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))) # Apply transformation assert len(FindNodes(Loop).visit(routine.body)) == 2 @@ -1867,7 +1867,7 @@ def test_transform_loop_unroll_nested_restricted_depth_unrollable(tmp_path, fron # Test transformation s = np.zeros(1) unrolled_function(s=s) - assert s == sum([a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))]) + assert s == sum(a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))) clean_test(filepath) clean_test(unrolled_filepath) @@ -1915,7 +1915,7 @@ def test_transform_loop_unroll_nested_counters(tmp_path, frontend): # Test transformation s = np.zeros(1) unrolled_function(s=s) - assert s == sum([a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 11)) if b <= a]) + assert s == sum(a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 11)) if b <= a) clean_test(filepath) clean_test(unrolled_filepath) @@ -1953,7 +1953,7 @@ def test_transform_loop_unroll_nested_neighbours(tmp_path, frontend): # Test the reference solution s = np.zeros(1) function(s=s) - assert s == 2 * sum([a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))]) + assert s == 2 * sum(a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))) # Apply transformation assert len(FindNodes(Loop).visit(routine.body)) == 3 loop_unroll(routine) @@ -1965,7 +1965,7 @@ def test_transform_loop_unroll_nested_neighbours(tmp_path, frontend): # Test transformation s = np.zeros(1) unrolled_function(s=s) - assert s == 2 * sum([a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))]) + assert s == 2 * sum(a + b + 1 for (a, b) in itertools.product(range(1, 11), range(1, 6))) clean_test(filepath) clean_test(unrolled_filepath) diff --git a/loki/transformations/tests/test_utilities.py b/loki/transformations/tests/test_utilities.py index a9241a6d5..cbacd60d3 100644 --- a/loki/transformations/tests/test_utilities.py +++ b/loki/transformations/tests/test_utilities.py @@ -502,22 +502,22 @@ def test_transform_utilites_get_local_arrays(frontend, tmp_path): module = Module.from_source(fcode, frontend=frontend, xmods=[tmp_path], definitions=(global_mod,)) routine = module['test_get_local_arrays'] - locals = get_local_arrays(routine, routine.body, unique=True) - assert len(locals) == 1 - assert locals[0] == 'local(i)' + local_arrs = get_local_arrays(routine, routine.body, unique=True) + assert len(local_arrs) == 1 + assert local_arrs[0] == 'local(i)' - locals = get_local_arrays(routine, routine.body, unique=False) - assert len(locals) == 2 - assert all(l == 'local(i)' for l in locals) + local_arrs = get_local_arrays(routine, routine.body, unique=False) + assert len(local_arrs) == 2 + assert all(l == 'local(i)' for l in local_arrs) - locals = get_local_arrays(routine, routine.body.body[-1:], unique=False) - assert len(locals) == 1 - assert locals[0] == 'local(i)' + local_arrs = get_local_arrays(routine, routine.body.body[-1:], unique=False) + assert len(local_arrs) == 1 + assert local_arrs[0] == 'local(i)' # Test for component arrays on arguments in spec - locals = get_local_arrays(routine, routine.spec, unique=True) - assert len(locals) == 1 - assert locals[0] == 'local(n)' + local_arrs = get_local_arrays(routine, routine.spec, unique=True) + assert len(local_arrs) == 1 + assert local_arrs[0] == 'local(n)' @pytest.mark.parametrize('frontend', available_frontends())