Skip to content

Commit

Permalink
Modify _print_Str and str printing of diffgeom classes
Browse files Browse the repository at this point in the history
  • Loading branch information
JSS95 committed Jul 14, 2020
1 parent 62c2d4b commit f9642ef
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions sympy/printing/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2650,6 +2650,9 @@ def _print_primeomega(self, expr, exp=None):
(self._print(expr.args[0]), exp)
return r'\Omega\left(%s\right)' % self._print(expr.args[0])

def _print_Str(self, s):
return self._print(s.name)

def emptyPrinter(self, expr):
# Checks what type of decimal separator to print.
expr = super().emptyPrinter(expr)
Expand Down
3 changes: 3 additions & 0 deletions sympy/printing/pretty/pretty.py
Original file line number Diff line number Diff line change
Expand Up @@ -2720,6 +2720,9 @@ def _print_AssignmentBase(self, e):
pform = prettyForm(*stringPict.next(l, op, r))
return pform

def _print_Str(self, s):
return self._print(s.name)

def pretty(expr, **settings):
"""Returns a string containing the prettified form of expr.
Expand Down
3 changes: 0 additions & 3 deletions sympy/printing/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,3 @@ def _as_ordered_terms(self, expr, order=None):
return list(expr.args)
else:
return expr.as_ordered_terms(order=order)

def _print_Str(self, s):
return self._print(s.name)
11 changes: 7 additions & 4 deletions sympy/printing/str.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,13 +876,13 @@ def _print_Category(self, category):
return 'Category("%s")' % category.name

def _print_Manifold(self, manifold):
return self._print(manifold.name)
return manifold.name.name

def _print_Patch(self, patch):
return self._print(patch.name)
return patch.name.name

def _print_CoordSystem(self, coords):
return self._print(coords.name)
return coords.name.name

def _print_BaseScalarField(self, field):
return field._coord_sys.symbols[field._index].name
Expand All @@ -901,6 +901,9 @@ def _print_Tr(self, expr):
#TODO : Handle indices
return "%s(%s)" % ("Tr", self._print(expr.args[0]))

def _print_Str(self, s):
return self._print(s.name)

def sstr(expr, **settings):
"""Returns the expression as a string.
Expand Down Expand Up @@ -931,7 +934,7 @@ def _print_str(self, s):

def _print_Str(self, s):
# Str does not to be printed same as str here
return str(s)
return repr(s)


def sstrrepr(expr, **settings):
Expand Down

0 comments on commit f9642ef

Please sign in to comment.