Skip to content

Commit

Permalink
tests/composition: Add multi dimensionality test
Browse files Browse the repository at this point in the history
  • Loading branch information
SamKG committed Oct 15, 2020
1 parent 7433f92 commit 1f7faf9
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),
])
def test_multidim(self, shape):
a = pnl.ProcessingMechanism(name='a', function=pnl.Linear(slope=4), default_variable=np.ones(shape=shape))
b = pnl.ProcessingMechanism(name='b', function=pnl.Linear(slope=4), default_variable=np.ones(shape=shape))
proj = pnl.MappingProjection(sender=a, receiver=b)
comp = pnl.Composition()
comp.add_node(a)
comp.add_node(b)
comp.add_projection(proj)
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 1f7faf9

Please sign in to comment.