Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readGDX( ) silently drops domain sets with the same name as a field when reading variables (probably equations, too) #1

Open
0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q opened this issue Aug 19, 2024 · 1 comment

Comments

@0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q

Minimal working example:

Sets
  something / foo, bar /
  level     / foo, bar /
;

Variables foo(level), bar(something);

foo.l(level)     = 1;
bar.l(something) = 1;

Execute_Unload 'foo.gdx', foo, bar;
lapply(readGDX('foo.gdx', c('foo', 'bar')), getElement, name = 'records')
# $foo
#   level marginal lower upper scale
# 1     1        0  -Inf   Inf     1
# 2     1        0  -Inf   Inf     1
# 
# $bar
#   something level marginal lower upper scale
# 1       foo     1        0  -Inf   Inf     1
# 2       bar     1        0  -Inf   Inf     1

The level set name collides with the level column of the variable, disappearing.

@abhosekar
Copy link
Contributor

Thanks for reporting. gamstransfer does not change the user supplied records data.frame as much as possible. This is a corner case where the keyword level clashes with the column name in the supplied records. This is a bug.

Note that readGDX and writeGDX are still undocumented functions that I don't recommend the users to use just yet. This is being developed to read GDX files with many symbols where the small amount of time to create a symbol object is a bottleneck. This is not usual but can happen in some cases. A typical example is a scalar GDX files. One should use the documented steps of creating a container and using the container method read.

m = Container$new()
m$read("foo.gdx")

The bug is independent of this method. I will notify as soon as the bug gets fixed. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants