Ejemplo n.º 1
0
def verify1():
    """Basic test of the extension module."""
    g = Grid2Deff(dx=0.5, dy=1)
    f_exact = g(f1)  # NumPy computation

    expression1 = StringFunction('x + 2*y',
                                 independent_variables=('x','y'),
                                 globals=globals())

    f = g.ext_gridloop1(f1)
    print 'f computed by external gridloop1 function and f1:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    f = g.ext_gridloop2(f1)
    print 'f computed by external gridloop2 function and f1:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    f = g.ext_gridloop1(expression1)
    print 'f computed by external gridloop1 function and StringFunction:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    f = g.ext_gridloop2(expression1)
    print 'f computed by external gridloop2 function and StringFunction:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    fast_func = expression1.__call__
    f = g.ext_gridloop2(fast_func)
    print 'f computed by external gridloop2 function and StringFunction.__call__:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    f = g(expression1)
    print 'f computed by __call__ and StringFunction:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    # check printing:
    print 'array seen from Python:'
    g.dump(f)
    if 'dump' in dir(ext_gridloop):
        print 'array seen from Fortran (transposed, but right values):'
        ext_gridloop.dump(f, g.xcoor, g.ycoor)
Ejemplo n.º 2
0
def verify1():
    """Basic test of the extension module."""
    g = Grid2Deff(dx=0.5, dy=1)
    f_exact = g(f1)  # NumPy computation

    expression1 = StringFunction('x + 2*y',
                                 independent_variables=('x', 'y'),
                                 globals=globals())

    f = g.ext_gridloop1(f1)
    print 'f computed by external gridloop1 function and f1:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    f = g.ext_gridloop2(f1)
    print 'f computed by external gridloop2 function and f1:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    f = g.ext_gridloop1(expression1)
    print 'f computed by external gridloop1 function and StringFunction:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    f = g.ext_gridloop2(expression1)
    print 'f computed by external gridloop2 function and StringFunction:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    fast_func = expression1.__call__
    f = g.ext_gridloop2(fast_func)
    print 'f computed by external gridloop2 function and StringFunction.__call__:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    f = g(expression1)
    print 'f computed by __call__ and StringFunction:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    # check printing:
    print 'array seen from Python:'
    g.dump(f)
    if 'dump' in dir(ext_gridloop):
        print 'array seen from Fortran (transposed, but right values):'
        ext_gridloop.dump(f, g.xcoor, g.ycoor)
Ejemplo n.º 3
0
def verify1():
    g = Grid2Deff2(dx=0.5, dy=1)
    f_exact = g(f1)  # NumPy computation
    f = g.ext_gridloop1(f1)
    print 'f computed by external gridloop1 function:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'
    f = g.ext_gridloop2(f1)
    print 'f computed by external gridloop2 function:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    # check printing:
    print 'array seen from Python:'
    g.dump(f)
    if 'dump' in dir(ext_gridloop):
        print 'array seen from Fortran (transposed, but right values):'
        ext_gridloop.dump(f, g.xcoor, g.ycoor)
Ejemplo n.º 4
0
def verify1():
    g = Grid2Deff2(dx=0.5, dy=1)
    f_exact = g(f1)
    f = g.ext_gridloop1(f1)
    print 'f computed by external gridloop1 function:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'
    f = g.ext_gridloop2(f1)
    print 'f computed by external gridloop2 function:\n', f
    if allclose(f, f_exact, atol=1.0E-10, rtol=1.0E-12):
        print 'f is correct'

    # check printing:
    print 'array seen from Python:'
    g.dump(f)
    if 'dump' in dir(ext_gridloop):
        print 'array seen from Fortran (transposed, but right values):'
        ext_gridloop.dump(f, g.xcoor, g.ycoor)