Skip to content

Commit

Permalink
Fix code printer import
Browse files Browse the repository at this point in the history
  • Loading branch information
hayk-skydio committed Jun 11, 2022
1 parent d516105 commit 07ffa56
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
4 changes: 1 addition & 3 deletions symforce/codegen/backends/cpp/cpp_code_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
# This source code is under the Apache 2.0 license found in the LICENSE file.
# ----------------------------------------------------------------------------

import sympy
from sympy.printing.c import get_math_macros
from sympy.printing.cxx import CXX11CodePrinter

from symforce import typing as T

# Everything in this file is SymPy, not SymEngine (even when SymForce is on the SymEngine backend)
import sympy


class CppCodePrinter(CXX11CodePrinter):
"""
Expand Down
4 changes: 2 additions & 2 deletions symforce/codegen/backends/cpp/cpp_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# SymForce - Copyright 2022, Skydio, Inc.
# This source code is under the Apache 2.0 license found in the LICENSE file.
# ----------------------------------------------------------------------------
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
from sympy.printing.codeprinter import CodePrinter

from symforce import typing as T
from symforce.codegen.codegen_config import CodegenConfig
Expand Down Expand Up @@ -60,7 +60,7 @@ def templates_to_render(self, generated_file_name: str) -> T.List[T.Tuple[str, s

return templates

def printer(self) -> "sympy.CodePrinter":
def printer(self) -> CodePrinter:
# NOTE(hayk): Is there any benefit to this being lazy?
from symforce.codegen.backends.cpp import cpp_code_printer

Expand Down
4 changes: 1 addition & 3 deletions symforce/codegen/backends/python/python_code_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
# This source code is under the Apache 2.0 license found in the LICENSE file.
# ----------------------------------------------------------------------------

from sympy.printing.pycode import PythonCodePrinter as _PythonCodePrinter

# Everything in this file is SymPy, not SymEngine (even when SymForce is on the SymEngine backend)
import sympy
from sympy.printing.pycode import PythonCodePrinter as _PythonCodePrinter


class PythonCodePrinter(_PythonCodePrinter):
Expand Down
4 changes: 2 additions & 2 deletions symforce/codegen/backends/python/python_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# SymForce - Copyright 2022, Skydio, Inc.
# This source code is under the Apache 2.0 license found in the LICENSE file.
# ----------------------------------------------------------------------------
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
from sympy.printing.codeprinter import CodePrinter

from symforce import typing as T
from symforce.codegen.codegen_config import CodegenConfig
Expand Down Expand Up @@ -52,7 +52,7 @@ def templates_to_render(self, generated_file_name: str) -> T.List[T.Tuple[str, s
("function/__init__.py.jinja", "__init__.py"),
]

def printer(self) -> "sympy.CodePrinter":
def printer(self) -> CodePrinter:
from symforce.codegen.backends.python import python_code_printer

return python_code_printer.PythonCodePrinter()
4 changes: 2 additions & 2 deletions symforce/codegen/codegen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# SymForce - Copyright 2022, Skydio, Inc.
# This source code is under the Apache 2.0 license found in the LICENSE file.
# ----------------------------------------------------------------------------
from __future__ import annotations
from abc import abstractmethod
from dataclasses import dataclass
from pathlib import Path
from sympy.printing.codeprinter import CodePrinter

from symforce import typing as T

Expand Down Expand Up @@ -63,7 +63,7 @@ def templates_to_render(self, generated_file_name: str) -> T.List[T.Tuple[str, s
pass

@abstractmethod
def printer(self) -> "sympy.CodePrinter":
def printer(self) -> CodePrinter:
"""
Return an instance of the code printer to use for this language.
"""
Expand Down

0 comments on commit 07ffa56

Please sign in to comment.