From 877378943ff46f6b42c9bf224a8070df229f44ec Mon Sep 17 00:00:00 2001 From: Jan Vesely Date: Fri, 7 Jul 2023 10:29:35 -0400 Subject: [PATCH] ControlSignal: Do not recalculate costs on Port._update The function (TransferWithCosts) calculates costs during execution. Partly closes: https://github.com/PrincetonUniversity/PsyNeuLink/issues/2721 Signed-off-by: Jan Vesely --- .../components/ports/modulatorysignals/controlsignal.py | 9 --------- tests/composition/test_control.py | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/psyneulink/core/components/ports/modulatorysignals/controlsignal.py b/psyneulink/core/components/ports/modulatorysignals/controlsignal.py index 93661da9129..95fcf458c5a 100644 --- a/psyneulink/core/components/ports/modulatorysignals/controlsignal.py +++ b/psyneulink/core/components/ports/modulatorysignals/controlsignal.py @@ -1077,15 +1077,6 @@ def _parse_port_specific_specs(self, owner, port_dict, port_specific_spec): return port_spec, params_dict - def _update(self, params=None, context=None): - """Update value (intensity) and costs - """ - super()._update(params=params, context=context) - - if self.parameters.cost_options._get(context): - intensity = self.parameters.value._get(context) - self.parameters.cost._set(self.compute_costs(intensity, context), context) - def compute_costs(self, intensity, context=None): """Compute costs based on self.value (`intensity `).""" # FIX 8/30/19: NEED TO DEAL WITH DURATION_COST AS STATEFUL: DON'T WANT TO MESS UP MAIN VALUE diff --git a/tests/composition/test_control.py b/tests/composition/test_control.py index a39b38cdb99..3b90e7d385e 100644 --- a/tests/composition/test_control.py +++ b/tests/composition/test_control.py @@ -2402,7 +2402,7 @@ def test_add_node_with_controller_spec_and_control_mech_but_not_a_controller(sel (pnl.CostFunctions.INTENSITY, 3, [0.2817181715409549, -3.3890560989306495, -15.085536923187664, -48.59815003314423, -141.41315910257657]), (pnl.CostFunctions.ADJUSTMENT, 3, [3, 3, 3, 3, 3] ), (pnl.CostFunctions.INTENSITY | pnl.CostFunctions.ADJUSTMENT, 3, [0.2817181715409549, -4.389056098930649, -17.085536923187664, -51.59815003314423, -145.41315910257657]), - (pnl.CostFunctions.DURATION, 3, [-17, -20, -23, -26, -29]), + (pnl.CostFunctions.DURATION, 3, [-7, -8, -9, -10, -11]), # FIXME: combinations with DURATION are broken # (pnl.CostFunctions.DURATION | pnl.CostFunctions.ADJUSTMENT, ,), # (pnl.CostFunctions.ALL, ,),