From 66cbb26ce8bd103ac84713ecd83494c1dcf8d719 Mon Sep 17 00:00:00 2001 From: odashi Date: Tue, 13 Dec 2022 18:38:15 +0000 Subject: [PATCH] remove expression style --- src/latexify/frontend.py | 10 +++++++--- src/latexify/generate_latex.py | 7 +++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/latexify/frontend.py b/src/latexify/frontend.py index 440b8f2..6f38bc7 100644 --- a/src/latexify/frontend.py +++ b/src/latexify/frontend.py @@ -119,7 +119,11 @@ def expression( `use_signature=False`. """ kwargs["use_signature"] = kwargs.get("use_signature", False) + if fn is not None: - return function(fn, **kwargs) - else: - return function(**kwargs) + return ipython_wrappers.LatexifiedFunction(fn, **kwargs) + + def wrapper(f): + return ipython_wrappers.LatexifiedFunction(f, **kwargs) + + return wrapper diff --git a/src/latexify/generate_latex.py b/src/latexify/generate_latex.py index 252bebc..2d8d817 100644 --- a/src/latexify/generate_latex.py +++ b/src/latexify/generate_latex.py @@ -15,7 +15,6 @@ class Style(enum.Enum): """The style of the generated LaTeX.""" ALGORITHMIC = "algorithmic" - EXPRESSION = "expression" FUNCTION = "function" IPYTHON_ALGORITHMIC = "ipython-algorithmic" @@ -67,11 +66,11 @@ def get_latex( elif style == Style.IPYTHON_ALGORITHMIC: # TODO(ZibingZhang): implement algorithmic codegen for ipython raise exceptions.LatexifyNotSupportedError - else: - if style == Style.EXPRESSION: - kwargs["use_signature"] = kwargs.get("use_signature", False) + elif style == Style.FUNCTION: return codegen.FunctionCodegen( use_math_symbols=merged_config.use_math_symbols, use_signature=merged_config.use_signature, use_set_symbols=merged_config.use_set_symbols, ).visit(tree) + + raise ValueError(f"Unrecognized style: {style}")