Sage: Ticket #6290: [with patch, positive review] Allow keywords such as latex_name=LaTeX while defining symbolic function
https://trac.sagemath.org/ticket/6290
<p>
In new symbolics, underlying "sage.symbolic.function.SFunction" class allows one to pass the keywords such as "latex_name=LaTeX". It would be really good if we expose this feature at the user interface level. This will directly allow LaTeX customization by users according to their need.
</p>
<p>
Currently, Sage (4.0.1) raises error if one tries to do so.
</p>
<p>
Couple of example usage:
</p>
<p>
<strong>(1)</strong> Define symbolic function with its latex representaion
</p>
<pre class="wiki">riemann(x) = function('riemann', x, latex_name="\\mathcal{R}")
latex( riemann(x) )
\mathcal{R}\left(x\right)
</pre><p>
<strong>(2)</strong> Printing arguments of a symbolic functions as its indices.
</p>
<pre class="wiki">mu,nu = var('mu,nu')
def my_latex_print(*args):
return "\psi_{%s}"%(', '.join(map(latex, args)))
psi(mu,nu) = function('psi', mu,nu, print_latex_func=my_latex_print)
latex(psi(mu,nu))
\psi_{\mu, \nu}
</pre><p>
Attached patch allows keyword arguments while defining symbolic functions.
</p>
en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/6290
Trac 1.1.6gmhossainSun, 14 Jun 2009 23:35:35 GMTdescription changed
https://trac.sagemath.org/ticket/6290#comment:1
https://trac.sagemath.org/ticket/6290#comment:1
<ul>
<li><strong>description</strong>
modified (<a href="/ticket/6290?action=diff&version=1">diff</a>)
</li>
</ul>
TicketgmhossainMon, 15 Jun 2009 17:09:00 GMTdescription, summary changed
https://trac.sagemath.org/ticket/6290#comment:2
https://trac.sagemath.org/ticket/6290#comment:2
<ul>
<li><strong>description</strong>
modified (<a href="/ticket/6290?action=diff&version=2">diff</a>)
</li>
<li><strong>summary</strong>
changed from <em>Allow latex_name=LaTeX keyword while defining symbolic function</em> to <em>[with patch, needs review] Allow keywords such as latex_name=LaTeX while defining symbolic function</em>
</li>
</ul>
TicketwasMon, 15 Jun 2009 17:44:54 GMTsummary changed
https://trac.sagemath.org/ticket/6290#comment:3
https://trac.sagemath.org/ticket/6290#comment:3
<ul>
<li><strong>summary</strong>
changed from <em>[with patch, needs review] Allow keywords such as latex_name=LaTeX while defining symbolic function</em> to <em>[with patch, needs work] Allow keywords such as latex_name=LaTeX while defining symbolic function</em>
</li>
</ul>
<p>
Nice. Could you add more to the docstring for function (at least the one that I get by default when I do function? from the sage prompt) that explains what happens to all kwds arguments? You do give a nice example (with riemann), but a sentence or two explaining what is going on would be very nice.
</p>
TicketgmhossainMon, 15 Jun 2009 20:07:59 GMTattachment set
https://trac.sagemath.org/ticket/6290
https://trac.sagemath.org/ticket/6290
<ul>
<li><strong>attachment</strong>
set to <em>allow-keyword-arguments-such-as-latex_name-in-symbolic-functions.patch</em>
</li>
</ul>
TicketgmhossainMon, 15 Jun 2009 20:12:19 GMTsummary changed; cc set
https://trac.sagemath.org/ticket/6290#comment:4
https://trac.sagemath.org/ticket/6290#comment:4
<ul>
<li><strong>cc</strong>
<em>was</em> added
</li>
<li><strong>summary</strong>
changed from <em>[with patch, needs work] Allow keywords such as latex_name=LaTeX while defining symbolic function</em> to <em>[with patch, needs review] Allow keywords such as latex_name=LaTeX while defining symbolic function</em>
</li>
</ul>
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/6290#comment:3" title="Comment 3">was</a>:
</p>
<blockquote class="citation">
<p>
Nice. Could you add more to the docstring for function (at least the one that I get by default when I do function? from the sage prompt) that explains what happens to all kwds arguments?
</p>
</blockquote>
<p>
Thanks for your comments! As you suggested, I have updated the patch with expanded docstrings.
</p>
TicketncalexanMon, 15 Jun 2009 20:36:20 GMTsummary changed
https://trac.sagemath.org/ticket/6290#comment:5
https://trac.sagemath.org/ticket/6290#comment:5
<ul>
<li><strong>summary</strong>
changed from <em>[with patch, needs review] Allow keywords such as latex_name=LaTeX while defining symbolic function</em> to <em>[with patch, positive review] Allow keywords such as latex_name=LaTeX while defining symbolic function</em>
</li>
</ul>
<p>
Looks good to me.
</p>
TicketrlmWed, 24 Jun 2009 09:44:35 GMTstatus changed; resolution, milestone set
https://trac.sagemath.org/ticket/6290#comment:6
https://trac.sagemath.org/ticket/6290#comment:6
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
<li><strong>milestone</strong>
set to <em>sage-4.1</em>
</li>
</ul>
<p>
Merged in sage-4.1.alpha0.
</p>
TicketmvnguThu, 25 Jun 2009 00:33:35 GMTreviewer, merged, author set
https://trac.sagemath.org/ticket/6290#comment:7
https://trac.sagemath.org/ticket/6290#comment:7
<ul>
<li><strong>reviewer</strong>
set to <em>Nick Alexander</em>
</li>
<li><strong>merged</strong>
set to <em>4.1.alpha0</em>
</li>
<li><strong>author</strong>
set to <em>Golam Mortuza Hossain</em>
</li>
</ul>
TicketschymansThu, 25 Jun 2009 10:15:37 GMT
https://trac.sagemath.org/ticket/6290#comment:8
https://trac.sagemath.org/ticket/6290#comment:8
<p>
Would something similar be possible whenever a variable is defined?
E.g. if I want to use multiple subscripts, I would like to define
var('A_gs', latex_name="A_{gs}").
</p>
<p>
That would make it really flexible.
</p>
TicketgmhossainThu, 25 Jun 2009 10:44:11 GMT
https://trac.sagemath.org/ticket/6290#comment:9
https://trac.sagemath.org/ticket/6290#comment:9
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/6290#comment:8" title="Comment 8">schymans</a>:
</p>
<blockquote class="citation">
<p>
Would something similar be possible whenever a variable is defined?
E.g. if I want to use multiple subscripts, I would like to define
var('A_gs', latex_name="A_{gs}").
</p>
</blockquote>
<p>
Hmmm, thats a great suggestion. Could you please post this to sage-devel?
</p>
Ticket