-
Notifications
You must be signed in to change notification settings - Fork 62
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
Compile AgML under python 3 #646
base: main
Are you sure you want to change the base?
Conversation
…iffer. I think we are safe in just getting each element here.
…his will pass it through and we will catch w/ the compiler.
…. And the modulus comparison below will result in different formatting without an explicit cast to int here.
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.
Looks good!
To really test it we need to load python3 module by default
Co-authored-by: Dmitri Smirnov <[email protected]>
Co-authored-by: Dmitri Smirnov <[email protected]>
... which had been used for a test Co-authored-by: Dmitri Smirnov <[email protected]>
…hon 3) if ImportError raised Co-authored-by: Dmitri Smirnov <[email protected]>
Just a quick note. The geometry model is invariant IF the C++ and MORtran source codes generated by AgML are functionally identical when we use python 2.7 versus python 3. As noted above, we have this functional equivalence in the C++ code. On the MORtran side, we needed to fix the code which determines line breaks when printing out a MORtran array. Python2 and python3 handle integer division differently. (The former returns an int always, the latter a floating point value). Once fixed, the MORtran generated using python 2.7 and 3.9 is equivalent up to (1) differences in whitespace, (2) different ordering of variable assignments, and (3) different ordering of AgSTAR keyword arguments. These differences have no observable impact on the final geometry. These are all consequences of switching from the iteritems() method to the iter() method for iterating on a dictionary. As Dmitri noted, this will be ready to merge once python 3 is made default. Should discuss at next S&C meeting. |
Integer division in python3 is done using the |
This is a draft PR for compiling AgML using python 3.
There were only a few types of changes needed to get AgML to run under python 3.
a quest for a new editor... as if emacs and vi are not enough.)
5a) Minor issue w/ using "pop" to access dictionary keys resulting from above... get was a perfectly good substitute
The refactoring above may or may not leave the geometry model invariant. It is sufficient to show that the output of the AgML codes is identical, up to whitespace differences and irrelevant re-orderings of declaration statements.
On the c++ side, we are good. The codes produced using python2 is equivalent to the python3 code. Some differences are observed in the order in which (for instance) shape parameters are output. This is a consequence of the change from iteritems() to iter()... and if I took the python2 output from after the refactoring, I would probably not even see this difference.
On the Mortran side, we have additional differences. The rules for breaking lines at column 72 seem to be broken. Will need to solve this problem before converting this from draft.