Hey,
I think I’ve found a bug while trying to loop through all symbols in a gdx file with the Python API.
Consider the following code:
ws = gams.control.GamsWorkspace(system_directory=gams_path)
gdx_db = ws.add_database_from_gdx(gdx_file)
for sym in gdx_db:
print(sym)
It works fine with the 47.6.0 version of the Python API but if I upgrade it to 48.6.0, then there is the following error:
File “c:\Users\bfsan\OneDrive\Desktop\minimum.py”, line 13, in
for sym in gdx_db:
^^^^^^
File “C:\Users\bfsan\anaconda3\envs\test_gams\Lib\site-packages\gams\control\database.py”, line 1400, in next
return self.next()
^^^^^^^^^^^
File “C:\Users\bfsan\anaconda3\envs\test_gams\Lib\site-packages\gams\control\database.py”, line 1383, in next
self._check_for_gmd_error(_int_value_and_free(rc))
File “C:\Users\bfsan\anaconda3\envs\test_gams\Lib\site-packages\gams\control\database.py”, line 1289, in _check_for_gmd_error
raise gams.control.workspace.GamsException(msg, workspace)
gams.control.workspace.GamsException: Symbol index 28 is out of range
In this example, there were exactly 28 symbols in the gdx, so it seems to be some sort of off-by-one error.