Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test/compositon/ validate input dict keys (#2365)
* • optimizationcontrolmechanism.py: docstring mods * • composition.py: - add allow_probes and exclude_probes_from_output * • composition.py: - 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) * • composition.py: - change "exclude_probes_from_output" -> "include_probes_in_output" * • composition.py: - docstring mods re: allow_probes and include_probes_in_output * • composition.py: - docstring mods re: allow_probes and include_probes_in_output * • controlmechanism.py: - 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 * • controlmechanism.py: - 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 * • composition.py add assignment of learning_mechanism to objective_mechanism.modulatory_mechanism for add_learning methods * • docstring mods * - * - * • optimizationcontrolmechanism.py: docstring revs * - * - * • test_composition.py: - add test_unnested_PROBE - add test_nested_PROBES TBD: test include_probes_in_output * - * • composition.py - add_node(): support tuple with required_role * - * • composition.py: - _determine_node_roles: fix bug in which nested comp was prevented from being an OUTPUT Node if, in addition to Nodes that qualifed as OUTPUT, it also had nodes that projected to Nodes in an outer comp (making it look like it was INTERNAL) * - * • composition.py: - add_node(): enforce include_probes_in_output = True for nested Compositions - execute(): - replace return of output_value with get_output_value() * - * • CompositionInterfaceMechanism.rst: - correct path ref • compositioninterfacemechanism.py: - docstring fixes * • optimizationcontrolmechanism.py: - docstring edits * - * - * - * - * - * - * - * - * • composition.py, optimizationcontrolmechanism.py: _build_predicted_input_dict(): support partial specification of INPUT Nodes for nested Compositions of agent_rep * • test_control.py: - test_nested_composition_as_agent_rep(): PASSES ALL TESTS * - * • optimizationcontrolmechanism.py: - _parse_state_feature_specs: support nested composition in dict spec * • test_control.py - test_ocm_state_feature_specs_and_warnings_and_errors(): - modified to accomodate nested INPUT Node specs - PASSES ALL TESTS * • composition.py: - add _nodes_added attribute - add_nodes(): set _nodes_added attribute upon completition - _analyze_graph(): add call _determine_node_roles() if _nodes_added is True * • composition.py: - _nodes_added -> needs_determine_node_roles • optimizationcontrolmechanism.py: - _get_agent_rep_input_nodes(): call _determine_node_roles if agent_rep.needs_determine_node_roles is True * • optimizationcontrolmechanism.py: - _parse_state_feature_specs(): consolidate handling of various formats * • optimizationcontrolmechanism.py: docstring updates * • optimizationcontrolmechanism.py: _get_agent_rep_input_nodes() -> _get_agent_rep_input_receivers() _parse_state_feature_specs(): standardize on InputPorts rather than Nodes * - * - * - * - * • composition.py: - _instantiate_input_dict(): refactor to accept inputs for InputPorts of nested Nodes - add helper method _get_external_cim_input_port() - TBD: - refactor _build_predicted_inputs_dict to support above * - * • composition.py: - _instantiate_input_dict(): now generates properly formatted values in input_dict for InputPort specs * • composition.py: - _build_predicted_inputs_dict(): refactored to construct inputs_dict with InputPorts as keys * - * - * - * - * - * - * - * - * - * - * - * - * - * • optimizationcontrolmechanism.py: - refactor state_feature_values as dict that can be used as predicted_inputs / feature_values arg of evaluate() (and inputs arg of run) • composition.py: - remove _build_predicted_inputs_dict(), since state_feature_values now formatted properly as input * - * - * - * - * - * - * - * - * - * - * - * - * - * • composition.py: - _instantiate_inputs_dict(): BEFORE REFACTORING FOR MISSING PORTS OF NESTED COMP * • composition.py: - _instantiate_inputs_dict(): BEFORE REFACTORING FOR MISSING PORTS OF NESTED COMP * • composition.py: - _instantiate_inputs_dict(): BEFORE REFACTORING FOR MISSING PORTS OF NESTED COMP * • composition.py: - _instantiate_inputs_dict(): AFTER REFACTORING FOR MISSING PORTS OF NESTED COMP * - * - * - * - * • test_composition.py: - refactor test_input_type_equivalence() * - PASSES test_control * - merged from devel missing dependencies * - * - * - * • update pandas req to 1.4.1 * • composition.py: - _instantiate_inputs_dict(): refactored to consolidate treatment of nested Nodes * - * - * • composition.py - _instantiate_input_dict(): handle ports with diff numbers of trials specified * • composition.py - _instantiate_input_dict(): handle ports with diff numbers of trials specified * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * • composition.py: - _parse_names_in_inputs(): support Port.full_name as keys in inputs dict • mechanism.py: - Mechanism_Base: replaced input_labels and output_labels with labeled_input_values and labeled_output_values respectively • port.py, inputport.py, outputport.py, parameterport.py: - Port_Base: impelment labeled_value property (and value_label alias) that returns calls get_label() - deleted label attributes of InputPort and OutputPort (replaced by Port_Base.labeled_value) - added get_label() stub on ParameterPort with error message * - * - * • conf.py: comment out 'sphinx_autodoc_typehints' (crashing for sphinx_autodoc_typehints v.1.17.0) * • conf.py: restore 'sphinx_autodoc_typehints' • doc_requirements.txt: pin sphinx_autodoc_typehints < v.1.16.0; error on v1.16 and v1.17; error: https://github.com/PrincetonUniversity/PsyNeuLink/runs/5573651890?check_suite_focus=true * - * - * • composition.py: - add property: external_input_ports_of_all_input_nodes • optimizationcontrolmechanism.py: - implement state_faature_default - add SHADOW_INPUTS as individual spec for state_features * • composition.py: - add property: external_input_ports_of_all_input_nodes • optimizationcontrolmechanism.py: - implement state_faature_default - add SHADOW_INPUTS as individual spec for state_features * - * - * - * - * - * - * - * - * • inputport.py: - add figure for shadowing * - * - * • processingmechanism.py: - __init__(): modify typecheck for input_ports to allow single items * • optimizationcontrolmechanism.py - allow single spec (None, array, tuple, or Components) that is assigned to all INPUT Node InputPorts - state_feature_default is assigned to all unspecified INPUT Node InputPorts (for a list that is shorter than the number, a dict or a set that has fewer, or any that are added to agent_rep after controller is initially constructed and added to Composition) * - * - * • optimizationcontrolmechanism.py: docstring mods * • optimizationcontrolmechanism.py: docstring mods * • optimizationcontrolmechanism.py: docstring mods * - * - * - * - * - * • optimizationcontrolmechanism.py: - _state_feature_values_getter(): for numeric state_feature, return state_input_port.functio(numeric_value) * • test_control.py: - test_ocm_state_feature_specs_and_warnings_and_errors() - added tests for single state_feature spec * - composition.py, inputport.py, optimizationcontrolmechanism.py: docstring mods re: "external InputPort" * - * - * - * • test_control.py: - test_state_features_in_nested_composition_as_agent_rep(): - add tests for single state_feature specs - add tests for INPUT Node with more than on InputPort * - * - * - * • optimizationcontrolmechanism.py: - state_features, get_state_feature_source: simplify * - * - * • optimizationcontrolmechanism.py: - state_features, get_state_feature_source: simplify * • optimizationcontrolmechanism.py: IN PROGRESS - _specified_INPUT_Node_InputPorts_in_order: use name (str) of items not yet in agent_rep rather than 'None' - state_features & state_feature_values: - use name (str) as key if INPUT Node InputPort is not yet in agent_rep - use name (str) if source (spec) is not yet in Composition * - * • optimizationcontrolmechanism.py: IMPLEMENTED - state_features: - convert all keys and values to port.full_name - if not yet in comp or agent_rep, add "DEFERRED..." * • optimizationcontrolmechanism.py: PASSES deferred_init and partial_deferred_init tests * • optimizationcontrolmechanism.py: - state_feature_values: strings for missing keys or values * • test_control.py: PASSING test_deferred and test_partial_deferred * • test_control.py: PASSING test_deferred and test_partial_deferred * • test_control.py: PASSING test_deferred and test_partial_deferred * • test_control.py: PASSING test_ocm_state_feature_specs_and_warnings_and_errors * • test_control.py: PASSING all state_feature tests * • composition.py: add _is_in_composition method * - * - * - * - * - * - * - * - * - * • optimzationcontrolmechanism.py: fix figure * • optimzationcontrolmechanism.py: fix figure * • optimizationcontrolmechanism.py: - fix bug in which state_feature_default = None was being ignored - fix bug in which deferred nodes were not being assigned state_feature_default * - * • optimizationcontrolmechanism.py: - 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_control.py: - test_deferred_init, test_partial_deferred_init(): added tests for controller.state_input_ports path_afferents * - * - * • optimizationcontrolmechanism.py: - _parse_state_feature_specs: - fixed bug in handling of lists of numeric specs - renamed state_input_ports for numeric specs * • registry.py: - rename_instance_in_registry(): finish implementing (including **new_name** arg) • optimizationcontrolmechanism.py: - _update_state_features_dict: rename deferred state_input_ports * • registry.py: - rename_instance_in_registry(): finish implementing (including **new_name** arg) • optimizationcontrolmechanism.py: - _update_state_features_dict: rename deferred state_input_ports * - * • optimizationcontrolmechanism.py, test_control.py - standarize prefixes for state_input_ports * • optimizationcontrolmechanism.py, test_control.py - standarize prefixes for state_input_ports * - * - * • test_show_graph remaining * • mechanism.py: - _show_structure(): fix parameterport label bug * - * - * - * - * • composition.py: _validate_input_keys(): add method to validate keys of inputs to run() method * • test_composition.py: - test_inputs_key_errors() * • test_composition.py: - test_inputs_key_errors(): add test for running nested composition with inputs * - * • composition.py: - execute(): allow direct call to nested composition with inputs * - * - Co-authored-by: jdcpni <pniintel55>
- Loading branch information