-
Notifications
You must be signed in to change notification settings - Fork 1
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
To sort in an lexicographic order the objects in dict() #78
Comments
rzyu45
added a commit
to rzyu45/Solverz-dev
that referenced
this issue
Jun 1, 2024
Partially resolve smallbunnies#78
rzyu45
changed the title
To sort the symbols in lexicographic order
To sort in an lexicographic order the objects in Jun 12, 2024
dict()
rzyu45
changed the title
To sort in an lexicographic order the objects in
To sort in an lexicographic order the objects in dict()
Jun 12, 2024
dict()
The locations of jac blocks in the Jac.blocks dict() vary in each run. m = Model()
m.x = Var('x', [1, 1])
m.c = Param('c', 2)
m.f1 = Eqn('f1', 1 + exp(m.x[0]) + sin(m.x[1]))
m.f2 = Eqn('f2', m.x[0] + m.c / 2 * m.x[1] ** 2)
F, y0 = m.create_instance()
current_file_path = os.path.abspath(__file__)
current_folder = os.path.dirname(current_file_path)
test_folder_path = current_folder + '\\Solverz_test_ae_module_printer_with_hvp'
sys.path.extend([test_folder_path])
pyprinter = module_printer(F,
y0,
'test_module',
jit=True,
directory=test_folder_path,
make_hvp=True)
pyprinter.render()
from test_module import mdl, y
from test_module.num_func import Hvp_, inner_Hvp, inner_Hvp0, inner_Hvp1, inner_Hvp2
assert inspect.getsource(Hvp_) == expected_Hvp_
assert inspect.getsource(inner_Hvp) == expected_inner_Hvp
assert inspect.getsource(inner_Hvp0.func_code) == expected_inner_Hvp0
assert inspect.getsource(inner_Hvp1.func_code) == expected_inner_Hvp1
assert inspect.getsource(inner_Hvp2.func_code) == expected_inner_Hvp2 In the above example, the |
Partially resolved in 9cf7ccf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For example, I first run
Then I run, in a new python console,
The order of symbols in
Eqn.SYMBOLS
dict is not fixed. It is hard to write tests in such cases. Also, since the printing order of variables in the the generated modules is changing, we cannot reuse the compiled python functions if we reprint these modules.I believe this should be attributed to sympy. To resolve this, we should use the
sort()
function to sort the items inEqn.SYMBOLS
in lexicographic order.The text was updated successfully, but these errors were encountered: