-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
easier access to operands of a symbolic expression #9989
Comments
comment:1
Attachment: trac_9989-operands.patch.gz |
comment:2
This looks like a good addition, after many sage-support queries - great! I hope to be able to review this eventually, though it will take some time because I am not a Cython expert and would want to be very careful. What is the Does this depend at all on any of the Pynac 0.2.1 tickets' patches? |
comment:3
Replying to @kcrisman:
I also found out about it while looking through the Sage library code for a way to make http://docs.cython.org/src/userguide/extension_types.html#properties The function defined by
No, it should be independent. Though I admit that there are a bunch of symbolics patches before this on my queue. |
comment:5
The error "TypeError: cannot index numeric, constant or symbol" is rather obscure, better to make it something like "... has no operands." Any reason why expr.op isn't just a plain list? |
This comment has been minimized.
This comment has been minimized.
Reviewer: Robert Bradshaw |
comment:6
Replying to @robertwb:
Done. The new message is: "expressions containing only a numeric coefficient, constant or symbol have no operands"
I wanted to avoid traversing the vector storing the operands and creating a python object for each. A list wouldn't allow nested indexing either:
This syntax was proposed in a discussion at Sage days 24 last summer. Apply trac_9989-operands.take2.patch |
comment:7
Replying to @burcin:
I think that the part in expression.pyx still has this syntax, and I agree that it is confusing. Putting 'needs info' just in case that is intentional. |
Attachment: trac_9989-operands.take2.patch.gz |
comment:8
Replying to @kcrisman:
Good catch! I forgot to change that message. Updated patch attached, with same name. |
comment:9
Is the Slowly working my way through it... Cython not being my forte... but looks good so far. |
Changed reviewer from Robert Bradshaw to Robert Bradshaw, Karl-DIeter Crisman |
comment:10
There is no doctest for
And you might as well just use |
comment:11
So far looks good - thanks to a little help and the Ginac refs. Questions, though.
Is this really the error message we want? Here it's the 'exclusive' between, but that could be confusing. Maybe it should say between -3 and 2 (length ops -1)?
since matrices can do this
The current code ends everything if it's a slice; you just get the operands at that level. But it would be interesting to get the 2nd element of each operand, though perhaps not very useful since you might not know what it is ahead of time. But perhaps for very regular expressions (Christoffel symbol-type surfeit of indices?) it could be useful. We might also want something like
But maybe going back and forth between Ginac and Sage in the way you'd have to for that is tricky.
We should have at least one doctest somewhere that tests this. But overall the code is correct for the promised functionality and passes its tests, documented pretty well if you know enough about !GEx etc. So I would say good work, needs work for the last item above and probably the first, and needs info for the second item (matrix-style slices). |
Changed reviewer from Robert Bradshaw, Karl-DIeter Crisman to Robert Bradshaw, Karl-Dieter Crisman |
comment:12
Thank you for the thorough reviews. I appreciate the feedback and it's certainly good for someone to look over my changes, since there are often rough edges I fail to see after staring at the code for a while. Replying to @kcrisman:
Fixed.
The output is a list if the index is a slice. We could pass further indices to the list's
I added a test in the docstring for For patchbot: Apply trac_9989-operands.take3.patch |
comment:13
Attachment: trac_9989-operands.take3.patch.gz
I certainly don't have time to reread this whole patch again, so assuming that the only changes are the ones mentioned, then tests pass, changes are good, explanation of second point is sufficient, good to go. |
This comment has been minimized.
This comment has been minimized.
comment:15
cringe I am ready to write some documentation if that gets people to use SAGE_LOCAL and SAGE_INC and all the other variables defined in module_list.py
rather than
and other combinations of SAGE_ROOT + "/local..." |
comment:16
Good catch. Thanks, Francois. I uploaded a new patch that just changes Francois, why don't you open a ticket to rename |
This comment has been minimized.
This comment has been minimized.
comment:17
Actually you could have used the ginac_depends variable. But your suggestion is good I can make it a part of #11377. I think I may try to write a little bit about these variables in the manual. |
comment:18
Attachment: trac_9989-operands.take4.patch.gz Apply trac_9989-operands.take4.patch |
Changed reviewer from Robert Bradshaw, Karl-Dieter Crisman to Robert Bradshaw, Karl-Dieter Crisman, Volker Braun |
Changed keywords from none to sd31 |
comment:19
By private communication, I asked Burcin to change the |
comment:21
Somebody should review the new patch... (I am not sure whether Volker's comment "I think its looks great now." means a formal positive_review) |
comment:22
Yes, positive review! |
Merged: sage-4.7.1.alpha4 |
Attached patch adds an
op
attribute to symbolic expressions which gives easy access to its operands. We now have:Using
__getitem__()
directly was not an option since it breaks conversion to numpy.Apply attachment: trac_9989-operands.take4.patch
CC: @jpflori
Component: symbolics
Keywords: sd31
Author: Burcin Erocal
Reviewer: Robert Bradshaw, Karl-Dieter Crisman, Volker Braun
Merged: sage-4.7.1.alpha4
Issue created by migration from https://trac.sagemath.org/ticket/9989
The text was updated successfully, but these errors were encountered: