def test_activation_matrix():
weights = xr.DataArray(np.array([[0, 1, 0], [1, 0, 0]]),
coords={
'outcomes': ['o1', 'o2'],
'cues': ['c1', 'c2', 'c3']
},
dims=('outcomes', 'cues'))
events = [(['c1', 'c2', 'c3'], []),
(['c1', 'c3'], []),
(['c2'], []),
(['c1', 'c1'], [])]
reference_activations = np.array([[1, 0, 1, 0], [1, 1, 0, 1]])
with pytest.raises(ValueError):
activations = activation(events, weights, number_of_threads=1)
activations = activation(events, weights, number_of_threads=1, remove_duplicates=True)
activations_mp = activation(events, weights, number_of_threads=3, remove_duplicates=True)
assert np.allclose(reference_activations, activations)
assert np.allclose(reference_activations, activations_mp)
评论列表
文章目录