-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: split core and psyneulink integration tests
- Loading branch information
Showing
8 changed files
with
1,185 additions
and
982 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
psyneulink >=0.9.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import pytest | ||
|
||
try: | ||
from psyneulink.core import llvm as pnlvm | ||
except Exception: | ||
# psyneulink unavailable | ||
pass | ||
else: | ||
def pytest_runtest_setup(item): | ||
if 'cuda' in item.keywords and not pnlvm.ptx_enabled: | ||
pytest.skip('PTX engine not enabled/available') | ||
|
||
def pytest_generate_tests(metafunc): | ||
if "comp_mode_no_llvm" in metafunc.fixturenames: | ||
modes = [ | ||
m for m in get_comp_execution_modes() | ||
if m.values[0] is not pnlvm.ExecutionMode.LLVM | ||
] | ||
metafunc.parametrize("comp_mode", modes) | ||
|
||
elif "comp_mode" in metafunc.fixturenames: | ||
metafunc.parametrize("comp_mode", get_comp_execution_modes()) | ||
|
||
def pytest_runtest_teardown(item): | ||
pnlvm.cleanup() | ||
|
||
@pytest.fixture | ||
def comp_mode_no_llvm(): | ||
# dummy fixture to allow 'comp_mode' filtering | ||
pass | ||
|
||
@pytest.helpers.register | ||
def get_comp_execution_modes(): | ||
return [ | ||
pytest.param(pnlvm.ExecutionMode.Python), | ||
pytest.param(pnlvm.ExecutionMode.LLVM, marks=pytest.mark.llvm), | ||
pytest.param(pnlvm.ExecutionMode.LLVMExec, marks=pytest.mark.llvm), | ||
pytest.param(pnlvm.ExecutionMode.LLVMRun, marks=pytest.mark.llvm), | ||
pytest.param(pnlvm.ExecutionMode.PTXExec, marks=[pytest.mark.llvm, pytest.mark.cuda]), | ||
pytest.param(pnlvm.ExecutionMode.PTXRun, marks=[pytest.mark.llvm, pytest.mark.cuda]) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
# importorskip/skipif module level does not provide reason for skipping | ||
try: | ||
import psyneulink as pnl | ||
except Exception as e: | ||
pnl_err = e | ||
else: | ||
pnl_err = None | ||
|
||
|
||
@pytest.mark.skipif( | ||
pnl_err is not None, reason=f'psyneulink error: {pnl_err}' | ||
) | ||
@pytest.mark.psyneulink | ||
class TestCondition: | ||
@pytest.mark.parametrize( | ||
'parameter, indices, default_variable, integration_rate, expected_results', | ||
[ | ||
('value', None, None, 1, [[[10]]]), | ||
('value', (0, 0), [[0, 0]], [1, 2], [[[10, 20]]]), | ||
('value', (0, 1), [[0, 0]], [1, 2], [[[5, 10]]]), | ||
('num_executions', pnl.TimeScale.TRIAL, None, 1, [[[10]]]), | ||
] | ||
) | ||
@pytest.mark.parametrize('threshold', [10, 10.0]) | ||
def test_Threshold_parameters( | ||
self, parameter, indices, default_variable, integration_rate, expected_results, threshold, | ||
): | ||
|
||
A = pnl.TransferMechanism( | ||
default_variable=default_variable, | ||
integrator_mode=True, | ||
integrator_function=pnl.SimpleIntegrator, | ||
integration_rate=integration_rate, | ||
) | ||
comp = pnl.Composition(pathways=[A]) | ||
|
||
comp.termination_processing = { | ||
pnl.TimeScale.TRIAL: pnl.Threshold(A, parameter, threshold, '>=', indices=indices) | ||
} | ||
|
||
comp.run(inputs={A: np.ones(A.defaults.variable.shape)}) | ||
|
||
np.testing.assert_array_equal(comp.results, expected_results) |
Oops, something went wrong.