google/latexify_py

Function docstring and reduce_assignments enabled does not play nice

ckming102 opened this issue · 2 comments

Environment

  • OS: Windows10
  • Python: 3.10.8
  • Latexify version: 0.4.1

Description

Enabling assignment reductions with a function docstring gives LatexifyNotSupportedError.

Reproduction

Running

@latexify.function(
    reduce_assignments=True,
)
def f(x):
    """doc string"""
    y = x + 1
    return 2 * y

f

gives LatexifyNotSupportedError: AssignmentReducer supports only Assign nodes, but got: Expr

Expected behavior

$$ f(x) = 2 \mathopen{}\left( x + 1 \mathclose{}\right) $$

odashi commented

Thanks! It looks we need a specific conditioning to ignore docstrings from this processing.

sugoi !!!