Skip to content

Commit

Permalink
Merge pull request #1440 from scolobb/long-unicode-arrows
Browse files Browse the repository at this point in the history
Fix long arrows in Unicode pretty printing.
  • Loading branch information
ness01 committed Aug 1, 2012
2 parents 02daa7d + 2fe40e8 commit a67d688
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
12 changes: 3 additions & 9 deletions sympy/printing/pretty/pretty.py
Expand Up @@ -1457,9 +1457,7 @@ def _print_Object(self, object):
return self._print(pretty_symbol(object.name))

def _print_Morphism(self, morphism):
arrow = "-->"
if self._use_unicode:
arrow = u"\u27f6 "
arrow = xsym("-->")

domain = self._print(morphism.domain)
codomain = self._print(morphism.codomain)
Expand All @@ -1480,9 +1478,7 @@ def _print_IdentityMorphism(self, morphism):
def _print_CompositeMorphism(self, morphism):
from sympy.categories import NamedMorphism

circle = "*"
if self._use_unicode:
circle = u"\u2218"
circle = xsym(".")

# All components of the morphism have names and it is thus
# possible to build the name of the composite.
Expand All @@ -1505,9 +1501,7 @@ def _print_Diagram(self, diagram):

pretty_result = self._print(diagram.premises)
if diagram.conclusions:
results_arrow = " ==> "
if self._use_unicode:
results_arrow = u" \u27f9 "
results_arrow = " %s " % xsym("==>")

pretty_conclusions = self._print(diagram.conclusions)[0]
pretty_result = pretty_result.right(results_arrow, pretty_conclusions)
Expand Down
6 changes: 6 additions & 0 deletions sympy/printing/pretty/pretty_symbology.py
Expand Up @@ -378,6 +378,12 @@ def hobj(symb, width):
'>=' : ('>=', U('GREATER-THAN OR EQUAL TO')),
'!=' : ('!=', U('NOT EQUAL TO')),
'*' : ('*', U('DOT OPERATOR')),
'-->' : ('-->', U('EM DASH') + U('EM DASH') +
U('BLACK RIGHT-POINTING TRIANGLE')),
'==>' : ('==>', U('BOX DRAWINGS DOUBLE HORIZONTAL') +
U('BOX DRAWINGS DOUBLE HORIZONTAL') +
U('BLACK RIGHT-POINTING TRIANGLE')),
'.' : ('*', U('RING OPERATOR')),
}


Expand Down
16 changes: 8 additions & 8 deletions sympy/printing/pretty/tests/test_pretty.py
Expand Up @@ -3716,12 +3716,12 @@ def test_categories():
assert upretty(A1) == u"A₁"

assert pretty(f1) == "f1:A1-->A2"
assert upretty(f1) == u"f₁:A₁A₂"
assert upretty(f1) == u"f₁:A₁——▶A₂"
assert pretty(id_A1) == "id:A1-->A1"
assert upretty(id_A1) == u"id:A₁A₁"
assert upretty(id_A1) == u"id:A₁——▶A₁"

assert pretty(f2*f1) == "f2*f1:A1-->A3"
assert upretty(f2*f1) == u"f₂∘f₁:A₁A₃"
assert upretty(f2*f1) == u"f₂∘f₁:A₁——▶A₃"

assert pretty(K1) == "K1"
assert upretty(K1) == u"K₁"
Expand All @@ -3736,17 +3736,17 @@ def test_categories():
"EmptySet(), id:A2-->A2: EmptySet(), id:A3-->A3: " \
"EmptySet(), f1:A1-->A2: {unique}, f2:A2-->A3: EmptySet()}"

assert upretty(d) == u"{f₂∘f₁:A₁A₃: ∅, id:A₁A₁: ∅, " \
u"id:A₂A₂: ∅, id:A₃A₃: ∅, f₁:A₁A₂: {unique}, f₂:A₂A₃: ∅}"
assert upretty(d) == u"{f₂∘f₁:A₁——▶A₃: ∅, id:A₁——▶A₁: ∅, " \
u"id:A₂——▶A₂: ∅, id:A₃——▶A₃: ∅, f₁:A₁——▶A₂: {unique}, f₂:A₂——▶A₃: ∅}"

d = Diagram({f1:"unique", f2:S.EmptySet}, {f2 * f1: "unique"})
assert pretty(d) == "{f2*f1:A1-->A3: EmptySet(), id:A1-->A1: " \
"EmptySet(), id:A2-->A2: EmptySet(), id:A3-->A3: " \
"EmptySet(), f1:A1-->A2: {unique}, f2:A2-->A3: EmptySet()}" \
" ==> {f2*f1:A1-->A3: {unique}}"
assert upretty(d) == u"{f₂∘f₁:A₁A₃: ∅, id:A₁A₁: ∅, id:A₂A₂: " \
u"∅, id:A₃A₃: ∅, f₁:A₁A₂: {unique}, f₂:A₂A₃: ∅}" \
u" {f₂∘f₁:A₁A₃: {unique}}"
assert upretty(d) == u"{f₂∘f₁:A₁——▶A₃: ∅, id:A₁——▶A₁: ∅, id:A₂——▶A₂: " \
u"∅, id:A₃——▶A₃: ∅, f₁:A₁——▶A₂: {unique}, f₂:A₂——▶A₃: ∅}" \
u" ══▶ {f₂∘f₁:A₁——▶A₃: {unique}}"

def test_PrettyModules():
R = QQ[x, y]
Expand Down

0 comments on commit a67d688

Please sign in to comment.