Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ControlSignal: Do not recalculate costs on Port._update #2722

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ControlSignal.intensity>`)."""
# FIX 8/30/19: NEED TO DEAL WITH DURATION_COST AS STATEFUL: DON'T WANT TO MESS UP MAIN VALUE
Expand Down
2 changes: 1 addition & 1 deletion tests/composition/test_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, ,),
Expand Down