def test_recurrent_mech_system_auto_change(self): R = RecurrentTransferMechanism(size=4, auto=[1, 2, 3, 4], hetero=-1) T = TransferMechanism(size=3, function=Linear) p = Process(size=4, pathway=[R, T], prefs=TestRecurrentTransferMechanismInSystem.simple_prefs) s = System(processes=[p], prefs=TestRecurrentTransferMechanismInSystem.simple_prefs) s.run(inputs={R: [[1, 2, 3, 4]]}) np.testing.assert_allclose(R.value, [[1., 2., 3., 4.]]) np.testing.assert_allclose(T.value, [[10., 10., 10.]]) R.auto = 0 s.run(inputs={R: [[5, 6, 7, 8]]}) np.testing.assert_allclose(R.value, [[-4, -2, 0, 2]]) np.testing.assert_allclose(T.value, [[-4, -4, -4]]) R.recurrent_projection.auto = [1, 1, 2, 4] s.run(inputs={R: [[12, 11, 10, 9]]}) np.testing.assert_allclose(R.value, [[8, 11, 14, 23]]) np.testing.assert_allclose(T.value, [[56, 56, 56]])
def test_recurrent_mech_system_auto_and_hetero_change(self): R = RecurrentTransferMechanism(size=4, auto=[1, 2, 3, 4], hetero=[[-1, -2, -3, -4]] * 4) T = TransferMechanism(size=5, function=Linear) p = Process(size=4, pathway=[R, T], prefs=TestRecurrentTransferMechanismInSystem.simple_prefs) s = System(processes=[p], prefs=TestRecurrentTransferMechanismInSystem.simple_prefs) s.run(inputs={R: [[1, 2, 3, -0.5]]}) np.testing.assert_allclose(R.value, [[1., 2., 3., -0.5]]) np.testing.assert_allclose(T.value, [[5.5, 5.5, 5.5, 5.5, 5.5]]) R.hetero = 0 s.run(inputs={R: [[-1.5, 0, 1, 2]]}) np.testing.assert_allclose(R.value, [[-.5, 4, 10, 0]]) np.testing.assert_allclose(T.value, [[13.5, 13.5, 13.5, 13.5, 13.5]]) R.auto = [0, 0, 0, 0] s.run(inputs={R: [[12, 11, 10, 9]]}) np.testing.assert_allclose(R.value, [[12, 11, 10, 9]]) np.testing.assert_allclose(T.value, [[42, 42, 42, 42, 42]])