diff --git a/psyneulink/core/components/component.py b/psyneulink/core/components/component.py index 2b793b1f026..117558c96d7 100644 --- a/psyneulink/core/components/component.py +++ b/psyneulink/core/components/component.py @@ -3844,21 +3844,14 @@ def _update_parameter_components(self, context=None): # store all Components in Parameters to be used in # _dependent_components for _initialize_from_context for p in self.parameters: + param_value = p._get(context) try: - param_value = p._get(context) - try: - param_value = param_value.__self__ - except AttributeError: - pass + param_value = param_value.__self__ + except AttributeError: + pass - if isinstance(param_value, Component) and param_value is not self: - self._parameter_components.add(param_value) - # ControlMechanism and GatingMechanism have Parameters that only - # throw these errors - except Exception as e: - # cannot import the specific exceptions due to circularity - if 'attribute is not implemented on' not in str(e): - raise + if isinstance(param_value, Component) and param_value is not self: + self._parameter_components.add(param_value) @property def _dependent_components(self): diff --git a/psyneulink/core/components/mechanisms/modulatory/control/gating/gatingmechanism.py b/psyneulink/core/components/mechanisms/modulatory/control/gating/gatingmechanism.py index ff8ae5ac1b5..dbf03790b30 100644 --- a/psyneulink/core/components/mechanisms/modulatory/control/gating/gatingmechanism.py +++ b/psyneulink/core/components/mechanisms/modulatory/control/gating/gatingmechanism.py @@ -227,29 +227,6 @@ class GatingMechanismError(Exception): def __init__(self, error_value): self.error_value = error_value -def _gating_allocation_getter(owning_component=None, context=None): - return owning_component.control_allocation - -def _gating_allocation_setter(value, owning_component=None, context=None): - owning_component.parameters.control_allocation._set(np.array(value), context) - return value - -# def _control_allocation_getter(owning_component=None, context=None): -# from psyneulink.core.components.mechanisms.modulatory.controlmechanism import ControlMechanism -# from psyneulink.core.components.ports.modulatorysignals.controlsignal import ControlSignal -# raise GatingMechanismError(f"'control_allocation' attribute is not implemented on {owning_component.name}; " -# f"consider using a {ControlMechanism.__name__} instead, " -# f"or a {ControlMechanism.__name__} if both {ControlSignal.__name__}s and " -# f"{GatingSignal.__name__}s are needed.") -# -# def _control_allocation_setter(value, owning_component=None, context=None, **kwargs): -# from psyneulink.core.components.mechanisms.modulatory.controlmechanism import ControlMechanism -# from psyneulink.core.components.ports.modulatorysignals.controlsignal import ControlSignal -# raise GatingMechanismError(f"'control_allocation' attribute is not implemented on {owning_component.name}; " -# f"consider using a {ControlMechanism.__name__} instead, " -# f"or a {ControlMechanism.__name__} if both {ControlSignal.__name__}s and " -# f"{GatingSignal.__name__}s are needed.") - class GatingMechanism(ControlMechanism): """ @@ -430,12 +407,9 @@ class Parameters(ControlMechanism.Parameters): :read only: True """ # This must be a list, as there may be more than one (e.g., one per control_signal) - value = Parameter(np.array([defaultGatingAllocation]), aliases='control_allocation', pnl_internal=True) - gating_allocation = Parameter( + value = Parameter( np.array([defaultGatingAllocation]), - getter=_gating_allocation_getter, - setter=_gating_allocation_setter, - read_only=True, + aliases=['control_allocation', 'gating_allocation'], pnl_internal=True )