From c694bbe7625f030452147d7c6d8f863c182d8f07 Mon Sep 17 00:00:00 2001 From: Jan Vesely Date: Wed, 28 Jun 2023 22:36:54 -0400 Subject: [PATCH 1/2] tests/llvm/debug: Remove duplicate 'const_data' debug flag Reduces the number of test variants by half. Signed-off-by: Jan Vesely --- tests/llvm/test_debug_composition.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/llvm/test_debug_composition.py b/tests/llvm/test_debug_composition.py index 646a31a6a3d..ba6b18f8175 100644 --- a/tests/llvm/test_debug_composition.py +++ b/tests/llvm/test_debug_composition.py @@ -9,7 +9,8 @@ from psyneulink.core.components.mechanisms.processing.transfermechanism import TransferMechanism from psyneulink.core.compositions.composition import Composition -debug_options=["const_input=[[[7]]]", "const_input", "const_data", "const_params", "const_data", "const_state", "stat", "time_stat", "unaligned_copy"] +debug_options = ["const_input=[[[7]]]", "const_input", "const_params", "const_data", "const_state", + "stat", "time_stat", "unaligned_copy"] options_combinations = (";".join(("", *c)) for i in range(len(debug_options) + 1) for c in combinations(debug_options, i)) @pytest.mark.composition From f9346b7aa5c06f5495e4887435d5bd78b7838e7e Mon Sep 17 00:00:00 2001 From: Jan Vesely Date: Wed, 28 Jun 2023 22:40:55 -0400 Subject: [PATCH 2/2] tests: Add a helper to generate power set Use the new helper to test all combinations of debug flags. Signed-off-by: Jan Vesely --- conftest.py | 10 +++++++++- tests/llvm/test_debug_composition.py | 3 +-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/conftest.py b/conftest.py index 6d2037c7617..1afd0260209 100644 --- a/conftest.py +++ b/conftest.py @@ -1,12 +1,13 @@ import contextlib import doctest import io +import itertools import numpy as np -import psyneulink import pytest import re import sys +import psyneulink from psyneulink import clear_registry, primary_registries, torch_available from psyneulink.core import llvm as pnlvm from psyneulink.core.globals.utilities import set_global_seed @@ -246,6 +247,13 @@ def expand_np_ndarray(arr): results_list.extend(nested_elem) return results_list +@pytest.helpers.register +def power_set(s): + """Set of all potential subsets.""" + + vals = list(s) + return (c for l in range(len(vals) + 1) for c in itertools.combinations(vals, l)) + # flag when run from pytest # https://docs.pytest.org/en/stable/example/simple.html#detect-if-running-from-within-a-pytest-run diff --git a/tests/llvm/test_debug_composition.py b/tests/llvm/test_debug_composition.py index ba6b18f8175..84e981a4e7e 100644 --- a/tests/llvm/test_debug_composition.py +++ b/tests/llvm/test_debug_composition.py @@ -1,7 +1,6 @@ import numpy as np import os import pytest -from itertools import combinations from psyneulink.core import llvm as pnlvm from psyneulink.core.components.functions.nonstateful.transferfunctions import Linear @@ -11,7 +10,7 @@ debug_options = ["const_input=[[[7]]]", "const_input", "const_params", "const_data", "const_state", "stat", "time_stat", "unaligned_copy"] -options_combinations = (";".join(("", *c)) for i in range(len(debug_options) + 1) for c in combinations(debug_options, i)) +options_combinations = (";".join(c) for c in pytest.helpers.power_set(debug_options)) @pytest.mark.composition @pytest.mark.parametrize("mode", [pytest.param(pnlvm.ExecutionMode.LLVMRun, marks=pytest.mark.llvm),