Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Add helper to generate power set and use it to test compiler debug options #2707

Merged
merged 2 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -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

Check notice

Code scanning / CodeQL

Module is imported with 'import' and 'import from'

Module 'psyneulink' is imported with both 'import' and 'import from'.
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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/llvm/test_debug_composition.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
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
from psyneulink.core.components.mechanisms.processing.integratormechanism import IntegratorMechanism
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"]
options_combinations = (";".join(("", *c)) for i in range(len(debug_options) + 1) for c in combinations(debug_options, i))
debug_options = ["const_input=[[[7]]]", "const_input", "const_params", "const_data", "const_state",
"stat", "time_stat", "unaligned_copy"]
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),
Expand Down