Comments (11)
This is somewhat weird, but should be fine. The difference between math.pi
and pi
is only the existence of the prefix and it is better to convert their suffixes to the same expression without any other conditioning. We can simply say that use_math_symbols
converts everything in the syntax into math symbols.
from latexify_py.
Once this happens, I think we should get rid of _COMMON_PREFIXES
. The trimming of prefixes should be by default turned off for all imo.
from latexify_py.
Once this happens, I think we should get rid of _COMMON_PREFIXES
Though prefixes trimming is a weird behavior, it couldn't be completely replaced by this feature. We couldn't expect that appropriate libraries are imported when @latexify.function
is applied, because function can be defined with undefined symbols.
Btw, I guessed we already don't need prefix trimming of especially math
, numpy
and np
because we have attribute-agnostic way to extract function names.
latexify_py/src/latexify/ast_utils.py
Line 146 in ddcbed9
from latexify_py.
Tried to remove common prefixes, observed that only this test failed. It is fine to remove this behavior I guess (I will work)
from latexify_py.
Maybe this is a weird behavior though:
from latexify_py.
Though prefixes trimming is a weird behavior, it couldn't be completely replaced by this feature. We couldn't expect that appropriate libraries are imported when
@latexify.function
is applied, because function can be defined with undefined symbols.
Yeah we should definitely keep the prefix trimming feature, just make the user specify which prefixes instead of defaulting to a hardcoded list.
Maybe this is a weird behavior though
That's definitely odd haha. Should maybe only convert in visit_Name
and not visit_Attribute
?
from latexify_py.
Should maybe only convert in visit_Name and not visit_Attribute?
We eventually need both: visit_Name
for pi
(from math import pi
) and visit_Attribute
for math.pi
. But I think this is somewhat too much and may result in unexpected conversion. The same problem may happen in visit_Call
though.
As a workaround, users also can get rid of the math
prefix manually by specifying prefixes={"math"}
, but this is not friendly I guess.
from latexify_py.
I don't think math.pi
-> visit_Attribute
context, we can't allow conversions to math symbols.
from latexify_py.
也许这是一个奇怪的行为:
from latexify_py.
How do I generate this formula output?
my IDE is pycharm,Where in the IDE should I run code to output such a formula?
from latexify_py.
Oh this was an unintended sideeffect introduced in recent changes.
For the quick fix, you can use prefixes
option to remove unnecessary math
:
How do I generate this formula output?
As this library uses IPython's display
functionality, you should use some notebook extensions with LaTeX support (e.g., jupyter) to show appropriate outputs.
from latexify_py.
Related Issues (20)
- Designing "plugin" interface HOT 3
- Use `latex.py` for to standardize codegen HOT 2
- Feedback From a User HOT 14
- Please add support for Python >3.11 HOT 2
- IPython extension to automatically use conversions on displayed objects HOT 1
- Better Identifier For Multi Index and RHS HOT 4
- Can you sub in values for show work? HOT 1
- Сonverting expressions or strings to latex format HOT 5
- Release New Version HOT 6
- Support for sqrt-like nth-roots when rendering x**(1/p)? HOT 2
- Support for log1p and expm1? HOT 4
- `if-elif` statements break if there's no `else` HOT 1
- Typo in \mathopen HOT 3
- Counterintuitive (wrong?) parenthesis when combining exp() and powers HOT 16
- Function docstring and reduce_assignments enabled does not play nice HOT 2
- Include .tex output examples in latexify_py/examples/examples.ipynb HOT 3
- math.pow not working properly on google colab HOT 2
- Non working link on the pypi page of the project HOT 2
- LatexifyNotSupportedError: Unsupported AST: Slice | tensorflow
- update and support 3.12 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from latexify_py.