示例#1
0
 def test_default_name_and_projections_listing_for_input_state_in_constructor(
         self):
     T1 = TransferMechanism()
     my_input_state = InputState(projections=[T1])
     T2 = TransferMechanism(input_states=[my_input_state])
     assert T2.input_states[0].name == 'InputState-0'
     assert T2.input_states[0].projections[0].sender.name == 'RESULTS'
示例#2
0
 def test_name_assigned_before_error(self):
     name = 'target'
     with pytest.raises(StateError) as error_text:
         m = TransferMechanism(default_variable=[0, 0, 0])
         i = InputState(owner=m, name=name, variable=[0, 0, 0])
         TransferMechanism(input_states=[i])
     assert (belongs_to_another_mechanism_error_text in str(
         error_text.value) and 'Attempt to assign a State ({})'.format(name)
             in str(error_text.value))
示例#3
0
 def test_add_input_state_with_projection_by_assigning_owner(self):
     T1 = TransferMechanism()
     T2 = TransferMechanism()
     InputState(owner=T2, projections=[T1])
     assert T2.input_states[1].path_afferents[0].sender.owner is T1
示例#4
0
 def test_add_input_state_with_projection_using_add_states(self):
     T1 = TransferMechanism()
     I = InputState(projections=[T1])
     T2 = TransferMechanism()
     T2.add_states([I])
     assert T2.input_states[1].path_afferents[0].sender.owner is T1
示例#5
0
 def test_add_input_state_with_projection_in_mech_constructor(self):
     T1 = TransferMechanism()
     I = InputState(projections=[T1])
     T2 = TransferMechanism(input_states=[I])
     assert T2.input_states[0].path_afferents[0].sender.owner is T1
示例#6
0
 def test_InputState_mismatches_default(self):
     with pytest.raises(MechanismError) as error_text:
         i = InputState(reference_value=[0, 0, 0])
         TransferMechanism(default_variable=[0, 0], input_states=[i])
     assert mismatches_default_variable_error_text in str(error_text.value)
示例#7
0
 def test_add_input_state_belonging_to_another_mech_error(self):
     with pytest.raises(StateError) as error_text:
         m = TransferMechanism(default_variable=[0, 0, 0])
         i = InputState(owner=m, variable=[0, 0, 0])
         TransferMechanism(input_states=[i])
     assert belongs_to_another_mechanism_error_text in str(error_text.value)
示例#8
0
# Princeton University licenses this file to You under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.  You may obtain a copy of the License at:
#     http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.

# ******************************************  GatingSignal *****************************************************
"""
Overview
--------

A GatingSignal is a type of `ModulatorySignal <ModulatorySignal>` that is specialized for use with a `GatingMechanism`
and one or more `GatingProjections <GatingProjection>`, to modify the `value <State_Base.value>`\\(s) of the
`InputState(s) <InputState>` and/or `OutputState(s) <OutputState>` to which they project. A GatingSignal receives the
value from the `gating_policy <GatingMechanism.gating_policy>` of the GatingMechanism to which it belongs,
and assigns that as the value of its `gating_signal <GatingSignal.gating_signal>` to its `GatingProjection(s)
<GatingProjection>`, each of which projects to an InputState or OutputState and is used to modulate the `value
<State_Base.value>` of that State.


.. _GatingSignal_Creation:

Creating a GatingSignal
-----------------------

A GatingSignal is created automatically whenever an `InputState` or `OutputState` of a `Mechanism <Mechanism>` is
specified for gating.  This can be done either in the **gating_signals** argument of the constructor for a
`GatingMechanism <GatingMechanism_GatingSignals>`, or in the `specification of projections <State_Projections>` to
the InputState or OutputState.  Although a GatingSignal can be created directly using its constructor (or any of the
other ways for `creating an OutputState <OutputStates_Creation>`), this is usually not necessary nor is it advisable,