コード例 #1
0
    def test_switch_mode(self):
        T = TransferMechanism(integrator_mode=True)
        P = Process(pathway=[T])
        S = System(processes=[P])
        integrator_function = T.integrator_function
        T.reinitialize_when = Never()
        # T starts with integrator_mode = True; confirm that T behaves correctly
        S.run({T: [[1.0], [1.0], [1.0]]})
        assert np.allclose(T.value, [[0.875]])

        assert T.integrator_mode is True
        assert T.integrator_function is integrator_function

        # Switch integrator_mode to False; confirm that T behaves correctly
        T.integrator_mode = False

        assert T.integrator_mode is False
        assert T.integrator_function is None

        S.run({T: [[1.0], [1.0], [1.0]]})
        assert np.allclose(T.value, [[1.0]])

        # Switch integrator_mode BACK to True; confirm that T picks up where it left off
        T.integrator_mode = True

        assert T.integrator_mode is True
        assert T.integrator_function is integrator_function

        S.run({T: [[1.0], [1.0], [1.0]]})
        assert np.allclose(T.value, [[0.984375]])