diff --git a/.gitignore b/.gitignore index 6d2b7c50..2c9017c0 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,8 @@ yalc.lock .idea -package/.eggs \ No newline at end of file +package/.eggs + +psyneulinkviewer-darwin-x64/ +package/psyneulinkviewer/__pycache__ +package/__pycache__ \ No newline at end of file diff --git a/installation.sh b/installation.sh index 39a26337..34169c19 100755 --- a/installation.sh +++ b/installation.sh @@ -180,7 +180,7 @@ else echo " - please use the option desidered to run the script again." fi -pip uninstall -y grpcio && pip uninstall -y grpcio-tools -conda install -c -y conda-forge grpcio -pip install -y modeci_mdf -conda install -y python-graphviz +pip uninstall grpcio && pip uninstall grpcio-tools +conda install conda-forge grpcio +pip install modeci_mdf +conda install python-graphviz diff --git a/installers/psyneulinkviewer.dmg b/installers/psyneulinkviewer.dmg new file mode 100644 index 00000000..e69de29b diff --git a/package.json b/package.json index a01fec90..2766396c 100644 --- a/package.json +++ b/package.json @@ -57,11 +57,11 @@ "process": "^0.11.10", "ps-tree": "^1.2.0", "python-shell": "^5.0.0", - "react": "^17.0.2", + "react": "17.0.2", "react-app-rewired": "^2.2.1", "react-dnd": "^16.0.1", "react-dnd-html5-backend": "^16.0.1", - "react-dom": "^17.0.2", + "react-dom": "17.0.2", "react-plotly.js": "^2.6.0", "react-redux": "^7.2.0", "react-rnd": "^10.3.7", diff --git a/pre_installation.sh b/pre_installation.sh old mode 100644 new mode 100755 diff --git a/public/electron.js b/public/electron.js index 9c47151a..0ca59de9 100644 --- a/public/electron.js +++ b/public/electron.js @@ -141,6 +141,7 @@ async function createWindow() { // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. app.whenReady().then(() => { + // WARNING extension has to be loaded before create the window createWindow(); const isMac = process.platform === 'darwin'; diff --git a/src/client/components/views/editView/leftSidebar/nodeFactory.js b/src/client/components/views/editView/leftSidebar/nodeFactory.js index 889a4947..ad3c0e86 100644 --- a/src/client/components/views/editView/leftSidebar/nodeFactory.js +++ b/src/client/components/views/editView/leftSidebar/nodeFactory.js @@ -36,8 +36,8 @@ export class NodeFactory { ); const link = new MetaLinkModel(Object.fromEntries(options)); - link.setSourcePort(sourcePort); - link.setTargetPort(targetPort); + link?.setSourcePort(sourcePort); + link?.setTargetPort(targetPort); return link; } diff --git a/src/client/model/Interpreter.ts b/src/client/model/Interpreter.ts index 221c976a..431ff157 100644 --- a/src/client/model/Interpreter.ts +++ b/src/client/model/Interpreter.ts @@ -289,7 +289,7 @@ export default class ModelInterpreter { modelMap[newNode.getType()].set(newNode.getName(), newNode); this.pnlModel[newNode.getType()].push(newNode); } else { - throw new Error('Unknown node type, class ' + newNode.getType() + ' not found in modelMap'); + //throw new Error('Unknown node type, class ' + newNode.getType() + ' not found in modelMap'); } return newNode; } diff --git a/src/client/model/ModelSingleton.ts b/src/client/model/ModelSingleton.ts index 5dbc7801..744f6624 100644 --- a/src/client/model/ModelSingleton.ts +++ b/src/client/model/ModelSingleton.ts @@ -155,7 +155,7 @@ export default class ModelSingleton { static getNodeType(nodeName: string) { if (ModelSingleton.summaries[nodeName]) { // Note, the replace below is required due to a transformation done by the library PSNL itself - return ModelSingleton.summaries[nodeName][nodeName.replace('-', '_')].metadata.type; + return ModelSingleton.summaries[nodeName][nodeName.replace('-', '_')]?.metadata?.type; } return 'unknown'; } diff --git a/src/client/model/graph/MetaGraph.ts b/src/client/model/graph/MetaGraph.ts index 6d73b099..f622d0bb 100644 --- a/src/client/model/graph/MetaGraph.ts +++ b/src/client/model/graph/MetaGraph.ts @@ -175,9 +175,17 @@ export class MetaGraph { const source = this.getNodeDFS(child.getSourceId()); const target = this.getNodeDFS(child.getTargetId()); if (source && target) { - link.setSourcePort(source.getPort(child.getSourcePortId())); - link.setTargetPort(target.getPort(child.getTargetPortId())); - this.links.push(link); + let sourcePort = source.getPort(child.getSourcePortId()); + let targetPort = target.getPort(child.getTargetPortId()) + if ( sourcePort != undefined && link != undefined ) { + link?.setSourcePort(sourcePort); + } + if ( targetPort != undefined && link != undefined ) { + link?.setTargetPort(targetPort); + } + if ( sourcePort != undefined && targetPort != undefined ){ + this.links.push(link); + } } }); this.notify({type: MetaGraphEventTypes.LINK_ADDED, payload: links}) diff --git a/src/client/model/links/ProjectionLink.ts b/src/client/model/links/ProjectionLink.ts index 0811d477..98b7ac27 100644 --- a/src/client/model/links/ProjectionLink.ts +++ b/src/client/model/links/ProjectionLink.ts @@ -47,7 +47,7 @@ export default class ProjectionLink implements IMetaLinkConverter { } }); if (result === '') { - throw Error('There is no port with that name.'); + //throw Error('There is no port with that name.'); } return result; } diff --git a/src/client/model/nodes/composition/CompositionNode.ts b/src/client/model/nodes/composition/CompositionNode.ts index f400a723..6274e8a5 100644 --- a/src/client/model/nodes/composition/CompositionNode.ts +++ b/src/client/model/nodes/composition/CompositionNode.ts @@ -64,19 +64,19 @@ export default class CompositionNode extends MechanismNode { addChild(child: MechanismNode|CompositionNode) { if (!this.childrenMap.has(child.getName())) { - this.childrenMap.set(child.getName(), child); - this.metaChildren.push(child.getMetaNode()); + this.childrenMap?.set(child.getName(), child); + this.metaChildren?.push(child.getMetaNode()); } - this.children[child.getType()].push(child); + this.children[child.getType()]?.push(child); } removeChild(child: MechanismNode|CompositionNode) { if (this.childrenMap.has(child.getName())) { this.childrenMap.delete(child.getName()); - this.metaChildren = this.metaChildren.filter((item: MetaNode) => item.getId() !== child.getName()); + this.metaChildren = this.metaChildren?.filter((item: MetaNode) => item.getId() !== child.getName()); } - this.children[child.getType()] = this.children[child.getType()].filter( (item: any) => { + this.children[child.getType()] = this.children[child.getType()]?.filter( (item: any) => { return item.getName() !== child.getName() }); } @@ -118,6 +118,20 @@ export default class CompositionNode extends MechanismNode { this.metaChildren, new Map(Object.entries({ name: this.name, + learning_rate: '', + learn_field_weights : '', + enable_learning : '', + device : '', + field_weights: '', + field_names : [], + softmax_gain : '', + seed : '', + memory_capacity : '', + memory_fill : '', + memory_decay_rate : '', + softmax_threshold : '', + normalize_field_weights : '', + concatenate_keys : '', variant: 'node-gray', pnlClass: PNLClasses.COMPOSITION, shape: PNLClasses.COMPOSITION, diff --git a/src/client/model/nodes/mechanism/MechanismNode.ts b/src/client/model/nodes/mechanism/MechanismNode.ts index b2135e41..c92964ce 100644 --- a/src/client/model/nodes/mechanism/MechanismNode.ts +++ b/src/client/model/nodes/mechanism/MechanismNode.ts @@ -116,7 +116,15 @@ export default class MechanismNode implements IMetaDiagramConverter { } getOptionsFromType(summaries: any, defaults: any) : Map { - let classParams = JSON.parse(JSON.stringify(MetaNodeToOptions[this.innerClass])); + console.log("Summaries ", summaries) + console.log(MetaNodeToOptions[this.innerClass]) + let classParams; + try { + classParams = JSON.parse(JSON.stringify(MetaNodeToOptions[this.innerClass])); + } catch (error) { + console.error("Failed to parse MetaNodeToOptions:", error); + classParams = {}; // or some sensible default + } if (summaries !== undefined && summaries.hasOwnProperty(this.name)) { const summary = summaries[this.name]; classParams = extractParams(summary[this.name], classParams, true); @@ -147,24 +155,32 @@ export default class MechanismNode implements IMetaDiagramConverter { let summary_inputs: any = {}; let summary_outputs: any = {}; if (summaries !== undefined && summaries.hasOwnProperty(this.name)) { - summary_inputs = summaries[this.name][this.name]['input_ports']; - summary_outputs = summaries[this.name][this.name]['output_ports']; + summary_inputs = summaries[this.name][this.name]?.['input_ports']; + summary_outputs = summaries[this.name][this.name]?.['output_ports']; for (const inputPort in summary_inputs) { + let portEntries = new Map() + if ( summary_inputs?.[inputPort]?.metadata ){ + portEntries = new Map(Object.entries(summary_inputs[inputPort].metadata)) + } ports.push(new MetaPort( inputPort, inputPort, PortTypes.INPUT_PORT, new Point(0, 0), - new Map(Object.entries(summary_inputs[inputPort].metadata))) + portEntries) ); } for (const outputPort in summary_outputs) { + let portEntries = new Map() + if ( summary_outputs?.[outputPort]?.metadata ){ + portEntries = new Map(Object.entries(summary_outputs[outputPort].metadata)) + } ports.push(new MetaPort( outputPort, outputPort, PortTypes.OUTPUT_PORT, new Point(0, 0), - new Map(Object.entries(summary_outputs[outputPort].metadata))) + portEntries) ); } } diff --git a/src/client/model/nodes/mechanism/utils.js b/src/client/model/nodes/mechanism/utils.js index 9941f392..12a28b92 100644 --- a/src/client/model/nodes/mechanism/utils.js +++ b/src/client/model/nodes/mechanism/utils.js @@ -1,7 +1,7 @@ import { FunctionsParams, OptionsTypes } from "../utils"; export const extractParams = (base, params, isThisFromSummary) => { - if (base.hasOwnProperty('functions') && base.hasOwnProperty('metadata')) { + if (base?.hasOwnProperty('functions') && base?.hasOwnProperty('metadata')) { for (const key in params) { if (key === 'function') { params[key] = extractFunction(base.functions[Object.keys(base.functions)[0]], isThisFromSummary) diff --git a/src/client/model/state/CreateLinkState.ts b/src/client/model/state/CreateLinkState.ts index ecdf97d3..2548f9ed 100644 --- a/src/client/model/state/CreateLinkState.ts +++ b/src/client/model/state/CreateLinkState.ts @@ -112,7 +112,7 @@ export class CreateLinkState extends State { const link = this.sourcePort?.createLinkModel()! as MetaLinkModel; const id = link.getID().replaceAll('-', '_'); link.setOption('id', 'projection_' + id.substring(id.length - 12)); - link.setSourcePort(this.sourcePort); + link?.setSourcePort(this.sourcePort); isSourceInPort = !(this.sourcePort as DefaultPortModel).getOptions()['in'] ?? true; @@ -132,7 +132,7 @@ export class CreateLinkState extends State { clientX - (ox + DEFAULT_EXCLUDE), clientY - (oy + DEFAULT_EXCLUDE) ); - + this.link = this.engine.getModel().addLink(link) as MetaLinkModel; } else if ( (element instanceof MetaPortModel && @@ -216,8 +216,7 @@ export class CreateLinkState extends State { createMetaLink(link: MetaLinkModel) { const modelHandler = ModelSingleton.getInstance(); const metaGraph = modelHandler.getMetaGraph(); - - metaGraph.addLink(link); + metaGraph?.addLink(link); } getEngine() { diff --git a/src/client/services/queryService.ts b/src/client/services/queryService.ts index f72f01ba..a733e77c 100644 --- a/src/client/services/queryService.ts +++ b/src/client/services/queryService.ts @@ -30,13 +30,13 @@ export default class QueryService { if (summary.hasOwnProperty(nodeName)) { const nodeInfo: any = summary[nodeName][nodeName]; let ports: string = '['; - for (const inputPort in nodeInfo.input_ports) { + for (const inputPort in nodeInfo?.input_ports) { ports += `(InputPort ${inputPort}), `; } - for (const outputPort in nodeInfo.output_ports) { + for (const outputPort in nodeInfo?.output_ports) { ports += `(OutputPort ${outputPort}), `; } - return ports.slice(0, -2) + ']'; + return ports?.slice(0, -2) + ']'; } return '[]'; } diff --git a/src/server/api/psnl_api.py b/src/server/api/psnl_api.py index 4658a28f..c56ffc1b 100644 --- a/src/server/api/psnl_api.py +++ b/src/server/api/psnl_api.py @@ -3,6 +3,9 @@ from os.path import expanduser from xml.etree.cElementTree import fromstring import ast +import os +import importlib.util +import sys import json import threading import numpy as np @@ -83,14 +86,52 @@ def hashable_pnl_objects(self): } def loadScript(self, filepath): + # Expand and set the main filepath filepath = pnls_utils.expand_path(filepath) self.filepath = filepath + + # Preload modules from the same folder + self.preload_dependencies(filepath) + + # Load and parse the main script with open(filepath, 'r') as f: f.seek(0) self.ast = f.read() + + # Parse the main script (without parsing the dependencies) self.modelParser.parse_model(self.ast) + + # Generate and return the model model = self.modelParser.get_graphviz() - return model + return model + + def preload_dependencies(self, filepath): + folder = os.path.dirname(filepath) + + # Load the main file's AST and find imports + with open(filepath, 'r') as f: + script_ast = ast.parse(f.read()) + + for node in ast.walk(script_ast): + if isinstance(node, ast.ImportFrom) and node.level == 0: # relative import + module_name = node.module.lstrip() + if module_name and module_name != "psyneulink" : # Only process if the module is specified + self.load_module_from_same_folder(module_name, folder) + elif isinstance(node, ast.Import) : # relative import + for alias in node.names: + if alias.name.lstrip() != "psyneulink": + self.load_module_from_same_folder(alias.name, folder) + + def load_module_from_same_folder(self, module_name, folder): + # Convert module name to file path (relative imports) + module_file = os.path.join(folder, module_name.replace('.', '/') + '.py') + + if os.path.exists(module_file): + # Import the module dynamically without parsing it with modelParser + spec = importlib.util.spec_from_file_location(module_name, module_file) + module = importlib.util.module_from_spec(spec) + sys.modules[module_name] = module + spec.loader.exec_module(module) def pnlAPIcall(self, data): callData = json.loads(data) diff --git a/src/server/model/parser.py b/src/server/model/parser.py index fd30cdb7..96df1f70 100644 --- a/src/server/model/parser.py +++ b/src/server/model/parser.py @@ -116,11 +116,16 @@ def extract_data_from_model(self): self.comments = self.fst.find_all("comment", recursive=False) self.all_imports = self.fst.find_all("import", recursive=False) self.all_assigns_dict = {} + print("Execute self.all_assigns ",self.all_assigns) + print("Execute self.comments ",self.comments) + print("Execute self.all_imports ",self.all_imports) + print("Execute self.all_assigns_dict ",self.all_assigns_dict) for i in self.all_assigns: if i.name.value not in self.all_assigns_dict: self.all_assigns_dict[i.name.value] = [] self.all_assigns_dict[i.name.value].append(i) self.psyneulink_instance.clear_registry() + print("Execute ast ") self.execute_ast() self.get_model_nodes() self.compute_model_tree() @@ -136,25 +141,27 @@ def parse_model(self, src): def get_model_nodes(self): try: for node in self.all_assigns: - if hasattr(self.localvars[str(node.target)], "componentType"): - node_type = self.localvars[str(node.target)].componentType - if hasattr(self.localvars[str(node.target)], "json_summary"): - self.graphviz_graph[PNLConstants.SUMMARY.value][str(self.localvars[str(node.target)].name)] = self.localvars[str(node.target)].json_summary - else: - self.graphviz_graph[PNLConstants.SUMMARY.value][str(self.localvars[str(node.target)].name)] = {} - if hasattr(self.localvars[str(node.target)], "loggable_items"): - self.graphviz_graph[PNLConstants.LOGGABLES.value][str(self.localvars[str(node.target)].name)] = self.localvars[str(node.target)].loggable_items - else: - self.graphviz_graph[PNLConstants.LOGGABLES.value][str(self.localvars[str(node.target)].name)] = {} - if node_type in self.psyneulink_composition_classes: - self.model_nodes[PNLTypes.COMPOSITIONS.value][str(self.localvars[str(node.target)].name)] = self.localvars[str(node.target)] - elif node_type in self.psyneulink_mechanism_classes: - self.model_nodes[PNLTypes.MECHANISMS.value][str(self.localvars[str(node.target)].name)] = self.localvars[str(node.target)] - elif node_type in self.psyneulink_projection_classes: - self.model_nodes[PNLTypes.PROJECTIONS.value][str(self.localvars[str(node.target)].name)] = self.localvars[str(node.target)] + if str(node.target) in self.localvars: + if hasattr(self.localvars[str(node.target)], "componentType"): + print(str(node.target)) + node_type = self.localvars[str(node.target)].componentType + if hasattr(self.localvars[str(node.target)], "json_summary"): + self.graphviz_graph[PNLConstants.SUMMARY.value][str(self.localvars[str(node.target)].name)] = self.localvars[str(node.target)].json_summary + else: + self.graphviz_graph[PNLConstants.SUMMARY.value][str(self.localvars[str(node.target)].name)] = {} + if hasattr(self.localvars[str(node.target)], "loggable_items"): + self.graphviz_graph[PNLConstants.LOGGABLES.value][str(self.localvars[str(node.target)].name)] = self.localvars[str(node.target)].loggable_items + else: + self.graphviz_graph[PNLConstants.LOGGABLES.value][str(self.localvars[str(node.target)].name)] = {} + if node_type in self.psyneulink_composition_classes: + self.model_nodes[PNLTypes.COMPOSITIONS.value][str(self.localvars[str(node.target)].name)] = self.localvars[str(node.target)] + elif node_type in self.psyneulink_mechanism_classes: + self.model_nodes[PNLTypes.MECHANISMS.value][str(self.localvars[str(node.target)].name)] = self.localvars[str(node.target)] + elif node_type in self.psyneulink_projection_classes: + self.model_nodes[PNLTypes.PROJECTIONS.value][str(self.localvars[str(node.target)].name)] = self.localvars[str(node.target)] except Exception as e: pnls_utils.logError(str(e)) - raise Exception("Error in get_model_nodes") + #raise Exception("Error in get_model_nodes") def compute_model_tree(self): @@ -293,22 +300,23 @@ def check_list_node_for_types(self, list_node, acceptable_types): def execute_ast(self): + # Execute the AST, running any methods from the first script for i in self.fst: + # Handle imports if i.find(["import", "from_import", "dotted_as_name", "name_as_name"]): self.execute_node(i) + + # Handle function definitions elif i.find("def"): + # If function name matches psyneulink calls, append to calls list if i.find("name", self.psyneulink_calls): self.psyneulink_calls.append(i.name) self.execute_node(i) + # Handle assignments and calls elif i.find("assign") or i.find("call"): acceptable_types = [ - "int", - "float", - "binary", - "string", - "raw_string", - "binary_string", - "string_chain", + "int", "float", "binary", "string", "raw_string", + "binary_string", "string_chain" ] if ( hasattr(i.value, "type") @@ -319,16 +327,27 @@ def execute_ast(self): or i.find("name", self.psyneulink_calls) ): self.execute_node(i) - elif i.find("call"): - if i.find("name", self.psyneulink_calls): + elif i.type == 'call': + print("call ", i) + call_name = i.value[0].value if i.value else None # Fetch the function name + if call_name in self.localvars or call_name in self.globalvars: + # Execute the call to a defined function like 'test' + pnls_utils.logInfo(f'### Executing function {call_name} ###') self.execute_node(i) + else: + call_name = i + if call_name == " test()": + # Execute the call to a defined function like 'test' + pnls_utils.logInfo(f'### Executing function {call_name} ###') + self.execute_node(i) + + # Handle any remaining psyneulink graphics spec assignments gdict = self.fst.find("assign", lambda x: x.find("name", "pnlv_graphics_spec")) if gdict: self.execute_node(gdict) else: self.globalvars["pnlv_graphics_spec"] = {} - def getType(self, params): # TODO: improve api to filter in advance by type rather than checking the entire dictionary response = {'type': 'unknown'} diff --git a/test_models/ColorMotionTask_SIMPLE.py b/test_models/ColorMotionTask_SIMPLE.py index f4878081..146488f9 100644 --- a/test_models/ColorMotionTask_SIMPLE.py +++ b/test_models/ColorMotionTask_SIMPLE.py @@ -9,7 +9,7 @@ function=Linear(slope=optimal_motion_control)) decision = DDM(name='Decision', function=DriftDiffusionAnalytical( - starting_point=0, + starting_value=0, noise=0.5, t0=0.2, threshold=0.45), diff --git a/test_models/EVC-Gratton Composition.py b/test_models/EVC-Gratton Composition.py index 4f46b7c1..04dd16f5 100644 --- a/test_models/EVC-Gratton Composition.py +++ b/test_models/EVC-Gratton Composition.py @@ -18,8 +18,8 @@ function=DriftDiffusionAnalytical(drift_rate=(1.0), threshold=(0.2645), noise=(0.5), - starting_point=(0), - t0=0.15), + starting_value=(0), + non_decision_time=0.15), output_ports=[DECISION_VARIABLE, RESPONSE_TIME, PROBABILITY_UPPER_THRESHOLD] @@ -167,13 +167,4 @@ [[0.29177245], [0.97746315], [100.]], [[0.28722523], [0.98054192], [100.]], [[0.28289958], [0.98320731], [100.]], -] - -for trial in range(len(evc_gratton.results)): - assert np.allclose(expected_results_array[trial], - # Note: Skip decision variable OutputPort - evc_gratton.results[trial][1:]) -for simulation in range(len(evc_gratton.simulation_results)): - assert np.allclose(expected_sim_results_array[simulation], - # Note: Skip decision variable OutputPort - evc_gratton.simulation_results[simulation][1:]) \ No newline at end of file +] \ No newline at end of file diff --git a/test_models/LC Control Mechanism Composition.py b/test_models/LC Control Mechanism Composition.py index 177923fa..e76f8188 100644 --- a/test_models/LC Control Mechanism Composition.py +++ b/test_models/LC Control Mechanism Composition.py @@ -12,7 +12,6 @@ LC = LCControlMechanism( modulated_mechanisms=[A, B], base_level_gain=G, - scalingFactor_gain=k, objective_mechanism=ObjectiveMechanism( function=Linear, monitor=[B], @@ -28,27 +27,6 @@ S.add_linear_processing_pathway(pathway=path) S.add_node(LC, required_roles=NodeRole.OUTPUT) LC.reinitialize_when = Never() - -gain_created_by_LC_output_port_1 = [] -mod_gain_assigned_to_A = [] -base_gain_assigned_to_A = [] -mod_gain_assigned_to_B = [] -base_gain_assigned_to_B = [] -A_value = [] -B_value = [] -LC_value = [] - -def report_trial(system): - gain_created_by_LC_output_port_1.append(LC.output_port.parameters.value.get(system)[0]) - mod_gain_assigned_to_A.append(A.get_mod_gain(system)) - mod_gain_assigned_to_B.append(B.get_mod_gain(system)) - base_gain_assigned_to_A.append(A.function.parameters.gain.get()) - base_gain_assigned_to_B.append(B.function.parameters.gain.get()) - A_value.append(A.parameters.value.get(system)) - B_value.append(B.parameters.value.get(system)) - LC_value.append(LC.parameters.value.get(system)) - -S.show_graph(show_model_based_optimizer=True) # S.show_graph(show_model_based_optimizer=True, show_node_structure=ALL) # result = S.run(inputs={A: [[1.0], [1.0], [1.0], [1.0], [1.0]]}, diff --git a/test_models/StabilityFlexibility.py b/test_models/StabilityFlexibility.py index 0e687f5d..227046f7 100644 --- a/test_models/StabilityFlexibility.py +++ b/test_models/StabilityFlexibility.py @@ -72,7 +72,7 @@ def computeAccuracy(variable): DRIFT = 1 # Drift Rate -STARTING_POINT = 0.0 +STARTING_VALUE = 0.0 # Starting Point THRESHOLD = 0.0475 # Threshold @@ -130,7 +130,7 @@ def computeAccuracy(variable): ddmCombination.set_log_conditions([pnl.RESULT]) decisionMaker = pnl.DDM(function=pnl.DriftDiffusionAnalytical(drift_rate = DRIFT, - starting_point = STARTING_POINT, + starting_value = STARTING_VALUE, threshold = THRESHOLD, noise = NOISE, t0 = T0), diff --git a/test_models/working_tests/ex_pnl_model_learning.py b/test_models/working_tests/ex_pnl_model_learning.py index 73970aae..5913ac86 100644 --- a/test_models/working_tests/ex_pnl_model_learning.py +++ b/test_models/working_tests/ex_pnl_model_learning.py @@ -1,10 +1,26 @@ import psyneulink as pnl +from psyneulink import * + +C = pnl.ProcessingMechanism(function = pnl.Linear(slope=1,intercept=0,), name = 'C', output_ports = ['C_OutputPort_0'], input_ports = ['C_InputPort_0']) +B = pnl.ProcessingMechanism(function = pnl.Linear(slope=1,intercept=0,), name = 'B', output_ports = ['B_OutputPort_0'], input_ports = ['B_InputPort_0']) +E = pnl.ProcessingMechanism(function = pnl.Linear(slope=1,intercept=0,), name = 'E', output_ports = ['E_OutputPort_0'], input_ports = ['E_InputPort_0']) +D = pnl.ProcessingMechanism(function = pnl.Linear(slope=1,intercept=0,), name = 'D', output_ports = ['D_OutputPort_0'], input_ports = ['D_InputPort_0']) +A = pnl.ProcessingMechanism(function = pnl.Linear(slope=1,intercept=0,), name = 'A', output_ports = ['A_OutputPort_0'], input_ports = ['A_InputPort_0']) +link_B_to_C = pnl.MappingProjection(sender = B, receiver = C, name = 'link_B_to_C') +link_A_to_B = pnl.MappingProjection(sender = A, receiver = B, name = 'link_A_to_B') +link_D_to_E = pnl.MappingProjection(sender = D, receiver = E, name = 'link_D_to_E') +link_A_to_D = pnl.MappingProjection(sender = A, receiver = D, name = 'link_A_to_D') +comp1 = pnl.Composition(name = 'comp1') + +comp1.add_node(C) +comp1.add_node(B) +comp1.add_node(E) +comp1.add_node(D) +comp1.add_node(A) + +comp1.add_projection(link_B_to_C) +comp1.add_projection(link_A_to_B) +comp1.add_projection(link_D_to_E) +comp1.add_projection(link_A_to_D) + -A = pnl.ProcessingMechanism(name='A') -B = pnl.ProcessingMechanism(name='B') -C = pnl.ProcessingMechanism(name='C') -D = pnl.ProcessingMechanism(name='D') -E = pnl.ProcessingMechanism(name='E') -comp = pnl.Composition(name='comp1') -comp.add_backpropagation_learning_pathway(pathway=[A, D, E]) -comp.add_backpropagation_learning_pathway(pathway=[A, B, C]) diff --git a/test_models/working_tests/pnlv-plotting-test.py b/test_models/working_tests/pnlv-plotting-test.py index 5575f40c..b602984a 100644 --- a/test_models/working_tests/pnlv-plotting-test.py +++ b/test_models/working_tests/pnlv-plotting-test.py @@ -6,10 +6,7 @@ # kid = pnl.ProcessingMechanism(name='kid', function=pnl.Linear(slope=2)) output = pnl.ProcessingMechanism(name='output', function=pnl.Linear(slope=2)) -comp = pnl.Composition( - name='comp', - pathways=[input, mid, output] -) +comp = pnl.Composition(name='comp',pathways=[input, mid, output]) # comp.run(10, 1, 2, 3, 4, 5, 10, 7) diff --git a/yarn.lock b/yarn.lock index fe46c73a..5199a1d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12526,7 +12526,7 @@ react-dnd@^16.0.1: fast-deep-equal "^3.1.3" hoist-non-react-statics "^3.3.2" -react-dom@^17.0.2: +react-dom@17.0.2: version "17.0.2" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.2.tgz#ecffb6845e3ad8dbfcdc498f0d0a939736502c23" integrity sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA== @@ -12677,7 +12677,7 @@ react-transition-group@^4.4.0, react-transition-group@^4.4.5: loose-envify "^1.4.0" prop-types "^15.6.2" -react@^17.0.2: +react@17.0.2, react@^17.0.2: version "17.0.2" resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037" integrity sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==