-
Notifications
You must be signed in to change notification settings - Fork 387
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
Algorithmic decorator (implement output for _repr_latex_) #163
Conversation
A point of interest is that the result of |
General comments before providing detailed review:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dummy, please re-request review after all changes in frontend were split into other PR.
I'm not ready for this PR to be reviewed, but #164 is ready for review. |
…fy_py into algorithmic-decorator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Use
\textsc
for small capital letters. - Wrap all statements by
\begin{array}{l}
and\end{array}
. newlines are unexpected in the bare math mode and it brings unexpected consequence (e.g.,$a\\b$
and$$a\\b$$
may generate different results in terms of the number of lines)
Okay, so I guess |
No, we don't have any necessity to use typewriter font. |
Sounds good, I can remove that. Only had it because |
@@ -26,20 +26,60 @@ def check_function( | |||
if not kwargs: | |||
latexified = frontend.function(fn) | |||
assert str(latexified) == latex | |||
assert latexified._repr_latex_() == rf"$$ \displaystyle {latex} $$" | |||
assert latexified._repr_latex_() == r"$$ \displaystyle " + latex + " $$" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore the original expression, and don't use "+" concatenation as well as possible. f-strings or join()
are basically the most fastest option to concatenate strings and "+" is the worst choice.
Ditto for all other places.
def f():
for i in range(1_000_000):
x = f"The answer is {i}."
return x
def g():
for i in range(1_000_000):
x = "The answer is " + str(i) + "."
return x
%time f()
%time g()
CPU times: user 191 ms, sys: 0 ns, total: 191 ms
Wall time: 192 ms
CPU times: user 327 ms, sys: 0 ns, total: 327 ms
Wall time: 327 ms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know, I think I've converted it all back. When codegen though lots of places can't use f
strings because of \
not allowed :(
Overview
Adds a$\LaTeX$ for IPython.
IPythonAlgorithmicCodegen
class which converts algorithms intoReferences
continues work on #57
Blocked by
None