math1um / objects-invariants-properties

Objects, Invariants and Properties for Graph Theory (GT) automated conjecturing: in particular with the Sage program CONJECTURING: http://nvcleemp.github.io/conjecturing/
GNU General Public License v3.0
14 stars 6 forks source link

Switch from Sage code to Python code #563

Open nvcleemp opened 6 years ago

nvcleemp commented 6 years ago

Currently our code only works after it is processed by the Sage preparser. This means there are no linters available to do some code checks. Since the chances are only cosmetic, we should try to switch Python code everywhere. E.g., write range(13) instead of [0..12]. This will help for #543.

math1um commented 6 years ago

What else does the Sage preparser do and assume? Doesn't it turn all ints into (Sage) Integers, etc? Is any of this functionality needed?

Also Sage uses "^" for exponentiation. Will changing every occurrence to "**", solve this?

What else?

nvcleemp commented 6 years ago

You can check what the preparser does to some specific code by running the preparse function on a string.

sage: preparse("[0..12]")
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
nvcleemp commented 6 years ago

More information is available here: http://doc.sagemath.org/html/en/reference/repl/sage/repl/preparse.html

nvcleemp commented 6 years ago

My current approach is as follows:

nvcleemp commented 6 years ago

All code has been updated so that gt.sage file now no longer has syntax errors when considered as a Python file. The file is not yet fully switched to Python code. There is a lot of code which still relies on the fact that the file is preparsed by Sage. E.g., 1/3 will give 0 in Python 2.7, but when preparsed by Sage will give the rational number 1/3.