Coder Social home page Coder Social logo

Comments (11)

odashi avatar odashi commented on May 18, 2024 1

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.

ZibingZhang avatar ZibingZhang commented on May 18, 2024

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.

odashi avatar odashi commented on May 18, 2024

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.

def extract_function_name_or_none(node: ast.Call) -> str | None:

from latexify_py.

odashi avatar odashi commented on May 18, 2024

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.

odashi avatar odashi commented on May 18, 2024

Maybe this is a weird behavior though:

無題

from latexify_py.

ZibingZhang avatar ZibingZhang commented on May 18, 2024

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.

odashi avatar odashi commented on May 18, 2024

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.

ZibingZhang avatar ZibingZhang commented on May 18, 2024

I don't think math.pi -> $\mathrm{math}.\pi$ should be correct behavior, i.e. should not require manual user solution. Maybe we have to disallow certain conversions in specific contexts, e.g. in the visit_Attribute context, we can't allow conversions to math symbols.

from latexify_py.

sisykeccco avatar sisykeccco commented on May 18, 2024

也许这是一个奇怪的行为:

无题

from latexify_py.

sisykeccco avatar sisykeccco commented on May 18, 2024

How do I generate this formula output?
image
my IDE is pycharm,Where in the IDE should I run code to output such a formula?

from latexify_py.

odashi avatar odashi commented on May 18, 2024

#88 (comment)

Oh this was an unintended sideeffect introduced in recent changes.
For the quick fix, you can use prefixes option to remove unnecessary math:

prefixes

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.