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

Refactor/composition/ validate input keys #2361

Merged
merged 417 commits into from
Mar 28, 2022

Conversation

jdcpni
Copy link
Collaborator

@jdcpni jdcpni commented Mar 27, 2022

• composition.py:

  • _validate_input_dict_keys(): add method to validate keys of inputs to run() method
  • _get_input_receivers(): fix bug concerning inputs count

jdcpni and others added 30 commits December 2, 2021 17:32
  implemented test_shadow_nested_nodes that tests shadowing of nested nodes
…ttps://github.com/PrincetonUniversity/PsyNeuLink into refactor/ocm/state_input_ports_PROBE_STATE_FEAT_FCT

� Conflicts:
�	tests/composition/test_show_graph.py
…Link into refactor/ocm/state_input_ports_PROBE_STATE_FEAT_FCT

� Conflicts:
�	tests/composition/test_show_graph.py
…Link into devel

� Conflicts:
�	psyneulink/core/components/mechanisms/modulatory/control/optimizationcontrolmechanism.py
  - add allow_probes and exclude_probes_from_output
  - docstring mods re: allow_probes

• optimizationcontrolmechanism.py:
  - allow_probes:  eliminate DIRECT setting
  - remove _parse_monitor_for_control_input_ports (no longer needed without allow_probes=DIRECT)
  - change "exclude_probes_from_output" -> "include_probes_in_output"
  - docstring mods re: allow_probes and include_probes_in_output
  - docstring mods re: allow_probes and include_probes_in_output
  - add allow_probes handling (moved from OCM)

• optimizationcontrolmechanism.py:
  - move allow_probes to controlmechanism.py

• composition.py:
  - refactor handling of allow_probes to permit for any ControlMechanism

• objectivemechanism.py:
  - add modulatory_mechanism attribute
  - add allow_probes handling (moved from OCM)

• optimizationcontrolmechanism.py:
  - move allow_probes to controlmechanism.py

• composition.py:
  - refactor handling of allow_probes to permit for any ControlMechanism
  - add _handle_allow_probes_for_control() to reconcile setting on Composition and ControlMechanism

• objectivemechanism.py:
  - add modulatory_mechanism attribute
  add assignment of learning_mechanism to objective_mechanism.modulatory_mechanism for add_learning methods
  - add test_unnested_PROBE
  - add test_nested_PROBES
    TBD: test include_probes_in_output
  - fix bug in which state_feature_default = None was being ignored
  - fix bug in which deferred nodes were not being assigned state_feature_default
  - test_deferred_init, test_partial_deferred_init():
    added tests for controller.state_input_ports path_afferents
…Link into refactor/ocm/state_features_all_as_input_ports
  - _parse_state_feature_specs:
    - fixed bug in handling of lists of numeric specs
    - renamed state_input_ports for numeric specs
  - rename_instance_in_registry(): finish implementing (including **new_name** arg)

• optimizationcontrolmechanism.py:
  - _update_state_features_dict:  rename deferred state_input_ports
  - rename_instance_in_registry(): finish implementing (including **new_name** arg)

• optimizationcontrolmechanism.py:
  - _update_state_features_dict:  rename deferred state_input_ports
  - standarize prefixes for state_input_ports
  - standarize prefixes for state_input_ports
  - _show_structure(): fix parameterport label bug
…Link into refactor/ocm/state_features_all_as_input_ports
  _validate_input_keys(): add method to validate keys of inputs to run() method
  - _validate_input_keys(): add method to validate keys of inputs to run() method
  - _get_input_receivers(): fix bug concerning inputs count
@github-actions
Copy link

This PR causes the following changes to the html docs (ubuntu-latest-3.7-x64):

