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

Cannot pretty print a function named gamma #13556

Closed
moble opened this issue Nov 1, 2017 · 6 comments
Closed

Cannot pretty print a function named gamma #13556

moble opened this issue Nov 1, 2017 · 6 comments

Comments

@moble
Copy link
Contributor

moble commented Nov 1, 2017

When I define a function named 'gamma', pretty printing interprets that object as the Gamma function and drops any but the first argument. This happens in both the notebook and the terminal, though interestingly the notebook capitalizes gamma, whereas the terminal keeps it lowercase. I can get around this by naming my function r'\gamma', but that prevents pickling the object. Here's the MWE:

import sympy
gamma = sympy.Function('gamma')
x, y = sympy.symbols('x, y')
sympy.init_printing()
gamma(x, y)

And the results:

badprinting

badterminal

This is related to #9253, but I agree that name collisions are inevitable — we just need to be able to overcome them. And I suppose this may be related to #9064. However, I don't find similar behavior with beta or phi.

@asmeurer
Copy link
Member

asmeurer commented Nov 1, 2017

This is #2832. I think gamma is unlike beta or phi because it the SymPy function name is spelled lowercase but it pretty prints as an uppercase letter.

Duplicate of #2832

@asmeurer
Copy link
Member

asmeurer commented Nov 1, 2017

Duplicate of #2832

@asmeurer asmeurer marked this as a duplicate of #2832 Nov 1, 2017
@asmeurer
Copy link
Member

asmeurer commented Nov 1, 2017

Regarding the behavior you see, it looks like it was fixed in the pretty printer but not the LaTeX printer.

@asmeurer asmeurer closed this as completed Nov 1, 2017
@moble
Copy link
Contributor Author

moble commented Nov 1, 2017

Maybe I'm just confused about what's doing what, but something also appears to be wrong with the pretty printer and gamma:

prettyprinting

Notice that gamma drops the second argument, but delta does not.

Also, sorry about missing the old issue.

@jksuom
Copy link
Member

jksuom commented Nov 1, 2017

Fixed in pretty printer: #11919

@asmeurer
Copy link
Member

asmeurer commented Nov 1, 2017

@moble good catch. That's another reason why we should print undefined functions completely separately from the function printers.

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

No branches or pull requests

3 participants