コード例 #1
0
ファイル: test_naming.py プロジェクト: uiuc-arc/PsyNeuLink
    def test_input_port_and_assigned_projection_names(self):
        T1 = pnl.TransferMechanism(name='T1')
        T2 = pnl.TransferMechanism(name='T2', input_ports=[T1])
        I1 = pnl.InputPort(owner=T2)
        I2 = pnl.InputPort(projections=[T1])
        assert I2.name == 'Deferred Init InputPort'
        T2.add_ports([I2])
        assert I1.name == 'InputPort-1'
        assert I2.name == 'InputPort-2'
        assert T2.input_ports[0].path_afferents[0].name == \
               'MappingProjection from T1[RESULT] to T2[InputPort-0]'
        assert T2.input_ports[2].path_afferents[0].name == \
               'MappingProjection from T1[RESULT] to T2[InputPort-2]'

        # ------------------------------------------------------------------------------------------------
        # TEST 10
        # Test that OutputPorts are properly named

        T1 = pnl.TransferMechanism(output_ports=['MY OUTPUT_PORT', [0]])
        assert T1.output_ports[0].name == 'MY OUTPUT_PORT'
        assert T1.output_ports[1].name == 'OutputPort-0'
        O = pnl.OutputPort(owner=T1)
        assert T1.output_ports[2].name == 'OutputPort-1'
        O2 = pnl.OutputPort()
        T1.add_ports([O2])
        assert T1.output_ports[3].name == 'OutputPort-2'
コード例 #2
0
 def test_internal_only(self):
     m = pnl.TransferMechanism(input_ports=[
         'EXTERNAL',
         pnl.InputPort(name='INTERNAL_ONLY', internal_only=True)
     ])
     assert m.input_values == [[0.], [0.]]
     assert m.external_input_values == [[0.]]
コード例 #3
0
 def test_combine_param_conflicting_fct_class_spec(self):
     with pytest.raises(pnl.InputPortError) as error_text:
         t = pnl.TransferMechanism(input_ports=pnl.InputPort(
             function=psyneulink.core.components.functions.nonstateful.
             transferfunctions.Linear,
             combine=pnl.PRODUCT))
     assert "Specification of 'combine' argument (PRODUCT) conflicts with Function specified " \
            "in 'function' argument (Linear) for InputPort" in str(error_text.value)
コード例 #4
0
 def test_combine_param_conflicting_fct_operation_spec(self):
     with pytest.raises(pnl.InputPortError) as error_text:
         t = pnl.TransferMechanism(input_ports=pnl.InputPort(
             function=psyneulink.core.components.functions.nonstateful.
             combinationfunctions.LinearCombination(operation=pnl.SUM),
             combine=pnl.PRODUCT))
     assert "Specification of 'combine' argument (PRODUCT) conflicts with specification of 'operation' (SUM) " \
            "for LinearCombination in 'function' argument for InputPort" in str(error_text.value)
コード例 #5
0
 def test_combine_param_alone(self):
     t1 = pnl.TransferMechanism(size=2)
     t2 = pnl.TransferMechanism(size=2)
     t3 = pnl.TransferMechanism(
         size=2, input_ports=pnl.InputPort(combine=pnl.PRODUCT))
     c = pnl.Composition(pathways=[[t1, t3], [t2, t3]])
     input_dict = {t1: [1, 2], t2: [3, 4]}
     val = c.run(inputs=input_dict)
     assert np.allclose(val, [[3, 8]])
コード例 #6
0
 def test_combine_param_redundant_fct_constructor_spec(self):
     t1 = pnl.TransferMechanism(size=2)
     t2 = pnl.TransferMechanism(size=2)
     t3 = pnl.TransferMechanism(
             size=2,
             input_ports=pnl.InputPort(function=psyneulink.core.components.functions.combinationfunctions.LinearCombination(operation=pnl.PRODUCT),
                                        combine=pnl.PRODUCT))
     p1 = pnl.Process(pathway=[t1, t3])
     p2 = pnl.Process(pathway=[t2, t3])
     s = pnl.System(processes=[p1,p2])
     input_dict = {t1:[1,2],t2:[3,4]}
     val = s.run(inputs=input_dict)
     assert np.allclose(val, [[3, 8]])
コード例 #7
0
 def test_combine_param_alone(self):
     t1 = pnl.TransferMechanism(size=2)
     t2 = pnl.TransferMechanism(size=2)
     t3 = pnl.TransferMechanism(
             size=2,
             input_ports=pnl.InputPort(
                     combine=pnl.PRODUCT))
     p1 = pnl.Process(pathway=[t1, t3])
     p2 = pnl.Process(pathway=[t2, t3])
     s = pnl.System(processes=[p1,p2])
     input_dict = {t1:[1,2],t2:[3,4]}
     val = s.run(inputs=input_dict)
     assert np.allclose(val, [[3, 8]])
コード例 #8
0
 def test_combine_param_redundant_fct_constructor_spec(self):
     t1 = pnl.TransferMechanism(size=2)
     t2 = pnl.TransferMechanism(size=2)
     t3 = pnl.TransferMechanism(
         size=2,
         input_ports=pnl.InputPort(
             function=psyneulink.core.components.functions.nonstateful.
             combinationfunctions.LinearCombination(operation=pnl.PRODUCT),
             combine=pnl.PRODUCT))
     c = pnl.Composition(pathways=[[t1, t3], [t2, t3]])
     input_dict = {t1: [1, 2], t2: [3, 4]}
     val = c.run(inputs=input_dict)
     assert np.allclose(val, [[3, 8]])
コード例 #9
0
activation.set_log_conditions([pnl.RESULT, "mod_gain"])

stimulusInfo = pnl.TransferMechanism(default_variable=[[0.0, 0.0]],
                                     size=2,
                                     function=pnl.Linear(slope=1, intercept=0),
                                     output_ports=[pnl.RESULT],
                                     name="Stimulus Info")

stimulusInfo.set_log_conditions([pnl.RESULT])

controlledElement = pnl.TransferMechanism(
    default_variable=[[0.0, 0.0]],
    size=2,
    function=pnl.Linear(slope=1, intercept=0),
    input_ports=pnl.InputPort(combine=pnl.PRODUCT),
    output_ports=[pnl.RESULT],
    name='Stimulus Info * Activity')

controlledElement.set_log_conditions([pnl.RESULT])

ddmCombination = pnl.TransferMechanism(size=1,
                                       function=pnl.Linear(slope=1,
                                                           intercept=0),
                                       output_ports=[pnl.RESULT],
                                       name="DDM Integrator")
ddmCombination.set_log_conditions([pnl.RESULT])

decisionMaker = pnl.DDM(
    function=pnl.DriftDiffusionAnalytical(drift_rate=DRIFT,
                                          starting_point=STARTING_POINT,