-
Notifications
You must be signed in to change notification settings - Fork 379
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
Automatically detecting imported libraries #88
Comments
Once this happens, I think we should get rid of |
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 Btw, I guessed we already don't need prefix trimming of especially latexify_py/src/latexify/ast_utils.py Line 146 in ddcbed9
|
Yeah we should definitely keep the prefix trimming feature, just make the user specify which prefixes instead of defaulting to a hardcoded list.
That's definitely odd haha. Should maybe only convert in |
We eventually need both: As a workaround, users also can get rid of the |
I don't think |
This is somewhat weird, but should be fine. The difference between |
Ref: #86
Sometimes users import libraries with custom names, and the current implementation of latexify does not recognize it without passing the custom config (this is not the current feature: tracked by #87)
We can anyway list up the all imported modules through
globals()
, and check if they contains some well known libraries. For example, if the user invokedimport numpy as np
,globals()["np"]
should point to a module with__name__ == "numpy"
.This is clever enough I think, but applying this involves environment-dependent behavior. I think this can be implemented as an additional NodeTransformer with a boolean switch which is turned off by default.
The text was updated successfully, but these errors were encountered: