예제 #1
0
def test_quantityexpr():
    data = []

    for (a, b, check_with_gnu) in valid_quantity_exprs:
        print 'a:', a
        print 'b:', b
        A = NeuroUnitParser.QuantityExpr(a)
        print 'LOADING B'
        B = NeuroUnitParser.QuantityExpr(b)

        if check_with_gnu:
            verify_equivalence_with_gnuunits(a, b)
        print "typeA:", type(A)
        print "typeB:", type(B)

        pcA = ((A - B) / A).dimensionless()
        pcB = ((A - B) / B).dimensionless()
        data.append([
            a, b,
            "$%s$" % (A.FormatLatex()),
            "$%s$" % (B.FormatLatex()),
            str(pcA),
            str(pcB)
        ])

    header = "A|B|Parsed(A)|Parsed(B)|PC(A)|PC(B)".split("|")
    return Table(header=header, data=data)
library_manager = neurounits.NeuroUnitParser.File(neuron_def)
from neurounits import NeuroUnitParser as P


print library_manager



evaluator = EqnSimulator( library_manager.eqnsets[0] )
res = evaluator(
        time_data = np.linspace(0.0, 0.100, 1000),
        params={
            },
        state0In={
            'V':P.QuantityExpr('-52mV'),
            'm':P.QuantityExpr('0'),
            'h':P.QuantityExpr('0'),
            'kf':P.QuantityExpr('0'),
            'ks':P.QuantityExpr('0'),
            'ca_m':P.QuantityExpr('0'),
            }
        )

print 'Done Simulating'
print res
print res.keys()


#pylab.figure()
#pylab.plot(res['x'], res['y'])