-
Notifications
You must be signed in to change notification settings - Fork 89
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
Make PySD Created Variables Private #182
Comments
Just a quick update. I have been testing for a while now the leading underscore (for delay, smooth, trend, initial) for the model database and I haven't run into any of these problems anymore. The model database is limited to .mdl files currently so xmile might be different. But based on the answer from @alexprey it seems like xmile identifiers cannot begin with an underscore which in my opinion would solve the problem or at least make it highly unlikely to occur. |
Hi, @kaetze66, solution with adding underscores is fine, I'm already done this thing in my experimental branch and it works fine. |
As @kaetze66 pointed out in kaetze66@c84030b, sometimes in the processing of a variable we create a new variable that didn't exist before. This may create the possibility for namespace conflicts:
For example, a stock like:
Has a new object created which is the stateful object, which is called each time you access a stock variable.
Or, the INITIAL function:
Which becomes:
if the model already defines a variable named
initial_inflowa
(which is a completely reasonable thing to do), I'm not sure if the function that creates pysafe names will properly account for this in the namespace - its been a while since I looked at that part of the code.We need to put together a test model to try this explicitly (probably based on @kaetze66's ).
One way to fix it may be to make the created variables 'private' - by listing underscores before their names. we know no model variable will have that syntax.
The text was updated successfully, but these errors were encountered: