def test_invalid_code(): code = ''' PRO invalid_code this_is_invalid end ''' with GDLFile(code) as name: with pytest.raises(GDL.error): GDL.pro(name)
def test_invalid_code(): code = ''' PRO invalid_code this_is_invalid end ''' with GDLFile(code) as name: with pytest.raises(GDL.error): GDL.pro(name)
def test_invalid_code(): '''Call a function with some invalid GDL code''' code = ''' PRO invalid_code this_is_invalid end ''' with GDLFile(code) as name: with pytest.raises(GDL.error): GDL.pro(name, ret)
def test_invalid_code(): '''Call a function with some invalid GDL code''' code = ''' PRO invalid_code this_is_invalid end ''' with GDLFile(code) as name: with pytest.raises(GDL.error): GDL.pro(name)
def test_pro_user(): '''Call the setenv procedure via a user defined procedure''' code = ''' pro USER_SETENV, key, val SETENV, key + '=' + val print, GETENV(key) end ''' s = 'blabla' with GDLFile(code) as name: GDL.pro(name, 'T1', s)
def test_pro_user(): '''Call the setenv procedure via a user defined procedure''' code = ''' pro USER_SETENV, key, val SETENV, key + '=' + val print, GETENV(key) end ''' s = 'blabla' with GDLFile(code) as name: GDL.pro(name, 'T1', s)
def test_pro_setvalue(dtype): '''Call a user defined procedure that replaces the values of an array with its sinus. Note that GDL does not support changes in the arguments, so this test is expected to fail''' code = '''pro SETVALUE, arg arg[*] = sin(arg) end ''' with GDLFile(code) as name: arg = numpy.arange(-10, 10., 1.1).astype(dtype) ret = numpy.copy(arg) GDL.pro(name, ret) for a, r in zip(numpy.sin(arg), ret): assert a == r
def test_pro_arg_pass(arg): '''Call a user defined procedure that stores the value for different data types in a file''' code = ''' PRO pro_arg_pass, fname, arg openw, 5, fname printf, 5, arg close, 5 end ''' with GDLFile(code) as name: fname = os.tmpnam() GDL.pro(name, fname, arg) ret = open(fname).read().strip() os.unlink(fname) assert arg == arg.__class__(ret)
def test_pro_arg_pass(arg): '''Call a user defined procedure that stores the value for different data types in a file''' code = ''' PRO pro_arg_pass, fname, arg openw, 5, fname printf, 5, arg close, 5 end ''' with GDLFile(code) as name: fname = os.tmpnam() GDL.pro(name, fname, arg) ret = open(fname).read().strip() os.unlink(fname) assert arg == arg.__class__(ret)
def test_pro_setvalue(dtype): '''Call a user defined procedure that replaces the values of an array with its sinus. Note that GDL does not support changes in the arguments, so this test is expected to fail''' code = '''pro SETVALUE, arg arg[*] = sin(arg) end ''' with GDLFile(code) as name: arg = numpy.arange(-10, 10., 1.1).astype(dtype) ret = numpy.copy(arg) GDL.pro(name, ret) for a, r in zip(numpy.sin(arg), ret): assert a == r
def test_pro_arg_pass(arg): '''Call a user defined procedure that stores the value for different data types in a file''' code = ''' PRO pro_arg_pass, fname, arg openw, 5, fname printf, 5, arg close, 5 end ''' with GDLFile(code) as name: with warnings.catch_warnings(): warnings.simplefilter("ignore") fname = tempfile.mkstemp()[1] GDL.pro(name, fname, arg) ret = open(fname).read().strip() os.unlink(fname) assert arg == arg.__class__(ret)
def test_pro_internal(): '''Call the internal setenv procedure''' s = 'blabla' GDL.pro('setenv', 'T1=' + s)
def test_pro_internal(): '''Call the internal setenv procedure''' s = 'blabla' GDL.pro('setenv', 'T1=' + s)