diff --git a/Scripts/Examples/Gating-Mechanism. with UDF.py b/Scripts/Examples/Gating-Mechanism. with UDF.py index bf8e94f03f3..91d51d3fc83 100644 --- a/Scripts/Examples/Gating-Mechanism. with UDF.py +++ b/Scripts/Examples/Gating-Mechanism. with UDF.py @@ -1,5 +1,7 @@ import functools + import numpy as np + import psyneulink as pnl import psyneulink.core.components.functions.nonstateful.transferfunctions @@ -51,7 +53,7 @@ def my_sinusoidal_fct(input, # pnl.FUNCTION: my_sinusoidal_fct} output_ports={pnl.NAME: 'RESULTS USING UDF', # pnl.VARIABLE: (pnl.OWNER_VALUE, 0), - pnl.FUNCTION: psyneulink.core.components.functions.nonstateful.transferfunctions.Linear(slope=pnl.GATING) + pnl.FUNCTION: psyneulink.core.components.functions.nonstateful.transferfunctions.Linear(slope=pnl.GATE) # pnl.FUNCTION: pnl.Logistic(gain=pnl.GATING) # pnl.FUNCTION: my_linear_fct # pnl.FUNCTION: my_exp_fct diff --git a/psyneulink/core/components/mechanisms/modulatory/control/gating/gatingmechanism.py b/psyneulink/core/components/mechanisms/modulatory/control/gating/gatingmechanism.py index 99b07ffe4db..61cea19174d 100644 --- a/psyneulink/core/components/mechanisms/modulatory/control/gating/gatingmechanism.py +++ b/psyneulink/core/components/mechanisms/modulatory/control/gating/gatingmechanism.py @@ -188,7 +188,7 @@ from psyneulink.core.components.ports.port import _parse_port_spec from psyneulink.core.globals.defaults import defaultGatingAllocation from psyneulink.core.globals.keywords import \ - CONTROL, CONTROL_SIGNALS, GATE, GATING, GATING_PROJECTION, GATING_SIGNAL, GATING_SIGNALS, \ + CONTROL, CONTROL_SIGNALS, GATE, GATING_PROJECTION, GATING_SIGNAL, GATING_SIGNALS, \ INIT_EXECUTE_METHOD_ONLY, MONITOR_FOR_CONTROL, PORT_TYPE, PROJECTION_TYPE from psyneulink.core.globals.parameters import Parameter from psyneulink.core.globals.preferences.basepreferenceset import is_pref_set @@ -218,7 +218,7 @@ def _is_gating_spec(spec): GatingMechanism, ControlMechanism)): return True - elif isinstance(spec, str) and spec in {GATING, GATING_PROJECTION, GATING_SIGNAL}: + elif isinstance(spec, str) and spec in {GATE, GATING_PROJECTION, GATING_SIGNAL}: return True else: return False diff --git a/psyneulink/core/components/projections/modulatory/gatingprojection.py b/psyneulink/core/components/projections/modulatory/gatingprojection.py index 7b810775f4b..1c852bbea2c 100644 --- a/psyneulink/core/components/projections/modulatory/gatingprojection.py +++ b/psyneulink/core/components/projections/modulatory/gatingprojection.py @@ -110,7 +110,7 @@ from psyneulink.core.components.shellclasses import Mechanism, Process_Base from psyneulink.core.globals.context import ContextFlags from psyneulink.core.globals.keywords import \ - FUNCTION_OUTPUT_TYPE, GATING, GATING_MECHANISM, GATING_PROJECTION, GATING_SIGNAL, \ + FUNCTION_OUTPUT_TYPE, GATE, GATING_MECHANISM, GATING_PROJECTION, GATING_SIGNAL, \ INPUT_PORT, OUTPUT_PORT from psyneulink.core.globals.parameters import Parameter from psyneulink.core.globals.preferences.basepreferenceset import is_pref_set @@ -120,8 +120,8 @@ 'GATING_SIGNAL_PARAMS', 'GatingProjection', 'GatingProjectionError', ] -parameter_keywords.update({GATING_PROJECTION, GATING}) -projection_keywords.update({GATING_PROJECTION, GATING}) +parameter_keywords.update({GATING_PROJECTION, GATE}) +projection_keywords.update({GATING_PROJECTION, GATE}) GATING_SIGNAL_PARAMS = 'gating_signal_params' class GatingProjectionError(Exception): diff --git a/psyneulink/core/components/projections/projection.py b/psyneulink/core/components/projections/projection.py index 65b17b21e53..48e91ce5e49 100644 --- a/psyneulink/core/components/projections/projection.py +++ b/psyneulink/core/components/projections/projection.py @@ -133,7 +133,7 @@ as its the ControlProjection's `sender `. See `ControlMechanism_ControlSignals` for additional details. - * *GATING_PROJECTION* (or *GATING*) -- this can be used when specifying an `InputPort + * *GATING_PROJECTION* (or *GATE*) -- this can be used when specifying an `InputPort ` or an `OutputPort `, to create a default `GatingProjection` to the `Port `. If the GatingProjection's `sender ` cannot be inferred from the context in which this specification occurs, then its `initialization is deferred @@ -402,14 +402,14 @@ import typecheck as tc from psyneulink.core import llvm as pnlvm -from psyneulink.core.components.functions.nonstateful.transferfunctions import LinearMatrix from psyneulink.core.components.functions.function import get_matrix -from psyneulink.core.components.shellclasses import Mechanism, Process_Base, Projection, Port +from psyneulink.core.components.functions.nonstateful.transferfunctions import LinearMatrix from psyneulink.core.components.ports.modulatorysignals.modulatorysignal import _is_modulatory_spec from psyneulink.core.components.ports.port import PortError +from psyneulink.core.components.shellclasses import Mechanism, Process_Base, Projection, Port from psyneulink.core.globals.context import ContextFlags from psyneulink.core.globals.keywords import \ - CONTROL, CONTROL_PROJECTION, CONTROL_SIGNAL, EXPONENT, FUNCTION_PARAMS, GATING, GATING_PROJECTION, GATING_SIGNAL, \ + CONTROL, CONTROL_PROJECTION, CONTROL_SIGNAL, EXPONENT, FUNCTION_PARAMS, GATE, GATING_PROJECTION, GATING_SIGNAL, \ INPUT_PORT, LEARNING, LEARNING_PROJECTION, LEARNING_SIGNAL, \ MAPPING_PROJECTION, MATRIX, MATRIX_KEYWORD_SET, MECHANISM, \ MODEL_SPEC_ID_RECEIVER_MECH, MODEL_SPEC_ID_RECEIVER_PORT, MODEL_SPEC_ID_SENDER_MECH, MODEL_SPEC_ID_SENDER_PORT, \ @@ -443,7 +443,7 @@ CONTROL: CONTROL_PROJECTION, CONTROL_SIGNAL: CONTROL_PROJECTION, CONTROL_PROJECTION: CONTROL_PROJECTION, - GATING: GATING_PROJECTION, + GATE: GATING_PROJECTION, GATING_SIGNAL: GATING_PROJECTION, GATING_PROJECTION: GATING_PROJECTION } diff --git a/psyneulink/core/globals/keywords.py b/psyneulink/core/globals/keywords.py index 202680b6295..90cbfa7fe2f 100644 --- a/psyneulink/core/globals/keywords.py +++ b/psyneulink/core/globals/keywords.py @@ -52,7 +52,7 @@ 'FEEDBACK', 'FITZHUGHNAGUMO_INTEGRATOR_FUNCTION', 'FINAL', 'FLAGS', 'FULL', 'FULL_CONNECTIVITY_MATRIX', 'FUNCTION', 'FUNCTIONS', 'FUNCTION_COMPONENT_CATEGORY','FUNCTION_CHECK_ARGS', 'FUNCTION_OUTPUT_TYPE', 'FUNCTION_OUTPUT_TYPE_CONVERSION', 'FUNCTION_PARAMS', - 'GAIN', 'GAMMA_DIST_FUNCTION', 'GATE', 'GATING', 'GATING_MECHANISM', 'GATING_ALLOCATION', 'GATING_PROJECTION', + 'GAIN', 'GAMMA_DIST_FUNCTION', 'GATE', 'GATING_MECHANISM', 'GATING_ALLOCATION', 'GATING_PROJECTION', 'GATING_PROJECTION_PARAMS', 'GATING_PROJECTIONS', 'GATING_SIGNAL', 'GATING_SIGNAL_SPECS', 'GATING_SIGNALS', 'GAUSSIAN', 'GAUSSIAN_FUNCTION', 'GILZENRAT_INTEGRATOR_FUNCTION', 'GREATER_THAN', 'GREATER_THAN_OR_EQUAL', 'GRADIENT_OPTIMIZATION_FUNCTION', 'GRID_SEARCH_FUNCTION', @@ -779,7 +779,6 @@ def _is_metric(metric): # GatingMechanism GATE = 'gate' -GATING = 'gating' GATING_SIGNALS = 'gating_signals' GATING_SIGNAL_SPECS = 'GATING_SIGNAL_SPECS' GATED_PORTS = 'GATED_PORTS' @@ -788,7 +787,7 @@ def _is_metric(metric): MODULATORY_SPEC_KEYWORDS = {LEARNING, LEARNING_SIGNAL, LEARNING_PROJECTION, LEARNING_MECHANISM, CONTROL, CONTROL_SIGNAL, CONTROL_PROJECTION, CONTROL_MECHANISM, - GATING, GATING_SIGNAL, GATING_PROJECTION, GATING_MECHANISM} + GATE, GATING_SIGNAL, GATING_PROJECTION, GATING_MECHANISM} MODULATED_PARAMETER_PREFIX = 'mod_' diff --git a/tests/composition/test_gating.py b/tests/composition/test_gating.py index 21f787a6f89..486f1c04fbb 100644 --- a/tests/composition/test_gating.py +++ b/tests/composition/test_gating.py @@ -1,5 +1,6 @@ import numpy as np import pytest + import psyneulink as pnl @@ -19,7 +20,7 @@ def test_gating(benchmark, comp_mode): function=pnl.Linear(), output_ports={ pnl.NAME: 'RESULTS USING UDF', - pnl.FUNCTION: pnl.Linear(slope=pnl.GATING) + pnl.FUNCTION: pnl.Linear(slope=pnl.GATE) } ) diff --git a/tests/mechanisms/test_gating_mechanism.py b/tests/mechanisms/test_gating_mechanism.py index a57dae02a9f..2d1a59a35eb 100644 --- a/tests/mechanisms/test_gating_mechanism.py +++ b/tests/mechanisms/test_gating_mechanism.py @@ -1,15 +1,16 @@ import numpy as np + import psyneulink as pnl import psyneulink.core.components.functions.nonstateful.transferfunctions - -from psyneulink.core.components.functions.stateful.integratorfunctions import AccumulatorIntegrator from psyneulink.core.components.functions.nonstateful.transferfunctions import Logistic +from psyneulink.core.components.functions.stateful.integratorfunctions import AccumulatorIntegrator from psyneulink.core.components.mechanisms.modulatory.control.gating.gatingmechanism import GatingMechanism from psyneulink.core.components.mechanisms.processing.transfermechanism import TransferMechanism from psyneulink.core.components.projections.pathway.mappingprojection import MappingProjection +from psyneulink.core.compositions.composition import Composition from psyneulink.core.globals.keywords import \ DEFAULT_VARIABLE, FUNCTION, FUNCTION_PARAMS, INITIALIZER, RATE, VALUE -from psyneulink.core.compositions.composition import Composition + def test_gating_with_composition(): """Tests same configuration as control of InputPort in tests/mechansims/test_identicalness_of_control_and_gating @@ -131,7 +132,7 @@ def my_sinusoidal_fct( output_ports={ pnl.NAME: 'RESULTS USING UDF', # pnl.VARIABLE: (pnl.OWNER_VALUE, 0), - pnl.FUNCTION: psyneulink.core.components.functions.nonstateful.transferfunctions.Linear(slope=pnl.GATING) + pnl.FUNCTION: psyneulink.core.components.functions.nonstateful.transferfunctions.Linear(slope=pnl.GATE) } ) diff --git a/tests/projections/test_projection_specifications.py b/tests/projections/test_projection_specifications.py index 94c9b3ece06..583241c7aa0 100644 --- a/tests/projections/test_projection_specifications.py +++ b/tests/projections/test_projection_specifications.py @@ -355,7 +355,7 @@ def test_formats_for_control_specification_for_mechanism_and_function_params(sel 'ControlProjection for R-CONTROL[gain]' gating_spec_list = [ - pnl.GATING, + pnl.GATE, pnl.CONTROL, pnl.GATING_SIGNAL, pnl.CONTROL_SIGNAL, @@ -371,7 +371,7 @@ def test_formats_for_control_specification_for_mechanism_and_function_params(sel pnl.ControlMechanism, pnl.GatingMechanism(), pnl.ControlMechanism(), - (0.3, pnl.GATING), + (0.3, pnl.GATE), (0.3, pnl.CONTROL), (0.3, pnl.GATING_SIGNAL), (0.3, pnl.CONTROL_SIGNAL),