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

fix: correct initialization of 2D arrays to allow dimensions with matching subscript names #101

Merged
merged 5 commits into from
Aug 17, 2021

Conversation

chrispcampbell
Copy link
Contributor

@chrispcampbell chrispcampbell commented Aug 4, 2021

Fixes #84

This fixes an issue that we encountered when trying a newer version of the C-ROADS model. See issue for more details.

The previous code would generate incorrect index values in the loop (for example, [i][i] instead of [i][j]) because it would look up the index of the subscript by name (and this would fail if the same subscript name appears in both dimensions). The new code looks up the index by position in the dimensions array rather than by name.

I updated the existing arrays_cname test case with an example that caused SDE to fail, but now passes with the fix in place.

Copy link
Collaborator

@ToddFincannon ToddFincannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this Vensim syntax works, but clearly it does. Good to have it covered.

@chrispcampbell
Copy link
Contributor Author

I'm surprised this Vensim syntax works, but clearly it does. Good to have it covered.

Yeah, there are a few places in the En-ROADS model where this sort of alias was used, so I guess it works in Vensim, and apparently also does in SDE though I didn't take the time to figure out how. I was tempted to change it to use the new alias syntax you added support for recently, but figured I'd leave it as is so that there's some amount of test coverage.

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

Successfully merging this pull request may close these issues.

2D array initialization is incorrect when dimensions have matching subscript names
2 participants