#13632 closed defect (fixed)
Fix latex display of arguments of symbolic functions
Reported by: | gouezel | Owned by: | burcin |
---|---|---|---|
Priority: | minor | Milestone: | sage-5.4.1 |
Component: | symbolics | Keywords: | |
Cc: | Merged in: | sage-5.4.1.rc0 | |
Authors: | Sebastien Gouezel | Reviewers: | Burcin Erocal |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
In sage 5.3, if the arguments of a symbolic function have no _latex_ attribute, an exception is raised if one tries to latex it:
sage: P=function('P',x) sage: latex(P(x=int(0))) Traceback (click to the left of this block for traceback) ... AttributeError: 'int' object has no attribute '_latex_'
This is fixed in the attached patch.
Attachments (1)
Change History (8)
Changed 10 years ago by
comment:1 Changed 10 years ago by
- Status changed from new to needs_review
comment:2 Changed 10 years ago by
comment:3 Changed 10 years ago by
It is certainly possible to avoid the conversion from string to LatexExpr? and then back to string. However, simply trying x._latex_() and catching an exception will not suffice, since _latex_() is broken in some cases where it exists (see has_latex_attr in latex.py). So, one would need to duplicate part of the code of latex() (more precisely, the first few lines of Latex.call).
Since latex output should never be speed-critical (it is supposed to be read by humans, right?), I would rather stay with the current version of the patch to avoid code duplication and keep it as simple as possible.
comment:4 Changed 10 years ago by
- Status changed from needs_review to positive_review
I agree that the overhead of typesetting an equation is not really important for the usual user. If you're doing this a lot when typesetting a book it might be an issue, but I'm willing to risk it. I'm switching to positive review.
Thanks a lot for the quick patch!
comment:5 Changed 10 years ago by
- Reviewers set to Burcin Erocal
comment:6 Changed 10 years ago by
- Merged in set to sage-5.5.beta0
- Resolution set to fixed
- Status changed from positive_review to closed
comment:7 Changed 10 years ago by
- Merged in changed from sage-5.5.beta0 to sage-5.4.1.rc0
- Milestone changed from sage-5.5 to sage-5.4.1
Wow, that's a pretty simple fix, but it looks right. I am a little concerned about the following:
Will that cause any problem/slow things down, or is this actually an improvement?
Naturally fixing the bug is good, just wondering if there is any slick way to avoid turning things into LatexExpr and back to strings - or maybe a try/except thing catching the attribute error?
Otherwise this looks like a good idea and nice fix.