Skip to content

Commit

Permalink
• Project:
Browse files Browse the repository at this point in the history
  - CONTROL: 'CONTROL' -> 'control'
  - del GATING
  - GATE = 'gate"
  • Loading branch information
jdcpni committed Jan 3, 2022
1 parent 59e0f3d commit 0e1ebbe
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
4 changes: 3 additions & 1 deletion Scripts/Examples/Gating-Mechanism. with UDF.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import functools

import numpy as np

import psyneulink as pnl
import psyneulink.core.components.functions.nonstateful.transferfunctions

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
10 changes: 5 additions & 5 deletions psyneulink/core/components/projections/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
as its the ControlProjection's `sender <ControlProjection.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
<InputPort_Projection_Source_Specification>` or an `OutputPort <OutputPort_Projections>`, to create a
default `GatingProjection` to the `Port <Port>`. If the GatingProjection's `sender <GatingProjection.sender>`
cannot be inferred from the context in which this specification occurs, then its `initialization is deferred
Expand Down Expand Up @@ -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, \
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 2 additions & 3 deletions psyneulink/core/globals/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'
Expand All @@ -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_'

Expand Down
3 changes: 2 additions & 1 deletion tests/composition/test_gating.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import pytest

import psyneulink as pnl


Expand All @@ -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)
}
)

Expand Down
9 changes: 5 additions & 4 deletions tests/mechanisms/test_gating_mechanism.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
}
)

Expand Down
4 changes: 2 additions & 2 deletions tests/projections/test_projection_specifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down

0 comments on commit 0e1ebbe

Please sign in to comment.