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 upper case state variable name naming clash #766
Open
clinssen
wants to merge
1
commit into
nest:master
Choose a base branch
from
clinssen:fix_state_var
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes. The code will compile, but we still have an unchecked runtime problem. The function
insert_recordables
at line 131 inserts in the map as key the array's name in an upper case form and adds a_{i}
as the entry name in the recordables. So if we have an arrayx
withn
elements, we will insertX_{i}
fori in [1, n]
. With this in mind, the user might then want to create two variables in his nestml file, one array variable namedx
and another double variable namedX_1
. What will happen when inserting the recordables is that the double variablesX_1
will be inserted first, and then the array entries, but the map already containsX_1
, and therefore the first entry of the array will never be recorded.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about that, and I think the best way is to override the
find
function in the genericRecordableMap
as thecreate
function. Instead of inserting each entry of the array, we should only register a constant pointer to the array and only store its name asx
, and then we have to implement a logic that can resolve the global name to a local name (mappingx
tox_i
).Assume we have the following map : map : { "x" : [x1, x2,...., xn]}, and let's say we want to deliver
x_i
to theDataLoggingRequest
. Calling map.find("x_i"), should return a pair containingx
as the name and acallable
that can access the array at positioni
.With this, we can also save us runtime overhead. Assume that we have an array with size
n >M
(big number), and we are only interested in the result of the last entry to be recorded, but at the same time that entry depends on the previous entries. Firstly, the constructor will be very expensive as it must iterate over the entries and register them in the map, but from the python side, the user will only want to record the last entry. With the new suggested changes, the entries will be registered all together at once by having the whole array representing them, and then when setting therecord_from
inpynest
tox_i
, the find function should parse the input and split it to(x, i)
and then returns an access function to the array at positioni
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could keep it simple and add a check that if a vector variable
foo
exists, there exists no declaration in the model of a variable namedFOO
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, but u must prevent not just
FOO
but also everyFOO_i
fori < len(foo)