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 c272801f2ec..c6b14d420a2 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 @@ -10,7 +9,7 @@ from psyneulink.core.compositions.composition import Composition 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),