Go to the documentation of this file.
38 return re.sub(
'\s',
'', data)
78 return re.sub(
'\s',
'', data)
86 alias (i,ii), (j,jj), (ij,iijj);
88 a(i) / #i 1 /, aa(ii) / #ii 2 /;
95 cmd = [os.path.join(ws.system_directory,
"gdxdump"), os.path.join(ws.working_directory, gdxfile)]
96 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
97 result, err = p.communicate()
98 result = re.sub(
'\s',
'', result.decode())
99 return result.lower() == expected_result.lower()
109 my_assert(len(alias_db) == 5, prefix +
"alias_db should have NrSymbols=5: i,j,ij,a,aa.")
114 my_assert(cnt_symbols == 5, prefix +
"'for sym in alias_db' should result in 5 symbols: i,j,ij,a,aa.")
117 my_assert(alias_db[
"ii"].name ==
"i", prefix +
"We should get set i when asking for alias ii.")
118 my_assert(alias_db[
"jj"].name ==
"j", prefix +
"We should get set j when asking for alias jj.")
119 my_assert(alias_db[
"iijj"].name ==
"ij", prefix +
"We should get set ij when asking for alias iijj.")
122 my_assert(alias_db.check_domains() ==
True, prefix +
"Check domains should be true")
123 my_assert(type(alias_db[
"aa"].domains[0])
is GamsSet, prefix +
"domain[0] of aa should be set")
124 my_assert((alias_db[
"aa"].domains[0]).name ==
"i", prefix +
"domain[0] of aa should point to i")
126 alias_db[
"ii"].delete_record(
"i1")
127 my_assert(alias_db.check_domains() ==
False, prefix +
"Check domains should be false after removal of i1")
128 alias_db[
"ii"].add_record(
"i1")
129 my_assert(alias_db.check_domains() ==
True, prefix +
"Check domains should be true after adding i1 again")
132 if __name__ ==
"__main__":
134 if len(sys.argv) > 1:
135 ws = GamsWorkspace(system_directory = sys.argv[1])
144 j1.out_db.export(
"outdb.gdx")
148 db = ws.add_database(source_database= j1.out_db)
153 db2 = ws.add_database()
154 ii = db2.add_set_dc(db[
"ii"].name, [
"*"], db[
"ii"].text)
155 db[
"ii"].copy_symbol(ii)
159 aa = db2.add_parameter_dc(db[
"aa"].name, [ii], db[
"aa"].text, )
160 aa_orig.copy_symbol(aa)
161 db2.export(
"db2.gdx")
166 my_assert(aa_orig.domains[0].name ==
"i",
"The domain set should be the original set")
167 my_assert(aa_orig.domains_as_strings[0] ==
"ii",
"The domain as string should be the alias name")
169 except Exception
as e:
170 raise Exception(
"\n###\n### Exception caught:" + str(e) +
"\n###")
def check_alias_logic(prefix, alias_db)
def same_gdx_dump(ws, gdxfile, expected_result)