Skip to content

Commit

Permalink
Adding support for conditional_derived_variables
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Jan 27, 2017
1 parent 53136f1 commit ace214c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions docs/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

nml_src = "../NeuroML2CoreTypes"

IF="IF"
THEN="THEN"

def category(name, rows=1, type="label-info"):
return (" <td width=\"%s\" rowspan='%i'>\n"+ \
" <span class=\"label %s\">%s</span>\n"+ \
Expand All @@ -56,6 +59,7 @@ def format_expression(expr):
expr2 = expr2.replace(".leq.", "&lt;=")
expr2 = expr2.replace(".and.", "AND")
expr2 = expr2.replace(".eq.", "=")
expr2 = expr2.replace(".neq.", "!=")

return expr2

Expand Down Expand Up @@ -616,7 +620,7 @@ def add_comp_type_and_related(comp_type, added, indent, pre, nameInfo=""):

oc = eh
test = format_expression(oc.test)
oc_content += spacer4+"IF "+test+" THEN<br/>\n"
oc_content += spacer4+IF+" "+test+" "+THEN+"<br/>\n"

for ac in oc.actions:
if isinstance(ac, StateAssignment):
Expand Down Expand Up @@ -654,6 +658,18 @@ def add_comp_type_and_related(comp_type, added, indent, pre, nameInfo=""):
res=res+" (reduce method: "+dv.reduce+")"
contents += spacer4+"<b>"+dv.name+"</b> = "+res+spacer4+exposed_as(dv.exposure)+"<br/>\n"
if len(dynamics.derived_variables) > 0: contents += "<br/>\n"

if len(dynamics.conditional_derived_variables) > 0:
contents += "<span class=\"label\">Conditional Derived Variables</span><br/><br/>\n"
for cdv in dynamics.conditional_derived_variables:
for case in cdv.cases:
res = case.value
cond = IF+" "+format_expression(case.condition)+" "+THEN+"<br/>"+spacer4+spacer4 if case.condition else "OTHERWISE<br/>"+spacer4+spacer4
contents += spacer4+cond+"<b>"+cdv.name+"</b> = "+res+spacer4+exposed_as(cdv.exposure)+"<br/>\n"

contents += "<br/>\n"

if len(dynamics.conditional_derived_variables) > 0: contents += "<br/>\n"


if len(dynamics.time_derivatives) > 0:
Expand Down Expand Up @@ -686,7 +702,7 @@ def add_comp_type_and_related(comp_type, added, indent, pre, nameInfo=""):

oc = eh
test = format_expression(oc.test)
oc_content += spacer8+spacer4+"IF "+test+" THEN<br/>\n"
oc_content += spacer8+spacer4+IF+" "+test+" "+THEN+"<br/>\n"

for ac in oc.actions:
if isinstance(ac, StateAssignment):
Expand Down

0 comments on commit ace214c

Please sign in to comment.