Skip to content

Commit

Permalink
- pycodestyle corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
jdcpni committed Nov 3, 2021
1 parent 09de3fb commit 721fa0e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ def _report_value(self, new_value):


class GridBasedOptimizationFunction(OptimizationFunction):
"""Implement helper method for parallelizing instantiation for evaluating samples from search space """

"""Implement helper method for parallelizing instantiation for evaluating samples from search space."""
def _grid_evaluate(self, ocm, context):

assert ocm is ocm.agent_rep.controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,25 +560,26 @@
"""

import copy
import collections
import copy
import itertools
import numpy as np
import threading
import typecheck as tc
import uuid
import warnings

import numpy as np
import typecheck as tc

from psyneulink.core import llvm as pnlvm
from psyneulink.core.components.functions.function import Function_Base, is_function_type
from psyneulink.core.components.functions.nonstateful.combinationfunctions import LinearCombination
from psyneulink.core.components.mechanisms.modulatory.modulatorymechanism import ModulatoryMechanism_Base
from psyneulink.core.components.mechanisms.mechanism import Mechanism, Mechanism_Base
from psyneulink.core.components.ports.port import Port, _parse_port_spec
from psyneulink.core.components.ports.modulatorysignals.controlsignal import ControlSignal
from psyneulink.core.components.mechanisms.modulatory.modulatorymechanism import ModulatoryMechanism_Base
from psyneulink.core.components.ports.inputport import InputPort
from psyneulink.core.components.ports.modulatorysignals.controlsignal import ControlSignal
from psyneulink.core.components.ports.outputport import OutputPort
from psyneulink.core.components.ports.parameterport import ParameterPort
from psyneulink.core.components.ports.port import Port, _parse_port_spec
from psyneulink.core.globals.defaults import defaultControlAllocation
from psyneulink.core.globals.keywords import \
AUTO_ASSIGN_MATRIX, CONTROL, CONTROL_PROJECTION, CONTROL_SIGNAL, CONTROL_SIGNALS, \
Expand Down Expand Up @@ -1444,7 +1445,7 @@ def _instantiate_input_ports(self, input_ports=None, context=None):
# FIX: MODIFY TO CONSTRUCT MAPPING PROJECTION FROM EACH MONITOR_FOR_CONTROL SPEC TO CORRESPONDING INPUTPORT
from psyneulink.core.components.projections.pathway.mappingprojection import MappingProjection
for i, sender in enumerate(convert_to_list(self.monitor_for_control)):
input_port = self.input_ports[len_stim_input_ports+i]
input_port = self.input_ports[len_stim_input_ports + i]
input_port.name = sender.name.upper()
self.aux_components.append(MappingProjection(sender=sender, receiver=input_port))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@
from psyneulink.core.components.functions.nonstateful.optimizationfunctions import \
GridSearch, OBJECTIVE_FUNCTION, SEARCH_SPACE
from psyneulink.core.components.functions.nonstateful.transferfunctions import CostFunctions
from psyneulink.core.components.functions.nonstateful.combinationfunctions import Concatenate
from psyneulink.core.components.mechanisms.mechanism import Mechanism
from psyneulink.core.components.mechanisms.modulatory.control.controlmechanism import ControlMechanism
from psyneulink.core.components.ports.inputport import InputPort, _parse_shadow_inputs
Expand All @@ -453,8 +452,7 @@
from psyneulink.core.globals.context import handle_external_context
from psyneulink.core.globals.defaults import defaultControlAllocation
from psyneulink.core.globals.keywords import \
DEFAULT_VARIABLE, EID_FROZEN, FUNCTION, INTERNAL_ONLY, NAME, \
OPTIMIZATION_CONTROL_MECHANISM, OUTCOME, PARAMS, PROJECTIONS, SIZE
DEFAULT_VARIABLE, EID_FROZEN, FUNCTION, INTERNAL_ONLY, OPTIMIZATION_CONTROL_MECHANISM, PARAMS, PROJECTIONS
from psyneulink.core.globals.parameters import Parameter
from psyneulink.core.globals.preferences.preferenceset import PreferenceLevel
from psyneulink.core.globals.sampleiterator import SampleIterator, SampleSpec
Expand Down Expand Up @@ -993,8 +991,8 @@ def _instantiate_attributes_after_function(self, context=None):
self._initialize_composition_function_approximator(context)

def _execute(self, variable=None, context=None, runtime_params=None):
"""Find ``control_allocation <ControlMechanism.control_allocation>` that optimizes result of
`agent_rep.evaluate`."""
"""Find control_allocation that optimizes result of agent_rep.evaluate().
"""

if self.is_initializing:
return [defaultControlAllocation]
Expand Down
11 changes: 5 additions & 6 deletions psyneulink/core/compositions/parameterestimationcomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,16 @@
from psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism import \
OptimizationControlMechanism
from psyneulink.core.components.mechanisms.processing.objectivemechanism import ObjectiveMechanism
from psyneulink.core.components.ports.port import PortError
from psyneulink.core.components.ports.modulatorysignals.controlsignal import ControlSignal
from psyneulink.core.compositions.composition import Composition
from psyneulink.core.globals.keywords import BEFORE
from psyneulink.core.globals.context import Context
from psyneulink.core.globals.utilities import convert_to_list
from psyneulink.core.globals.keywords import BEFORE
from psyneulink.core.globals.sampleiterator import SampleSpec
from psyneulink.core.globals.utilities import convert_to_list

__all__ = ['ParameterEstimationComposition']

COMPOSITION_SPECIFICATION_ARGS = {'nodes', 'pathways', 'projections'}
COMPOSITION_SPECIFICATION_ARGS = {'nodes', 'pathways', 'projections'}
CONTROLLER_SPECIFICATION_ARGS = {'controller',
'enable_controller',
'controller_mode',
Expand Down Expand Up @@ -431,7 +430,7 @@ def __init__(self,
# If model has been specified, assign as (only) node in PEC, otherwise specification(s) in kwargs are used
# (Note: _validate_params() ensures that either model or nodes and/or pathways are specified, but not both)
kwargs.update({'nodes':model})
self.model = model or self
self.model = model or self

self.optimized_parameter_values = []

Expand Down Expand Up @@ -579,4 +578,4 @@ def evaluate(self,
# FIX: THIS NEEDS TO BE A DEQUE THAT TRACKS ALL THE CONTROL_SIGNAL VALUES OVER num_estimates FOR PARAM DISTRIB
# FIX: AUGMENT TO USE num_estimates and num_trials_per_estimate
# FIX: AUGMENT TO USE same_seed_for_all_parameter_combinations PARAMETER
return self.function(feature_values, control_allocation, context=context)
return self.function(feature_values, control_allocation, context=context)

0 comments on commit 721fa0e

Please sign in to comment.