diff --git a/.github/workflows/ci_test_all.yml b/.github/workflows/ci_test_all.yml new file mode 100644 index 000000000..e540681e9 --- /dev/null +++ b/.github/workflows/ci_test_all.yml @@ -0,0 +1,52 @@ +name: CI Test script + +on: + push: + branches: [ main, development, experimental, test*, nml* ] + pull_request: + branches: [ main, development, experimental, test*, nml* ] + +jobs: + + checks: + name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }} + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + python-version: [ "3.10"] + runs-on: [ubuntu-latest] + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install HDF5 for pytables on macos-14/latest + if: ${{ matrix.runs-on == 'macos-latest' }} + run: | + brew install hdf5 + + - name: Install graphviz + uses: ts-graphviz/setup-graphviz@v2 + with: + # Skip to run brew update command on macOS. + macos-skip-brew-update: 'true' # default false + + - name: Run test script + run: | + export NEURON_HOME=$pythonLocation + ./test_all.sh + + - name: Version info for installed packages + run: | + pip list + + + + + - name: Final version info for optional installed packages + run: | + pip list diff --git a/docs/sphinx/source/api/export_format/MDF/images/abc_conditions.png b/docs/sphinx/source/api/export_format/MDF/images/abc_conditions.png index 0c6ed7095..5883c83c8 100644 Binary files a/docs/sphinx/source/api/export_format/MDF/images/abc_conditions.png and b/docs/sphinx/source/api/export_format/MDF/images/abc_conditions.png differ diff --git a/docs/sphinx/source/api/export_format/MDF/images/switched_rlc_circuit.png b/docs/sphinx/source/api/export_format/MDF/images/switched_rlc_circuit.png new file mode 100644 index 000000000..f9d5b94e6 Binary files /dev/null and b/docs/sphinx/source/api/export_format/MDF/images/switched_rlc_circuit.png differ diff --git a/docs/sphinx/source/api/export_format/MDF/images/switched_rlc_plot.png b/docs/sphinx/source/api/export_format/MDF/images/switched_rlc_plot.png new file mode 100644 index 000000000..e9b6fcd41 Binary files /dev/null and b/docs/sphinx/source/api/export_format/MDF/images/switched_rlc_plot.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/ABCD.mdf.png b/docs/sphinx/source/api/export_format/NeuroML/ABCD.mdf.png index 5e5cd48a0..c21ed0509 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/ABCD.mdf.png and b/docs/sphinx/source/api/export_format/NeuroML/ABCD.mdf.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimABCD.png b/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimABCD.png index 398fc3cca..98b10485d 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimABCD.png and b/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimABCD.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimFN.png b/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimFN.png index 0cf55dead..d282d58d7 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimFN.png and b/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimFN.png differ diff --git a/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimIzhikevichTest.png b/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimIzhikevichTest.png index e85f0ea77..ea4574211 100644 Binary files a/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimIzhikevichTest.png and b/docs/sphinx/source/api/export_format/NeuroML/LEMS_SimIzhikevichTest.png differ diff --git a/docs/sphinx/source/api/export_format/PyTorch/inception.png b/docs/sphinx/source/api/export_format/PyTorch/inception.png index e8fdcb38d..7b70f7027 100644 Binary files a/docs/sphinx/source/api/export_format/PyTorch/inception.png and b/docs/sphinx/source/api/export_format/PyTorch/inception.png differ diff --git a/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf_torchviz.png b/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf_torchviz.png index 53344ea2d..30099da9b 100644 Binary files a/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf_torchviz.png and b/docs/sphinx/source/api/export_format/PyTorch/simple_pytorch_to_mdf_torchviz.png differ diff --git a/examples/MDF/RNN/IAFs.nmllite.json b/examples/MDF/RNN/IAFs.nmllite.json index eeca660ae..4c843b710 100644 --- a/examples/MDF/RNN/IAFs.nmllite.json +++ b/examples/MDF/RNN/IAFs.nmllite.json @@ -1,9 +1,9 @@ { "iaf_example": { - "version": "NeuroMLlite v0.5.3", + "version": "NeuroMLlite v0.6.0", "notes": "NeuroMLlite export of MDF graph: iaf_example", "cells": { - "input_node__instance": { + "current_input_node__instance": { "lems_source_file": "iaf_example_lems_definitions.xml" }, "pre__instance": { @@ -11,6 +11,9 @@ }, "post__instance": { "lems_source_file": "iaf_example_lems_definitions.xml" + }, + "syn_post__instance": { + "lems_source_file": "iaf_example_lems_definitions.xml" } }, "synapses": { @@ -20,14 +23,17 @@ "silentSyn_proj_input_edge": { "lems_source_file": "iaf_example_lems_definitions.xml" }, + "silentSyn_proj_post_internal_edge": { + "lems_source_file": "iaf_example_lems_definitions.xml" + }, "silentSyn_proj_syn_edge": { "lems_source_file": "iaf_example_lems_definitions.xml" } }, "populations": { - "input_node": { + "current_input_node": { "size": 1, - "component": "input_node__instance", + "component": "current_input_node__instance", "properties": { "color": "0.2 0.2 0.2", "radius": 3 @@ -48,11 +54,19 @@ "color": "0.2 0.2 0.2", "radius": 3 } + }, + "syn_post": { + "size": 1, + "component": "syn_post__instance", + "properties": { + "color": "0.2 0.2 0.2", + "radius": 3 + } } }, "projections": { "proj_input_edge": { - "presynaptic": "input_node", + "presynaptic": "current_input_node", "postsynaptic": "pre", "synapse": "rsDL", "pre_synapse": "silentSyn_proj_input_edge", @@ -62,9 +76,20 @@ "probability": 1 } }, + "proj_post_internal_edge": { + "presynaptic": "syn_post", + "postsynaptic": "post", + "synapse": "rsDL", + "pre_synapse": "silentSyn_proj_post_internal_edge", + "type": "continuousProjection", + "weight": 1, + "random_connectivity": { + "probability": 1 + } + }, "proj_syn_edge": { "presynaptic": "pre", - "postsynaptic": "post", + "postsynaptic": "syn_post", "synapse": "rsDL", "pre_synapse": "silentSyn_proj_syn_edge", "type": "continuousProjection", diff --git a/examples/MDF/RNN/Simiaf_example.json b/examples/MDF/RNN/Simiaf_example.json index 49c8a4b98..1e3b96ec4 100644 --- a/examples/MDF/RNN/Simiaf_example.json +++ b/examples/MDF/RNN/Simiaf_example.json @@ -1,29 +1,22 @@ { "Simiaf_example": { - "version": "NeuroMLlite v0.5.3", + "version": "NeuroMLlite v0.6.0", "network": "IAFs.nmllite.json", "duration": 100000.0, "dt": 10.0, "seed": 123, "record_variables": { "time": { - "input_node": 0 + "current_input_node": 0 }, - "out_port": { - "input_node": 0 + "current_output": { + "current_input_node": 0, + "syn_post": 0 }, "current_input": { "pre": 0, "post": 0 }, - "spike_input": { - "pre": 0, - "post": 0 - }, - "syn_i": { - "pre": 0, - "post": 0 - }, "spiking": { "pre": 0, "post": 0 @@ -32,13 +25,19 @@ "pre": 0, "post": 0 }, - "out_port_v": { + "v_output": { "pre": 0, "post": 0 }, - "out_port_spiking": { + "spiking_output": { "pre": 0, "post": 0 + }, + "spike_input": { + "syn_post": 0 + }, + "syn_i": { + "syn_post": 0 } } } diff --git a/examples/MDF/RNN/regenerate.sh b/examples/MDF/RNN/regenerate.sh index 13796379d..6a6b140ef 100755 --- a/examples/MDF/RNN/regenerate.sh +++ b/examples/MDF/RNN/regenerate.sh @@ -12,4 +12,4 @@ python generate_iaf.py -run -net -nogui python generate_iaf.py -run -net2 -nogui #Fix dimensions! #python generate_iaf.py -neuroml -pynml LEMS_Simiaf_example.xml -lems-graph +#pynml LEMS_Simiaf_example.xml -lems-graph diff --git a/examples/MDF/SwitchedRLC_Circuit.json b/examples/MDF/SwitchedRLC_Circuit.json new file mode 100644 index 000000000..209f7f2f0 --- /dev/null +++ b/examples/MDF/SwitchedRLC_Circuit.json @@ -0,0 +1,75 @@ +{ + "SwitchedRLC_Circuit": { + "format": "ModECI MDF v0.4", + "generating_application": "Python modeci-mdf v0.4.11", + "metadata": { + "preferred_duration": 2, + "preferred_dt": 0.001 + }, + "graphs": { + "SwitchedRLC_Circuit": { + "nodes": { + "V": { + "parameters": { + "Vs": { + "conditions": [ + { + "id": "off", + "test": "time<0.5", + "value": "0" + }, + { + "id": "on", + "test": "time>=0.5", + "value": 0.1 + } + ] + }, + "R": { + "metadata": { + "description": "Resistance in Ohms" + }, + "value": 100 + }, + "L": { + "metadata": { + "description": "Inductance in Henrys" + }, + "value": 1 + }, + "C": { + "value": 0.001 + }, + "time": { + "default_initial_value": 0, + "time_derivative": "1" + }, + "V": { + "default_initial_value": 0, + "time_derivative": "i_C /C" + }, + "i_R": { + "value": "V / R" + }, + "i_L": { + "default_initial_value": 0, + "time_derivative": "(Vs - V)/L" + }, + "i_C": { + "value": "i_L-i_R" + } + }, + "output_ports": { + "V_out": { + "value": "V" + }, + "i_L_out": { + "value": "i_L" + } + } + } + } + } + } + } +} diff --git a/examples/MDF/SwitchedRLC_Circuit.yaml b/examples/MDF/SwitchedRLC_Circuit.yaml new file mode 100644 index 000000000..973930418 --- /dev/null +++ b/examples/MDF/SwitchedRLC_Circuit.yaml @@ -0,0 +1,47 @@ +SwitchedRLC_Circuit: + format: ModECI MDF v0.4 + generating_application: Python modeci-mdf v0.4.11 + metadata: + preferred_duration: 2 + preferred_dt: 0.001 + graphs: + SwitchedRLC_Circuit: + nodes: + V: + parameters: + Vs: + conditions: + - id: 'off' + test: time<0.5 + value: '0' + - id: 'on' + test: time>=0.5 + value: 0.1 + R: + metadata: + description: Resistance in Ohms + value: 100 + L: + metadata: + description: Inductance in Henrys + value: 1 + C: + value: 0.001 + time: + default_initial_value: 0 + time_derivative: '1' + V: + default_initial_value: 0 + time_derivative: i_C /C + i_R: + value: V / R + i_L: + default_initial_value: 0 + time_derivative: (Vs - V)/L + i_C: + value: i_L-i_R + output_ports: + V_out: + value: V + i_L_out: + value: i_L diff --git a/examples/MDF/conditions/images/composite_example.png b/examples/MDF/conditions/images/composite_example.png index 4e7945dca..09aa37d1f 100644 Binary files a/examples/MDF/conditions/images/composite_example.png and b/examples/MDF/conditions/images/composite_example.png differ diff --git a/examples/MDF/images/abc_conditions.png b/examples/MDF/images/abc_conditions.png index 0c6ed7095..5883c83c8 100644 Binary files a/examples/MDF/images/abc_conditions.png and b/examples/MDF/images/abc_conditions.png differ diff --git a/examples/MDF/images/switched_rlc_circuit.png b/examples/MDF/images/switched_rlc_circuit.png new file mode 100644 index 000000000..f9d5b94e6 Binary files /dev/null and b/examples/MDF/images/switched_rlc_circuit.png differ diff --git a/examples/MDF/images/switched_rlc_plot.png b/examples/MDF/images/switched_rlc_plot.png new file mode 100644 index 000000000..e9b6fcd41 Binary files /dev/null and b/examples/MDF/images/switched_rlc_plot.png differ diff --git a/examples/MDF/newton.py b/examples/MDF/newton.py index 62130e4b0..75628067d 100644 --- a/examples/MDF/newton.py +++ b/examples/MDF/newton.py @@ -52,13 +52,13 @@ def main(): s.append(eg.enodes["cool_node"].evaluable_outputs["out_port"].curr_value) t += dt + # Plotting the results + plt.plot(times, s) + plt.xlabel("Time") + plt.ylabel("Temperature") + plt.title("Newton's Cooling Law Simulation") + plt.savefig("newton_plot.png") if "-nogui" not in sys.argv: - # Plotting the results - plt.plot(times, s) - plt.xlabel("Time") - plt.ylabel("Temperature") - plt.title("Newton's Cooling Law Simulation") - plt.savefig("newton_plot.png") plt.show() if "-graph" in sys.argv: diff --git a/examples/MDF/switched_rlc.py b/examples/MDF/switched_rlc.py new file mode 100644 index 000000000..4346c824d --- /dev/null +++ b/examples/MDF/switched_rlc.py @@ -0,0 +1,133 @@ +from modeci_mdf.mdf import * +import os +from modeci_mdf.utils import simple_connect +import sys +from modeci_mdf.execution_engine import EvaluableGraph +import matplotlib.pyplot as plt + + +def run_simulation(mod_graph, duration=2, dt=0.001): + eg = EvaluableGraph(mod_graph, verbose=False) + t = 0 + times = [] + Vs_values = [] + V_values = [] + i_L_values = [] + i_R_values = [] + i_C_values = [] + + while t <= duration: + times.append(t) + if t == 0: + eg.evaluate() + else: + eg.evaluate(time_increment=dt) + + i_L_values.append(eg.enodes["V"].evaluable_outputs["i_L_out"].curr_value) + i_R_values.append(eg.enodes["V"].evaluable_parameters["i_R"].curr_value) + i_C_values.append(eg.enodes["V"].evaluable_parameters["i_C"].curr_value) + Vs_values.append(eg.enodes["V"].evaluable_parameters["Vs"].curr_value) + V = eg.enodes["V"].evaluable_parameters["V"].curr_value + V_values.append(V) + t += dt + + print( + "Finished simulation of MDF model: %s of duration: %s sec" + % (mod_graph.id, duration) + ) + + plt.figure(figsize=(10, 5)) + plt.plot(times, i_L_values, label="Inductor Current (i_L)") + plt.plot(times, i_R_values, label="Resistor Current (i_R)") + plt.plot(times, i_C_values, label="Capacitor Current (i_C)") + plt.plot(times, V_values, label="Voltage (V)") + plt.xlabel("Time (s)") + plt.ylabel("Values") + plt.title("Switched RLC Circuit Simulation Results") + plt.legend() + plt.savefig("switched_rlc_plot.png") + if "-nogui" not in sys.argv: + plt.show() + + return times, i_L_values, i_R_values, i_C_values, V_values + + +def main(): + parameters = { + "R": 100, # Resistance in Ohms + "L": 1, # Inductance in Henrys + "C": 1e-3, # Capacitance in Farads + "Vb": 0.1, # Battery Voltage in Volts + } + parameter_descriptions = { + "R": "Resistance in Ohms", + "L": "Inductance in Henrys", + "C": "Capacitance in Farads", + "Vb": "Battery Voltage in Volts", + } + mod = Model( + id="SwitchedRLC_Circuit", + metadata={"preferred_duration": 2, "preferred_dt": 0.001}, + ) + mod_graph = Graph(id="SwitchedRLC_Circuit") + mod.graphs.append(mod_graph) + + node = Node(id="V") + + vs = ParameterCondition(id="off", test="time<0.5", value="0") + vb = ParameterCondition(id="on", test="time>=0.5", value=parameters["Vb"]) + voltage = Parameter(id="Vs") + voltage.conditions.append(vs) + voltage.conditions.append(vb) + node.parameters.append(voltage) + + node.parameters.append( + Parameter( + id="R", + value=parameters["R"], + metadata={"description": parameter_descriptions["R"]}, + ) + ) + node.parameters.append( + Parameter( + id="L", + value=parameters["L"], + metadata={"description": parameter_descriptions["L"]}, + ) + ) + node.parameters.append(Parameter(id="C", value=parameters["C"])) + + node.parameters.append( + Parameter(id="time", default_initial_value=0, time_derivative="1") + ) + node.parameters.append( + Parameter(id="V", default_initial_value=0, time_derivative="i_C /C") + ) + node.parameters.append(Parameter(id="i_R", value="V / R")) + node.parameters.append( + Parameter(id="i_L", default_initial_value=0, time_derivative="(Vs - V)/L") + ) + node.parameters.append(Parameter(id="i_C", value="i_L-i_R")) + + node.output_ports.append(OutputPort(id="V_out", value="V")) + node.output_ports.append(OutputPort(id="i_L_out", value="i_L")) + mod_graph.nodes.append(node) + new_file = mod.to_json_file("%s.json" % mod.id) + new_file = mod.to_yaml_file("%s.yaml" % mod.id) + + if "-graph" in sys.argv: + mod.to_graph_image( + engine="dot", + output_format="png", + view_on_render=False, + level=3, + filename_root="switched_rlc_circuit", + only_warn_on_fail=(os.name == "nt"), + ) + + if "-run" in sys.argv: + times, i_L_values, i_R_values, i_C_values, V_values = run_simulation(mod_graph) + + +if __name__ == "__main__": + main() diff --git a/examples/NeuroML/ABCD.json b/examples/NeuroML/ABCD.json index c1a912c09..4ae8044fa 100644 --- a/examples/NeuroML/ABCD.json +++ b/examples/NeuroML/ABCD.json @@ -1,6 +1,6 @@ { "ABCD": { - "version": "NeuroMLlite v0.5.9", + "version": "NeuroMLlite v0.6.0", "notes": "Example of a simplified network", "parameters": { "A_initial": 0.1, diff --git a/examples/NeuroML/ABCD.mdf.png b/examples/NeuroML/ABCD.mdf.png index 5e5cd48a0..c21ed0509 100644 Binary files a/examples/NeuroML/ABCD.mdf.png and b/examples/NeuroML/ABCD.mdf.png differ diff --git a/examples/NeuroML/ABCD.net.nml b/examples/NeuroML/ABCD.net.nml index 8a29509f4..996a1dc68 100644 --- a/examples/NeuroML/ABCD.net.nml +++ b/examples/NeuroML/ABCD.net.nml @@ -1,5 +1,5 @@ - - Generated by NeuroMLlite v0.5.9 + + Generated by NeuroMLlite v0.6.0 Generated network: ABCD Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/FN.json b/examples/NeuroML/FN.json index 3e02690f2..38f564e1e 100644 --- a/examples/NeuroML/FN.json +++ b/examples/NeuroML/FN.json @@ -1,6 +1,6 @@ { "FN": { - "version": "NeuroMLlite v0.5.9", + "version": "NeuroMLlite v0.6.0", "notes": "FitzHugh Nagumo cell model - originally specified in NeuroML/LEMS", "parameters": { "initial_w": 0.0, diff --git a/examples/NeuroML/FN.net.nml b/examples/NeuroML/FN.net.nml index 28c0b9bcf..8087b3bfe 100644 --- a/examples/NeuroML/FN.net.nml +++ b/examples/NeuroML/FN.net.nml @@ -1,5 +1,5 @@ - - Generated by NeuroMLlite v0.5.9 + + Generated by NeuroMLlite v0.6.0 Generated network: FN Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/IzhikevichTest.net.nml b/examples/NeuroML/IzhikevichTest.net.nml index 95490bdd8..1b9da89eb 100644 --- a/examples/NeuroML/IzhikevichTest.net.nml +++ b/examples/NeuroML/IzhikevichTest.net.nml @@ -1,5 +1,5 @@ - - Generated by NeuroMLlite v0.5.9 + + Generated by NeuroMLlite v0.6.0 Generated network: IzhikevichTest Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/IzhikevichTest.nmllite.yaml b/examples/NeuroML/IzhikevichTest.nmllite.yaml index 7a271c1c3..62888fbbe 100644 --- a/examples/NeuroML/IzhikevichTest.nmllite.yaml +++ b/examples/NeuroML/IzhikevichTest.nmllite.yaml @@ -1,5 +1,5 @@ IzhikevichTest: - version: NeuroMLlite v0.5.9 + version: NeuroMLlite v0.6.0 notes: Example Izhikevich parameters: N: 1 diff --git a/examples/NeuroML/LEMS_SimABCD.png b/examples/NeuroML/LEMS_SimABCD.png index 398fc3cca..98b10485d 100644 Binary files a/examples/NeuroML/LEMS_SimABCD.png and b/examples/NeuroML/LEMS_SimABCD.png differ diff --git a/examples/NeuroML/LEMS_SimABCD.xml b/examples/NeuroML/LEMS_SimABCD.xml index 60f9f1681..ca3616995 100644 --- a/examples/NeuroML/LEMS_SimABCD.xml +++ b/examples/NeuroML/LEMS_SimABCD.xml @@ -2,7 +2,7 @@ diff --git a/examples/NeuroML/LEMS_SimFN.png b/examples/NeuroML/LEMS_SimFN.png index 0cf55dead..d282d58d7 100644 Binary files a/examples/NeuroML/LEMS_SimFN.png and b/examples/NeuroML/LEMS_SimFN.png differ diff --git a/examples/NeuroML/LEMS_SimFN.xml b/examples/NeuroML/LEMS_SimFN.xml index 46cc5f1b1..206a9299b 100644 --- a/examples/NeuroML/LEMS_SimFN.xml +++ b/examples/NeuroML/LEMS_SimFN.xml @@ -2,7 +2,7 @@ diff --git a/examples/NeuroML/LEMS_SimIzhikevichTest.png b/examples/NeuroML/LEMS_SimIzhikevichTest.png index e85f0ea77..ea4574211 100644 Binary files a/examples/NeuroML/LEMS_SimIzhikevichTest.png and b/examples/NeuroML/LEMS_SimIzhikevichTest.png differ diff --git a/examples/NeuroML/LEMS_SimIzhikevichTest.xml b/examples/NeuroML/LEMS_SimIzhikevichTest.xml index c943d4a53..54490d7d3 100644 --- a/examples/NeuroML/LEMS_SimIzhikevichTest.xml +++ b/examples/NeuroML/LEMS_SimIzhikevichTest.xml @@ -2,7 +2,7 @@ diff --git a/examples/NeuroML/PyNN/HH.net.nml b/examples/NeuroML/PyNN/HH.net.nml index 256e4546e..da98d6956 100644 --- a/examples/NeuroML/PyNN/HH.net.nml +++ b/examples/NeuroML/PyNN/HH.net.nml @@ -1,5 +1,5 @@ - - Generated by NeuroMLlite v0.5.9 + + Generated by NeuroMLlite v0.6.0 Generated network: HH Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/PyNN/InputWeights.net.nml b/examples/NeuroML/PyNN/InputWeights.net.nml index d5ab31f80..437728db7 100644 --- a/examples/NeuroML/PyNN/InputWeights.net.nml +++ b/examples/NeuroML/PyNN/InputWeights.net.nml @@ -1,5 +1,5 @@ - - Generated by NeuroMLlite v0.5.9 + + Generated by NeuroMLlite v0.6.0 Generated network: InputWeights Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/PyNN/Net1.net.nml b/examples/NeuroML/PyNN/Net1.net.nml index d806e8689..87c1eb1c3 100644 --- a/examples/NeuroML/PyNN/Net1.net.nml +++ b/examples/NeuroML/PyNN/Net1.net.nml @@ -1,5 +1,5 @@ - - Generated by NeuroMLlite v0.5.9 + + Generated by NeuroMLlite v0.6.0 Generated network: Net1 Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/PyNN/OneCell.net.nml b/examples/NeuroML/PyNN/OneCell.net.nml index 180cdd676..b2361b0a6 100644 --- a/examples/NeuroML/PyNN/OneCell.net.nml +++ b/examples/NeuroML/PyNN/OneCell.net.nml @@ -1,5 +1,5 @@ - - Generated by NeuroMLlite v0.5.9 + + Generated by NeuroMLlite v0.6.0 Generated network: OneCell Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/PyNN/SimpleNet.net.nml b/examples/NeuroML/PyNN/SimpleNet.net.nml index eedb0c5cd..1860cfbbc 100644 --- a/examples/NeuroML/PyNN/SimpleNet.net.nml +++ b/examples/NeuroML/PyNN/SimpleNet.net.nml @@ -1,5 +1,5 @@ - - Generated by NeuroMLlite v0.5.9 + + Generated by NeuroMLlite v0.6.0 Generated network: SimpleNet Generation seed: 1234 NeuroMLlite parameters: diff --git a/examples/NeuroML/SimABCD.json b/examples/NeuroML/SimABCD.json index 695b19ad5..c111c11fd 100644 --- a/examples/NeuroML/SimABCD.json +++ b/examples/NeuroML/SimABCD.json @@ -1,6 +1,6 @@ { "SimABCD": { - "version": "NeuroMLlite v0.5.9", + "version": "NeuroMLlite v0.6.0", "network": "ABCD.json", "duration": 5000.0, "dt": 100.0, diff --git a/examples/NeuroML/SimFN.json b/examples/NeuroML/SimFN.json index f1b68db9b..4b90990b7 100644 --- a/examples/NeuroML/SimFN.json +++ b/examples/NeuroML/SimFN.json @@ -1,6 +1,6 @@ { "SimFN": { - "version": "NeuroMLlite v0.5.9", + "version": "NeuroMLlite v0.6.0", "network": "FN.json", "duration": 100.0, "dt": 0.05, diff --git a/examples/NeuroML/SimIzhikevichTest.yaml b/examples/NeuroML/SimIzhikevichTest.yaml index 040a7bc42..2e418d847 100644 --- a/examples/NeuroML/SimIzhikevichTest.yaml +++ b/examples/NeuroML/SimIzhikevichTest.yaml @@ -1,5 +1,5 @@ SimIzhikevichTest: - version: NeuroMLlite v0.5.9 + version: NeuroMLlite v0.6.0 network: IzhikevichTest.nmllite.yaml duration: 700.0 dt: 0.025 diff --git a/examples/PyTorch/inception.png b/examples/PyTorch/inception.png index e8fdcb38d..7b70f7027 100644 Binary files a/examples/PyTorch/inception.png and b/examples/PyTorch/inception.png differ diff --git a/examples/PyTorch/simple_pytorch_to_mdf_torchviz.png b/examples/PyTorch/simple_pytorch_to_mdf_torchviz.png index 53344ea2d..30099da9b 100644 Binary files a/examples/PyTorch/simple_pytorch_to_mdf_torchviz.png and b/examples/PyTorch/simple_pytorch_to_mdf_torchviz.png differ diff --git a/setup.cfg b/setup.cfg index ca8118ecc..855f25f20 100644 --- a/setup.cfg +++ b/setup.cfg @@ -60,7 +60,10 @@ psyneulink = neuroml = pyNeuroML>=1.0.10 neuromllite>=0.5.6 - PyNN==0.10.1 + PyNN>=0.10.1 + +neuroml_simulators = + neuron tensorflow = @@ -90,7 +93,7 @@ optional = torchviz netron torch>=1.11.0 - torchvision + torchvision<=0.20 # it's actually psyneulink limiting our version of torch, but the latest torchvision fails with earlier torch... h5py all_except_psyneulink = @@ -98,13 +101,17 @@ all_except_psyneulink = modeci-mdf[optional] modeci-mdf[neuroml] -all = - modeci-mdf[all_except_psyneulink] - modeci-mdf[psyneulink] dev = + pre-commit modeci-mdf[test] +all = + modeci-mdf[all_except_psyneulink] + modeci-mdf[psyneulink] + modeci-mdf[neuroml_simulators] + modeci-mdf[dev] + [options.packages.find] where = src exclude = diff --git a/src/modeci_mdf/execution_engine.py b/src/modeci_mdf/execution_engine.py index 50558b498..e54297571 100644 --- a/src/modeci_mdf/execution_engine.py +++ b/src/modeci_mdf/execution_engine.py @@ -586,15 +586,26 @@ def evaluate( if len(self.parameter.conditions) > 0: for condition in self.parameter.conditions: + + test = ( + condition.test if hasattr(condition, "test") else condition["test"] + ) + value = ( + condition.value + if hasattr(condition, "value") + else condition["value"] + ) + cond_id = condition.id if hasattr(condition, "id") else condition["id"] + cond_mask = evaluate_expr( - condition.test, + test, parameters, verbose=False, array_format=array_format, ) val_if_true = evaluate_expr( - condition.value, + value, parameters, verbose=False, array_format=array_format, @@ -603,7 +614,7 @@ def evaluate( if self.verbose: print( " --- Condition: %s: %s = %s: true? %s" - % (condition.id, condition.test, val_if_true, cond_mask) + % (cond_id, test, val_if_true, cond_mask) ) # e.g. if the parameter value is set only by a set of conditions... diff --git a/src/modeci_mdf/interfaces/graphviz/exporter.py b/src/modeci_mdf/interfaces/graphviz/exporter.py index 770b45d26..b928e0bcc 100644 --- a/src/modeci_mdf/interfaces/graphviz/exporter.py +++ b/src/modeci_mdf/interfaces/graphviz/exporter.py @@ -352,12 +352,20 @@ def mdf_to_graphviz( p.time_derivative, node ) for cond in p.conditions: - test = cond.test.replace(">", ">").replace("<", "<") + cond_test = ( + cond.test if hasattr(cond, "test") else cond["test"] + ) + cond_value = ( + cond.value if hasattr(cond, "value") else cond["value"] + ) + cond_id = cond.id if hasattr(cond, "id") else cond["id"] + + test = cond_test.replace(">", ">").replace("<", "<") v += "
{}: IF {} THEN {}={}".format( - cond.id, + cond_id, match_in_expr(test, node), format_param(p.id), - match_in_expr(cond.value, node), + match_in_expr(cond_value, node), ) info += "{}{} = {}".format( format_label(" "), diff --git a/src/modeci_mdf/interfaces/neuroml/exporter.py b/src/modeci_mdf/interfaces/neuroml/exporter.py index 18f7f22df..a9adbb22e 100644 --- a/src/modeci_mdf/interfaces/neuroml/exporter.py +++ b/src/modeci_mdf/interfaces/neuroml/exporter.py @@ -36,7 +36,11 @@ def mdf_to_neuroml( node_comp = "%s__instance" % node.id # Create the ComponentType which defines behaviour of the general class - ct = lems.ComponentType(node_comp_type, extends="baseCellMembPotDL") + ct = lems.ComponentType( + node_comp_type, + extends="baseCellMembPotDL", + description="LEMS ComponentType generated from MDF node definition", + ) for ip in node.input_ports: ct.add(lems.Attachments("ip_%s" % ip.id, "basePointCurrentDL")) @@ -133,7 +137,11 @@ def mdf_to_neuroml( on_start.actions.append(sa) if p.time_derivative: - td = lems.TimeDerivative(variable=p.id, value=p.time_derivative) + + ct.add(lems.Constant("SEC", "1s", "time")) + td = lems.TimeDerivative( + variable=p.id, value="(%s)/SEC" % p.time_derivative + ) ct.dynamics.add(td) if p.conditions: @@ -279,6 +287,7 @@ def mdf_to_neuroml( from modeci_mdf.utils import load_mdf, print_summary example = "../../../../examples/MDF/Simple.json" + example = "../../../../examples/MDF/States.json" verbose = True run = False if "-run" in sys.argv: diff --git a/test_all.sh b/test_all.sh index cf0792b17..4d09a4d19 100755 --- a/test_all.sh +++ b/test_all.sh @@ -6,9 +6,9 @@ pip install .[all] # Note this: # 1) runs examples to regenerate yaml/json... # 2) tests examples with simple_scheduler -python -m pytest -ra tests/*.py -python -m pytest -ra tests/interfaces/onnx/*.py -python -m pytest -ra tests/interfaces/pytorch/test_export.py +python -m pytest -ra -v tests/*.py +python -m pytest -rav tests/interfaces/onnx/*.py +python -m pytest -rav tests/interfaces/pytorch/test_export.py #python -m pytest -ra tests/interfaces/pytorch/test_import.py # inception taking v long cd examples/MDF @@ -21,7 +21,8 @@ python arrays.py -run python states.py -run -nogui python abc_conditions.py -run python params_funcs.py -run -python newton.py -run +python newton.py -run -nogui +python switched_rlc.py -run -nogui ## Test exporting to NeuroML @@ -51,6 +52,9 @@ mv params_funcs_example.gv.png images/params_funcs.png python -m modeci_mdf.interfaces.graphviz.exporter NewtonCoolingModel.yaml 3 -noview mv cooling_process.gv.png images/newton.png mv newton_plot.png images/newton_plot.png +python -m modeci_mdf.interfaces.graphviz.exporter SwitchedRLC_Circuit.yaml 3 -noview +mv SwitchedRLC_Circuit.gv.png images/switched_rlc_circuit.png +mv switched_rlc_plot.png images/switched_rlc_plot.png cd conditions python everyNCalls.py -graph @@ -104,4 +108,4 @@ cd ../../../docs python generate.py cd .. -pre-commit run --all-files +/bin/bash -c 'pre-commit run --all-files; echo Finished running pre-commit!' # Note: prevents error code when reformatting