Skip to content

Commit

Permalink
tests: Add multi dimensionality test
Browse files Browse the repository at this point in the history
  • Loading branch information
SamKG committed Oct 13, 2020
1 parent fce48ac commit 065d75f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/composition/test_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -7306,3 +7306,26 @@ def store_inputs():
)

assert np.allclose(check_inputs, [[[1.0, 2.0, 3.0], [1.0, 2.0, 3.0]]])

@pytest.mark.parametrize("shape",[
(2, 2),
(2, 2, 2),
(3, 3, 3, 3),
(3, 3, 3, 3, 3),
])
@pytest.mark.parametrize("mode", ['Python',
pytest.param('LLVMRun', marks=pytest.mark.llvm),
])
def test_multidim(self, shape, mode):
import numpy as np
a = pnl.ProcessingMechanism(name='a', function=pnl.Linear(slope=4), default_variable=np.ones(shape=shape))
comp = pnl.Composition()
comp.add_node(a)
input_list = {a: [np.ones(shape=shape)]}

res = comp.run(
inputs=input_list,
)
res = np.array(res)
assert res.shape == shape
assert np.allclose(res, np.ones(shape=shape)*4)

0 comments on commit 065d75f

Please sign in to comment.