diff -r docs-base/Composition.html docs-head/Composition.html
223a224
> <li class="toctree-l1"><a class="reference internal" href="OptimizationControlMechanism.html">OptimizationControlMechanism</a></li>
4343,4358c4344,4345
< <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._validate_input_shapes">
< <span class="sig-name descname"><span class="pre">_validate_input_shapes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._validate_input_shapes" title="Permalink to this definition">¶</a></dt>
< <dd><p>Validates that all inputs provided in input dict are valid</p>
< <dl class="field-list simple">
< <dt class="field-odd">Returns</dt>
< <dd class="field-odd"><p>The input dict, with shapes corrected if necessary.</p>
< </dd>
< <dt class="field-even">Return type</dt>
< <dd class="field-even"><p><code class="xref any docutils literal notranslate"><span class="pre">dict</span></code></p>
< </dd>
< </dl>
< </dd></dl>
< 
< <dl class="py method">
< <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._flatten_nested_dicts">
< <span class="sig-name descname"><span class="pre">_flatten_nested_dicts</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._flatten_nested_dicts" title="Permalink to this definition">¶</a></dt>
---
> <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._parse_input_dict">
> <span class="sig-name descname"><span class="pre">_parse_input_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">context</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._parse_input_dict" title="Permalink to this definition">¶</a></dt>
4360c4347
< <dt>Converts inputs provided in the form of a dict for a nested Composition to a list corresponding to the</dt><dd><p>Composition’s input CIM ports</p>
---
> <dt>Validate and parse a dict provided as input to a Composition into a standardized form to be used throughout</dt><dd><p>its execution</p>
4365,4368c4352,4356
< <dd class="field-odd"><p>The input dict, with nested dicts corresponding to nested Compositions converted to lists</p>
< </dd>
< <dt class="field-even">Return type</dt>
< <dd class="field-even"><p><code class="xref any docutils literal notranslate"><span class="pre">dict</span></code></p>
---
> <dd class="field-odd"><p><ul class="simple">
> <li><p><code class="xref any docutils literal notranslate"><span class="pre">dict</span></code> – Parsed and standardized input dict</p></li>
> <li><p><code class="xref any docutils literal notranslate"><span class="pre">int</span></code> – Number of input sets (i.e., trials’ worths of inputs) in dict for each input node in the Composition</p></li>
> </ul>
> </p>
4389,4390c4377,4410
< <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._parse_input_dict">
< <span class="sig-name descname"><span class="pre">_parse_input_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">context</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._parse_input_dict" title="Permalink to this definition">¶</a></dt>
---
> <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._validate_input_dict_keys">
> <span class="sig-name descname"><span class="pre">_validate_input_dict_keys</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._validate_input_dict_keys" title="Permalink to this definition">¶</a></dt>
> <dd><p>Validate that keys of inputs are all legal:
> - they are all InputPorts, Mechanisms or Compositions;
> - they are all (or InputPorts of) INPUT Nodes of Composition at any level of nesting;
> - an InputPort and the Mechanism to which it belongs are not <em>both</em> specified;
> - an InputPort of an input_CIM and the Composition to which it belongs are not <em>both</em> specified;
> - an InputPort or Mechanism and any Composition under which it is nested are not <em>both</em> specified.</p>
> </dd></dl>
> 
> <dl class="py method">
> <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._instantiate_input_dict">
> <span class="sig-name descname"><span class="pre">_instantiate_input_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._instantiate_input_dict" title="Permalink to this definition">¶</a></dt>
> <dd><p>Implement dict with all INPUT Node of Composition as keys and their assigned inputs or defaults as values
> <strong>inputs</strong> can contain specifications for inputs to InputPorts, Mechanisms and/or nested Compositions,</p>
> <blockquote>
> <div><p>that can be at any level of nesting within self.</p>
> </div></blockquote>
> <p>Consolidate any entries of <strong>inputs</strong> with InputPorts as keys to Mechanism or Composition entries
> If any INPUT Nodes of Composition are not included, add them to the input_dict using their default values.
> InputPort entries must specify either a single trial or the same number as all other InPorts for that Node:</p>
> <blockquote>
> <div><ul class="simple">
> <li><p>preprocess InputPorts for a Node to determine maximum number of trials specified, and use to set mech_shape</p></li>
> <li><p>if more than one trial is specified for any InputPort, assign fillers to ones that specify only one trial</p></li>
> </ul>
> <p>(this does not apply to Mechanism or Composition specifications, as they are tested in validate_input_shapes)</p>
> </div></blockquote>
> <p>Return input_dict, with added entries for any INPUT Nodes or InputPorts for which input was not provided</p>
> </dd></dl>
> 
> <dl class="py method">
> <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._flatten_nested_dicts">
> <span class="sig-name descname"><span class="pre">_flatten_nested_dicts</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._flatten_nested_dicts" title="Permalink to this definition">¶</a></dt>
4392c4412
< <dt>Validate and parse a dict provided as input to a Composition into a standardized form to be used throughout</dt><dd><p>its execution</p>
---
> <dt>Converts inputs provided in the form of a dict for a nested Composition to a list corresponding to the</dt><dd><p>Composition’s input CIM ports</p>
4397,4401c4417,4420
< <dd class="field-odd"><p><ul class="simple">
< <li><p><code class="xref any docutils literal notranslate"><span class="pre">dict</span></code> – Parsed and standardized input dict</p></li>
< <li><p><code class="xref any docutils literal notranslate"><span class="pre">int</span></code> – Number of input sets (i.e., trials’ worths of inputs) in dict for each input node in the Composition</p></li>
< </ul>
< </p>
---
> <dd class="field-odd"><p>The input dict, with nested dicts corresponding to nested Compositions converted to lists</p>
> </dd>
> <dt class="field-even">Return type</dt>
> <dd class="field-even"><p><code class="xref any docutils literal notranslate"><span class="pre">dict</span></code></p>
4407,4417c4426,4428
< <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._instantiate_input_dict">
< <span class="sig-name descname"><span class="pre">_instantiate_input_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._instantiate_input_dict" title="Permalink to this definition">¶</a></dt>
< <dd><p>Implement dict with all INPUT Nodes of Composition as keys and their assigned inputs or defaults as values
< <strong>inputs</strong> can contain specifications for inputs to InputPorts, Mechanisms and/or nested Compositions,</p>
< <blockquote>
< <div><p>that can be at any level of nesting within self.</p>
< </div></blockquote>
< <p>Validate that all Nodes included in input dict are INPUT nodes of Composition.
< Consolidate any entries of <strong>inputs</strong> with InputPorts as keys to Mechanism or Composition entries
< If any INPUT nodes of Composition are not included, add them to the input_dict using their default values.
< Note: all entries must specify either a single trial’s worth of input, or the same number as all others.</p>
---
> <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._validate_input_shapes">
> <span class="sig-name descname"><span class="pre">_validate_input_shapes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._validate_input_shapes" title="Permalink to this definition">¶</a></dt>
> <dd><p>Validates that all inputs provided in input dict are valid</p>
4420c4431
< <dd class="field-odd"><p>Input dict, with added entries for any input Nodes or Ports for which input was not provided</p>
---
> <dd class="field-odd"><p>The input dict, with shapes corrected if necessary.</p>
diff -r docs-base/_sources/Composition.rst.txt docs-head/_sources/Composition.rst.txt
27a28
>        OptimizationControlMechanism
diff -r docs-base/genindex.html docs-head/genindex.html
956a957,958
>       <li><a href="Composition.html#psyneulink.core.compositions.composition.Composition._validate_input_dict_keys">_validate_input_dict_keys() (psyneulink.core.compositions.composition.Composition method)</a>
> </li>
Binary files docs-base/objects.inv and docs-head/objects.inv differ
diff -r docs-base/searchindex.js docs-head/searchindex.js
1c1
< Search.setIndex({docnames:["AGT","AGTControlMechanism","AutoAssociativeLearningMechanism","AutoAssociativeProjection","AutodiffComposition","BasicsAndPrimer","BotvinickConflictMonitoringModel","BustamanteStroopXORLVOCModel","Cohen_HustonModel","CombinationFunctions","ComparatorMechanism","Compilation","Component","Components","Composition","CompositionFunctionApproximator","CompositionInterfaceMechanism","Compositions","Condition","Context","ContrastiveHebbianMechanism","ContributorsGuide","ControlMechanism","ControlMechanisms","ControlProjection","ControlProjections","ControlSignal","ConventionsAndDefinitions","Core","DDM","DefaultControlMechanism","Defaults","DistributionFunctions","EVC","EVCAuxiliary","EVCControlMechanism","EpisodicMemoryMechanism","Function","Functions","GatingMechanism","GatingMechanisms","GatingProjection","GatingProjections","GatingSignal","GilzenratModel","InputPort","IntegratorFunctions","IntegratorMechanism","IntegratorMechanisms","KWTAMechanism","Keywords","KohonenMechanism","LCAMechanism","LCControlMechanism","LCMechanism","LeabraMechanism","LearningFunctions","LearningMechanism","LearningMechanisms","LearningProjection","LearningProjections","LearningSignal","Library","Log","MappingProjection","MaskedMappingProjection","Mechanism","Mechanisms","MemoryFunctions","Models","ModulatoryMechanism","ModulatoryMechanisms","ModulatoryProjection","ModulatoryProjections","ModulatorySignal","MontagueModel","NieuwenhuisModel","NonStatefulFunctions","ObjectiveFunctions","ObjectiveMechanism","ObjectiveMechanisms","OptimizationControlMechanism","OptimizationFunctions","OutputPort","PCTC_model","ParameterEstimationComposition","ParameterPort","Parameters","Pathway","PathwayProjection","PathwayProjections","Port","PredictionErrorMechanism","Preferences","ProcessingMechanism","ProcessingMechanisms","Projection","Projections","QuickReference","RecurrentTransferMechanism","RefactoredLearningGuide","Registry","RegressionCFA","Report","Scheduler","Scheduling","SelectionFunctions","Services","StatefulFunction","StatefulFunctions","Subystems","Time","TransferFunctions","TransferMechanism","TransferMechanisms","UserDefinedFunction","UserGuide","UserGuide_TBD","Visualization","globals","index","index_logo_with_text","mdf"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":4,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":3,"sphinx.domains.rst":2,"sphinx.domains.std":2,sphinx:56},filenames:["AGT.rst","AGTControlMechanism.rst","AutoAssociativeLearningMechanism.rst","AutoAssociativeProjection.rst","AutodiffComposition.rst","BasicsAndPrimer.rst","BotvinickConflictMonitoringModel.rst","BustamanteStroopXORLVOCModel.rst","Cohen_HustonModel.rst","CombinationFunctions.rst","ComparatorMechanism.rst","Compilation.rst","Component.rst","Components.rst","Composition.rst","CompositionFunctionApproximator.rst","CompositionInterfaceMechanism.rst","Compositions.rst","Condition.rst","Context.rst","ContrastiveHebbianMechanism.rst","ContributorsGuide.rst","ControlMechanism.rst","ControlMechanisms.rst","ControlProjection.rst","ControlProjections.rst","ControlSignal.rst","ConventionsAndDefinitions.rst","Core.rst","DDM.rst","DefaultControlMechanism.rst","Defaults.rst","DistributionFunctions.rst","EVC.rst","EVCAuxiliary.rst","EVCControlMechanism.rst","EpisodicMemoryMechanism.rst","Function.rst","Functions.rst","GatingMechanism.rst","GatingMechanisms.rst","GatingProjection.rst","GatingProjections.rst","GatingSignal.rst","GilzenratModel.rst","InputPort.rst","IntegratorFunctions.rst","IntegratorMechanism.rst","IntegratorMechanisms.rst","KWTAMechanism.rst","Keywords.rst","KohonenMechanism.rst","LCAMechanism.rst","LCControlMechanism.rst","LCMechanism.rst","LeabraMechanism.rst","LearningFunctions.rst","LearningMechanism.rst","LearningMechanisms.rst","LearningProjection.rst","LearningProjections.rst","LearningSignal.rst","Library.rst","Log.rst","MappingProjection.rst","MaskedMappingProjection.rst","Mechanism.rst","Mechanisms.rst","MemoryFunctions.rst","Models.rst","ModulatoryMechanism.rst","ModulatoryMechanisms.rst","ModulatoryProjection.rst","ModulatoryProjections.rst","ModulatorySignal.rst","MontagueModel.rst","NieuwenhuisModel.rst","NonStatefulFunctions.rst","ObjectiveFunctions.rst","ObjectiveMechanism.rst","ObjectiveMechanisms.rst","OptimizationControlMechanism.rst","OptimizationFunctions.rst","OutputPort.rst","PCTC_model.rst","ParameterEstimationComposition.rst","ParameterPort.rst","Parameters.rst","Pathway.rst","PathwayProjection.rst","PathwayProjections.rst","Port.rst","PredictionErrorMechanism.rst","Preferences.rst","ProcessingMechanism.rst","ProcessingMechanisms.rst","Projection.rst","Projections.rst","QuickReference.rst","RecurrentTransferMechanism.rst","RefactoredLearningGuide.rst","Registry.rst","RegressionCFA.rst","Report.rst","Scheduler.rst","Scheduling.rst","SelectionFunctions.rst","Services.rst","StatefulFunction.rst","StatefulFunctions.rst","Subystems.rst","Time.rst","TransferFunctions.rst","TransferMechanism.rst","TransferMechanisms.rst","UserDefinedFunction.rst","UserGuide.rst","UserGuide_TBD.rst","Visualization.rst","globals.rst","index.rst","i
...

See CI logs for the full diff.

@github-actions
Copy link

This PR causes the following changes to the html docs (ubuntu-latest-3.7-x64):

diff -r docs-base/Composition.html docs-head/Composition.html
223a224
> <li class="toctree-l1"><a class="reference internal" href="OptimizationControlMechanism.html">OptimizationControlMechanism</a></li>
4343,4358c4344,4345
< <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._validate_input_shapes">
< <span class="sig-name descname"><span class="pre">_validate_input_shapes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._validate_input_shapes" title="Permalink to this definition">¶</a></dt>
< <dd><p>Validates that all inputs provided in input dict are valid</p>
< <dl class="field-list simple">
< <dt class="field-odd">Returns</dt>
< <dd class="field-odd"><p>The input dict, with shapes corrected if necessary.</p>
< </dd>
< <dt class="field-even">Return type</dt>
< <dd class="field-even"><p><code class="xref any docutils literal notranslate"><span class="pre">dict</span></code></p>
< </dd>
< </dl>
< </dd></dl>
< 
< <dl class="py method">
< <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._flatten_nested_dicts">
< <span class="sig-name descname"><span class="pre">_flatten_nested_dicts</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._flatten_nested_dicts" title="Permalink to this definition">¶</a></dt>
---
> <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._parse_input_dict">
> <span class="sig-name descname"><span class="pre">_parse_input_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">context</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._parse_input_dict" title="Permalink to this definition">¶</a></dt>
4360c4347
< <dt>Converts inputs provided in the form of a dict for a nested Composition to a list corresponding to the</dt><dd><p>Composition’s input CIM ports</p>
---
> <dt>Validate and parse a dict provided as input to a Composition into a standardized form to be used throughout</dt><dd><p>its execution</p>
4365,4368c4352,4356
< <dd class="field-odd"><p>The input dict, with nested dicts corresponding to nested Compositions converted to lists</p>
< </dd>
< <dt class="field-even">Return type</dt>
< <dd class="field-even"><p><code class="xref any docutils literal notranslate"><span class="pre">dict</span></code></p>
---
> <dd class="field-odd"><p><ul class="simple">
> <li><p><code class="xref any docutils literal notranslate"><span class="pre">dict</span></code> – Parsed and standardized input dict</p></li>
> <li><p><code class="xref any docutils literal notranslate"><span class="pre">int</span></code> – Number of input sets (i.e., trials’ worths of inputs) in dict for each input node in the Composition</p></li>
> </ul>
> </p>
4389,4390c4377,4409
< <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._parse_input_dict">
< <span class="sig-name descname"><span class="pre">_parse_input_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">context</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._parse_input_dict" title="Permalink to this definition">¶</a></dt>
---
> <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._validate_input_keys">
> <span class="sig-name descname"><span class="pre">_validate_input_keys</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._validate_input_keys" title="Permalink to this definition">¶</a></dt>
> <dd><p>Validate that keys of inputs are all legal:
> - they are all InputPorts, Mechanisms or Compositions
> - they are all (or InputPorts of) INPUT Nodes of Composition at any level of nesting
> - an InputPort and the Mechanism to which it belongs are not <em>both</em> specified
> - an InputPort or Mechanism and any Composition under whicht it is nested are not <em>both</em> specified</p>
> </dd></dl>
> 
> <dl class="py method">
> <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._instantiate_input_dict">
> <span class="sig-name descname"><span class="pre">_instantiate_input_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._instantiate_input_dict" title="Permalink to this definition">¶</a></dt>
> <dd><p>Implement dict with all INPUT Node of Composition as keys and their assigned inputs or defaults as values
> <strong>inputs</strong> can contain specifications for inputs to InputPorts, Mechanisms and/or nested Compositions,</p>
> <blockquote>
> <div><p>that can be at any level of nesting within self.</p>
> </div></blockquote>
> <p>Consolidate any entries of <strong>inputs</strong> with InputPorts as keys to Mechanism or Composition entries
> If any INPUT Nodes of Composition are not included, add them to the input_dict using their default values.
> InputPort entries must specify either a single trial or the same number as all other InPorts for that Node:</p>
> <blockquote>
> <div><ul class="simple">
> <li><p>preprocess InputPorts for a Node to determine maximum number of trials specified, and use to set mech_shape</p></li>
> <li><p>if more than one trial is specified for any InputPort, assign fillers to ones that specify only one trial</p></li>
> </ul>
> <p>(this does not apply to Mechanism or Composition specifications, as they are tested in validate_input_shapes)</p>
> </div></blockquote>
> <p>Return input_dict, with added entries for any INPUT Nodes or InputPorts for which input was not provided</p>
> </dd></dl>
> 
> <dl class="py method">
> <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._flatten_nested_dicts">
> <span class="sig-name descname"><span class="pre">_flatten_nested_dicts</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._flatten_nested_dicts" title="Permalink to this definition">¶</a></dt>
4392c4411
< <dt>Validate and parse a dict provided as input to a Composition into a standardized form to be used throughout</dt><dd><p>its execution</p>
---
> <dt>Converts inputs provided in the form of a dict for a nested Composition to a list corresponding to the</dt><dd><p>Composition’s input CIM ports</p>
4397,4401c4416,4419
< <dd class="field-odd"><p><ul class="simple">
< <li><p><code class="xref any docutils literal notranslate"><span class="pre">dict</span></code> – Parsed and standardized input dict</p></li>
< <li><p><code class="xref any docutils literal notranslate"><span class="pre">int</span></code> – Number of input sets (i.e., trials’ worths of inputs) in dict for each input node in the Composition</p></li>
< </ul>
< </p>
---
> <dd class="field-odd"><p>The input dict, with nested dicts corresponding to nested Compositions converted to lists</p>
> </dd>
> <dt class="field-even">Return type</dt>
> <dd class="field-even"><p><code class="xref any docutils literal notranslate"><span class="pre">dict</span></code></p>
4407,4417c4425,4427
< <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._instantiate_input_dict">
< <span class="sig-name descname"><span class="pre">_instantiate_input_dict</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._instantiate_input_dict" title="Permalink to this definition">¶</a></dt>
< <dd><p>Implement dict with all INPUT Nodes of Composition as keys and their assigned inputs or defaults as values
< <strong>inputs</strong> can contain specifications for inputs to InputPorts, Mechanisms and/or nested Compositions,</p>
< <blockquote>
< <div><p>that can be at any level of nesting within self.</p>
< </div></blockquote>
< <p>Validate that all Nodes included in input dict are INPUT nodes of Composition.
< Consolidate any entries of <strong>inputs</strong> with InputPorts as keys to Mechanism or Composition entries
< If any INPUT nodes of Composition are not included, add them to the input_dict using their default values.
< Note: all entries must specify either a single trial’s worth of input, or the same number as all others.</p>
---
> <dt class="sig sig-object py" id="psyneulink.core.compositions.composition.Composition._validate_input_shapes">
> <span class="sig-name descname"><span class="pre">_validate_input_shapes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inputs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#psyneulink.core.compositions.composition.Composition._validate_input_shapes" title="Permalink to this definition">¶</a></dt>
> <dd><p>Validates that all inputs provided in input dict are valid</p>
4420c4430
< <dd class="field-odd"><p>Input dict, with added entries for any input Nodes or Ports for which input was not provided</p>
---
> <dd class="field-odd"><p>The input dict, with shapes corrected if necessary.</p>
diff -r docs-base/_sources/Composition.rst.txt docs-head/_sources/Composition.rst.txt
27a28
>        OptimizationControlMechanism
diff -r docs-base/genindex.html docs-head/genindex.html
956a957,958
>       <li><a href="Composition.html#psyneulink.core.compositions.composition.Composition._validate_input_keys">_validate_input_keys() (psyneulink.core.compositions.composition.Composition method)</a>
> </li>
Binary files docs-base/objects.inv and docs-head/objects.inv differ
diff -r docs-base/searchindex.js docs-head/searchindex.js
1c1
< Search.setIndex({docnames:["AGT","AGTControlMechanism","AutoAssociativeLearningMechanism","AutoAssociativeProjection","AutodiffComposition","BasicsAndPrimer","BotvinickConflictMonitoringModel","BustamanteStroopXORLVOCModel","Cohen_HustonModel","CombinationFunctions","ComparatorMechanism","Compilation","Component","Components","Composition","CompositionFunctionApproximator","CompositionInterfaceMechanism","Compositions","Condition","Context","ContrastiveHebbianMechanism","ContributorsGuide","ControlMechanism","ControlMechanisms","ControlProjection","ControlProjections","ControlSignal","ConventionsAndDefinitions","Core","DDM","DefaultControlMechanism","Defaults","DistributionFunctions","EVC","EVCAuxiliary","EVCControlMechanism","EpisodicMemoryMechanism","Function","Functions","GatingMechanism","GatingMechanisms","GatingProjection","GatingProjections","GatingSignal","GilzenratModel","InputPort","IntegratorFunctions","IntegratorMechanism","IntegratorMechanisms","KWTAMechanism","Keywords","KohonenMechanism","LCAMechanism","LCControlMechanism","LCMechanism","LeabraMechanism","LearningFunctions","LearningMechanism","LearningMechanisms","LearningProjection","LearningProjections","LearningSignal","Library","Log","MappingProjection","MaskedMappingProjection","Mechanism","Mechanisms","MemoryFunctions","Models","ModulatoryMechanism","ModulatoryMechanisms","ModulatoryProjection","ModulatoryProjections","ModulatorySignal","MontagueModel","NieuwenhuisModel","NonStatefulFunctions","ObjectiveFunctions","ObjectiveMechanism","ObjectiveMechanisms","OptimizationControlMechanism","OptimizationFunctions","OutputPort","PCTC_model","ParameterEstimationComposition","ParameterPort","Parameters","Pathway","PathwayProjection","PathwayProjections","Port","PredictionErrorMechanism","Preferences","ProcessingMechanism","ProcessingMechanisms","Projection","Projections","QuickReference","RecurrentTransferMechanism","RefactoredLearningGuide","Registry","RegressionCFA","Report","Scheduler","Scheduling","SelectionFunctions","Services","StatefulFunction","StatefulFunctions","Subystems","Time","TransferFunctions","TransferMechanism","TransferMechanisms","UserDefinedFunction","UserGuide","UserGuide_TBD","Visualization","globals","index","index_logo_with_text","mdf"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":4,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":3,"sphinx.domains.rst":2,"sphinx.domains.std":2,sphinx:56},filenames:["AGT.rst","AGTControlMechanism.rst","AutoAssociativeLearningMechanism.rst","AutoAssociativeProjection.rst","AutodiffComposition.rst","BasicsAndPrimer.rst","BotvinickConflictMonitoringModel.rst","BustamanteStroopXORLVOCModel.rst","Cohen_HustonModel.rst","CombinationFunctions.rst","ComparatorMechanism.rst","Compilation.rst","Component.rst","Components.rst","Composition.rst","CompositionFunctionApproximator.rst","CompositionInterfaceMechanism.rst","Compositions.rst","Condition.rst","Context.rst","ContrastiveHebbianMechanism.rst","ContributorsGuide.rst","ControlMechanism.rst","ControlMechanisms.rst","ControlProjection.rst","ControlProjections.rst","ControlSignal.rst","ConventionsAndDefinitions.rst","Core.rst","DDM.rst","DefaultControlMechanism.rst","Defaults.rst","DistributionFunctions.rst","EVC.rst","EVCAuxiliary.rst","EVCControlMechanism.rst","EpisodicMemoryMechanism.rst","Function.rst","Functions.rst","GatingMechanism.rst","GatingMechanisms.rst","GatingProjection.rst","GatingProjections.rst","GatingSignal.rst","GilzenratModel.rst","InputPort.rst","IntegratorFunctions.rst","IntegratorMechanism.rst","IntegratorMechanisms.rst","KWTAMechanism.rst","Keywords.rst","KohonenMechanism.rst","LCAMechanism.rst","LCControlMechanism.rst","LCMechanism.rst","LeabraMechanism.rst","LearningFunctions.rst","LearningMechanism.rst","LearningMechanisms.rst","LearningProjection.rst","LearningProjections.rst","LearningSignal.rst","Library.rst","Log.rst","MappingProjection.rst","MaskedMappingProjection.rst","Mechanism.rst","Mechanisms.rst","MemoryFunctions.rst","Models.rst","ModulatoryMechanism.rst","ModulatoryMechanisms.rst","ModulatoryProjection.rst","ModulatoryProjections.rst","ModulatorySignal.rst","MontagueModel.rst","NieuwenhuisModel.rst","NonStatefulFunctions.rst","ObjectiveFunctions.rst","ObjectiveMechanism.rst","ObjectiveMechanisms.rst","OptimizationControlMechanism.rst","OptimizationFunctions.rst","OutputPort.rst","PCTC_model.rst","ParameterEstimationComposition.rst","ParameterPort.rst","Parameters.rst","Pathway.rst","PathwayProjection.rst","PathwayProjections.rst","Port.rst","PredictionErrorMechanism.rst","Preferences.rst","ProcessingMechanism.rst","ProcessingMechanisms.rst","Projection.rst","Projections.rst","QuickReference.rst","RecurrentTransferMechanism.rst","RefactoredLearningGuide.rst","Registry.rst","RegressionCFA.rst","Report.rst","Scheduler.rst","Scheduling.rst","SelectionFunctions.rst","Services.rst","StatefulFunction.rst","StatefulFunctions.rst","Subystems.rst","Time.rst","TransferFunctions.rst","TransferMechanism.rst","TransferMechanisms.rst","UserDefinedFunction.rst","UserGuide.rst","UserGuide_TBD.rst","Visualization.rst","globals.rst","index.rst","index_logo_with_text.rst","mdf.rst"],objects:{"psyneulink.core.components":{component:[12,0,0,"-"]},"psyneulink.core.components.compone
...

See CI logs for the full diff.

@coveralls
Copy link

coveralls commented Mar 28, 2022

Coverage Status

Coverage decreased (-0.002%) to 84.164% when pulling 3358fe0 on refactor/composition/_validate_input_keys into c79f7bb on devel.

@jdcpni jdcpni merged commit 69d09a8 into devel Mar 28, 2022
@jdcpni jdcpni deleted the refactor/composition/_validate_input_keys branch March 28, 2022 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants