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

Improve error reporting when things go wrong while generating NEURON code: to enable the use to have some idea of where to look #106

Draft
wants to merge 2 commits into
base: feat/nrn-cvode
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public String toString()
ref = "=== Unable to determine reference: " + ex;
}

ref += super.toString()
ref += "\n" + super.toString()
+ "\n ** Neuron ref: " + ref
+ "\n popsOrComponents: " + popsOrComponents
+ "\n targetComp: " + targetComp
Expand Down
48 changes: 32 additions & 16 deletions src/main/java/org/neuroml/export/neuron/NeuronWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,7 @@ else if(cc.getComponentType().isOrExtends(NeuroMLElements.CONTINUOUS_CONNECTION_
processInputLists(main, targetComp);
processExplicitInputs(main, targetComp);

E.info("Setting up recorders...");
main.append(bIndent+"trec = h.Vector()\n");
main.append(bIndent+"trec.record(h._ref_t)\n\n");

Expand Down Expand Up @@ -1439,28 +1440,43 @@ else if(cc.getComponentType().isOrExtends(NeuroMLElements.CONTINUOUS_CONNECTION_
String quantity = colComp.getStringValue("quantity");
String scale = "1";

LEMSQuantityPathNeuron lqp = new LEMSQuantityPathNeuron(quantity, scale, targetComp, compMechNamesHoc, popsOrComponents, compIdsVsCells, hocRefsVsInputs, lems);
LEMSQuantityPathNeuron lqp = null;
try
{
lqp = new LEMSQuantityPathNeuron(quantity, scale, targetComp, compMechNamesHoc, popsOrComponents, compIdsVsCells, hocRefsVsInputs, lems);

//System.out.println("lqp: "+lqp);
//System.out.println("lqp: "+lqp);

columnsPre.get(outfileId).add(bIndent+"# Column: " + lqp.getQuantity());
columnsPre.get(outfileId).add(bIndent+"h(' objectvar v_" + colId + " ')");
columnsPre.get(outfileId).add(bIndent+"h(' { v_" + colId + " = new Vector() } ')");
columnsPre.get(outfileId).add(bIndent+"h(' { v_" + colId + ".record(&" + lqp.getNeuronVariableReference() + ") } ')");
columnsPre.get(outfileId).add(bIndent+"if self.abs_tol is None or self.rel_tol is None:\n");
columnsPre.get(outfileId).add(bIndent+" h.v_" + colId + ".resize((h.tstop * h.steps_per_ms) + 1)");
columnsPre.get(outfileId).add(bIndent+"# Column: " + lqp.getQuantity());
columnsPre.get(outfileId).add(bIndent+"h(' objectvar v_" + colId + " ')");
columnsPre.get(outfileId).add(bIndent+"h(' { v_" + colId + " = new Vector() } ')");
columnsPre.get(outfileId).add(bIndent+"h(' { v_" + colId + ".record(&" + lqp.getNeuronVariableReference() + ") } ')");
columnsPre.get(outfileId).add(bIndent+"if self.abs_tol is None or self.rel_tol is None:\n");
columnsPre.get(outfileId).add(bIndent+" h.v_" + colId + ".resize((h.tstop * h.steps_per_ms) + 1)");

float conv = NRNUtils.getNeuronUnitFactor(lqp.getDimension().getName());
String factor = (conv == 1) ? "" : " / " + conv;
float conv = NRNUtils.getNeuronUnitFactor(lqp.getDimension().getName());
String factor = (conv == 1) ? "" : " / " + conv;

columnsPost0.get(outfileId).add(bIndent+
"py_v_" + colId + " = [ float(x " + factor + ") for x in h.v_" + colId + ".to_python() ] # Convert to Python list for speed, variable has dim: " + lqp.getDimension().getName());
columnsPost0.get(outfileId).add(bIndent+
"py_v_" + colId + " = [ float(x " + factor + ") for x in h.v_" + colId + ".to_python() ] # Convert to Python list for speed, variable has dim: " + lqp.getDimension().getName());

/*columnsPostTraces.get(outfileId).add(
" + '%e\\t'%(py_v_" + colId + "[i]) ");*/
/*columnsPostTraces.get(outfileId).add(
" + '%e\\t'%(py_v_" + colId + "[i]) ");*/

columnsPostTraces.get(outfileId).add("%e\\t");
writingVariables.get(outfileId).add("py_v_" + colId + "[i], ");
columnsPostTraces.get(outfileId).add("%e\\t");
writingVariables.get(outfileId).add("py_v_" + colId + "[i], ");
}
catch(NullPointerException e){
String err = "Error processing outputfile quantity: " + quantity + "\n";
try {
err += "Reference: " + lqp + "\n";
throw new ContentError(err + e);
}
catch(NullPointerException ex)
{
throw new ContentError(err + ex);
}
}

}
}
Expand Down