Skip to content
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

Allow keywords such as latex_name=LaTeX while defining symbolic function #6290

Closed
golam-m-hossain opened this issue Jun 14, 2009 · 12 comments
Closed

Comments

@golam-m-hossain
Copy link

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.

Currently, Sage (4.0.1) raises error if one tries to do so.

Couple of example usage:

(1) Define symbolic function with its latex representaion

riemann(x) = function('riemann', x, latex_name="\\mathcal{R}")
latex( riemann(x) )
\mathcal{R}\left(x\right)

(2) Printing arguments of a symbolic functions as its indices.

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}

Attached patch allows keyword arguments while defining symbolic functions.

CC: @williamstein

Component: symbolics

Keywords: latex_name, symbolic function

Author: Golam Mortuza Hossain

Reviewer: Nick Alexander

Merged: 4.1.alpha0

Issue created by migration from https://trac.sagemath.org/ticket/6290

@golam-m-hossain

This comment has been minimized.

@golam-m-hossain

This comment has been minimized.

@golam-m-hossain golam-m-hossain changed the title Allow latex_name=LaTeX keyword while defining symbolic function Allow keywords such as latex_name=LaTeX while defining symbolic function Jun 15, 2009
@williamstein
Copy link
Contributor

comment:3

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.

@golam-m-hossain
Copy link
Author

@golam-m-hossain
Copy link
Author

comment:4

Replying to @williamstein:

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?

Thanks for your comments! As you suggested, I have updated the patch with expanded docstrings.

@ncalexan
Copy link
Mannequin

ncalexan mannequin commented Jun 15, 2009

comment:5

Looks good to me.

@rlmill
Copy link
Mannequin

rlmill mannequin commented Jun 24, 2009

comment:6

Merged in sage-4.1.alpha0.

@rlmill rlmill mannequin removed the s: positive review label Jun 24, 2009
@rlmill rlmill mannequin closed this as completed Jun 24, 2009
@rlmill rlmill mannequin added this to the sage-4.1 milestone Jun 24, 2009
@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Jun 25, 2009

Author: Golam Mortuza Hossain

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Jun 25, 2009

Reviewer: Nick Alexander

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Jun 25, 2009

Merged: 4.1.alpha0

@sagetrac-schymans
Copy link
Mannequin

sagetrac-schymans mannequin commented Jun 25, 2009

comment:8

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}").

That would make it really flexible.

@golam-m-hossain
Copy link
Author

comment:9

Replying to @sagetrac-schymans:

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}").

Hmmm, thats a great suggestion. Could you please post this to sage-devel?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants