test_activation.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:pyndl 作者: quantling 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号