Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use a longer arrows in pretty representation of morphisms.

Shorter arrows look somewhat too crowded.
  • Loading branch information...
commit 25f746ace8e2bb816624b294b0d6451d26483025 1 parent d03d55c
Sergiu Ivanov authored June 15, 2012
12  sympy/categories/baseclasses.py
@@ -558,13 +558,13 @@ class Diagram(Basic):
558 558
     >>> g = NamedMorphism(B, C, "g")
559 559
     >>> d = Diagram([f, g])
560 560
     >>> print pretty(d.premises.keys(), use_unicode=False)
561  
-    [f:A->B, id:B->B, g*f:A->C, g:B->C, id:C->C, id:A->A]
  561
+    [f:A-->B, id:B-->B, g*f:A-->C, g:B-->C, id:C-->C, id:A-->A]
562 562
     >>> print pretty(d.premises, use_unicode=False)
563  
-    {g*f:A->C: EmptySet(), id:A->A: EmptySet(), id:B->B: EmptySet(), id:C->C: Empt
564  
-    ySet(), f:A->B: EmptySet(), g:B->C: EmptySet()}
  563
+    {g*f:A-->C: EmptySet(), id:A-->A: EmptySet(), id:B-->B: EmptySet(), id:C-->C:
  564
+    EmptySet(), f:A-->B: EmptySet(), g:B-->C: EmptySet()}
565 565
     >>> d = Diagram([f, g], {g * f:"unique"})
566 566
     >>> print pretty(d.conclusions)
567  
-    {g*f:A->C: {unique}}
  567
+    {g*f:A-->C: {unique}}
568 568
 
569 569
     References
570 570
     ==========
@@ -733,7 +733,7 @@ def premises(self):
733 733
         >>> id_B = IdentityMorphism(B)
734 734
         >>> d = Diagram([f])
735 735
         >>> print pretty(d.premises, use_unicode=False)
736  
-        {id:A->A: EmptySet(), id:B->B: EmptySet(), f:A->B: EmptySet()}
  736
+        {id:A-->A: EmptySet(), id:B-->B: EmptySet(), f:A-->B: EmptySet()}
737 737
 
738 738
         """
739 739
         return self.args[0]
@@ -805,7 +805,7 @@ def hom(self, A, B):
805 805
         >>> g = NamedMorphism(B, C, "g")
806 806
         >>> d = Diagram([f, g], {g * f: "unique"})
807 807
         >>> print pretty(d.hom(A, C), use_unicode=False)
808  
-        ({g*f:A->C}, {g*f:A->C})
  808
+        ({g*f:A-->C}, {g*f:A-->C})
809 809
 
810 810
         See Also
811 811
         ========
4  sympy/printing/pretty/pretty.py
@@ -1450,9 +1450,9 @@ def _print_Object(self, object):
1450 1450
         return self._print(pretty_symbol(object.name))
1451 1451
 
1452 1452
     def _print_Morphism(self, morphism):
1453  
-        arrow = "->"
  1453
+        arrow = "-->"
1454 1454
         if self._use_unicode:
1455  
-            arrow = u"\u2192"
  1455
+            arrow = u"\u27f6  "
1456 1456
             circle = u"\u2218"
1457 1457
 
1458 1458
         domain = self._print(morphism.domain)
48  sympy/printing/pretty/tests/test_pretty.py
@@ -3711,27 +3711,27 @@ def test_categories():
3711 3711
     assert pretty(A1) == "A1"
3712 3712
     assert upretty(A1) == u"A₁"
3713 3713
 
3714  
-    assert pretty(f1) == "f1:A1->A2"
3715  
-    assert upretty(f1) == u"f₁:A₁→A₂"
3716  
-    assert pretty(anonymous) == "A1->A3"
3717  
-    assert upretty(anonymous) == u"A₁→A₃"
3718  
-    assert pretty(id_A1) == "id:A1->A1"
3719  
-    assert upretty(id_A1) == u"id:A₁→A₁"
  3714
+    assert pretty(f1) == "f1:A1-->A2"
  3715
+    assert upretty(f1) == u"f₁:A₁⟶  A₂"
  3716
+    assert pretty(anonymous) == "A1-->A3"
  3717
+    assert upretty(anonymous) == u"A₁⟶  A₃"
  3718
+    assert pretty(id_A1) == "id:A1-->A1"
  3719
+    assert upretty(id_A1) == u"id:A₁⟶  A₁"
3720 3720
 
3721  
-    assert pretty(f2*f1) == "f2*f1:A1->A3"
3722  
-    assert upretty(f2*f1) == u"f₂∘f₁:A₁→A₃"
  3721
+    assert pretty(f2*f1) == "f2*f1:A1-->A3"
  3722
+    assert upretty(f2*f1) == u"f₂∘f₁:A₁⟶  A₃"
3723 3723
 
3724 3724
     assert pretty(K1) == "K1"
3725 3725
     assert upretty(K1) == u"K₁"
3726 3726
 
3727 3727
     # Some further tests for anonymous morphisms.
3728 3728
     h = Morphism(A2, A3) * Morphism(A1, A2)
3729  
-    assert pretty(h) == "A1->A3"
3730  
-    assert upretty(h) == u"A₁→A₃"
  3729
+    assert pretty(h) == "A1-->A3"
  3730
+    assert upretty(h) == u"A₁⟶  A₃"
3731 3731
 
3732 3732
     h = NamedMorphism(A2, A3, "f") * Morphism(A1, A2)
3733  
-    assert pretty(h) == "A1->A3"
3734  
-    assert upretty(h) == u"A₁→A₃"
  3733
+    assert pretty(h) == "A1-->A3"
  3734
+    assert upretty(h) == u"A₁⟶  A₃"
3735 3735
 
3736 3736
     # Test how diagrams are printed.
3737 3737
     d = Diagram()
@@ -3739,18 +3739,18 @@ def test_categories():
3739 3739
     assert upretty(d) == u"∅"
3740 3740
 
3741 3741
     d = Diagram({f1:"unique", f2:S.EmptySet})
3742  
-    assert pretty(d) == "{f2*f1:A1->A3: EmptySet(), id:A1->A1: " \
3743  
-           "EmptySet(), id:A2->A2: EmptySet(), id:A3->A3: " \
3744  
-           "EmptySet(), f1:A1->A2: {unique}, f2:A2->A3: EmptySet()}"
  3742
+    assert pretty(d) == "{f2*f1:A1-->A3: EmptySet(), id:A1-->A1: " \
  3743
+           "EmptySet(), id:A2-->A2: EmptySet(), id:A3-->A3: " \
  3744
+           "EmptySet(), f1:A1-->A2: {unique}, f2:A2-->A3: EmptySet()}"
3745 3745
 
3746  
-    assert upretty(d) == u"{f₂∘f₁:A₁→A₃: ∅, id:A₁→A₁: ∅, " \
3747  
-           u"id:A₂→A₂: ∅, id:A₃→A₃: ∅, f₁:A₁→A₂: {unique}, f₂:A₂→A₃: ∅}"
  3746
+    assert upretty(d) == u"{f₂∘f₁:A₁⟶  A₃: ∅, id:A₁⟶  A₁: ∅, " \
  3747
+           u"id:A₂⟶  A₂: ∅, id:A₃⟶  A₃: ∅, f₁:A₁⟶  A₂: {unique}, f₂:A₂⟶  A₃: ∅}"
3748 3748
 
3749 3749
     d = Diagram({f1:"unique", f2:S.EmptySet}, {f2 * f1: "unique"})
3750  
-    assert pretty(d) == "{f2*f1:A1->A3: EmptySet(), id:A1->A1: " \
3751  
-           "EmptySet(), id:A2->A2: EmptySet(), id:A3->A3: " \
3752  
-           "EmptySet(), f1:A1->A2: {unique}, f2:A2->A3: EmptySet()}" \
3753  
-           " ==> {f2*f1:A1->A3: {unique}}"
3754  
-    assert upretty(d) == u"{f₂∘f₁:A₁→A₃: ∅, id:A₁→A₁: ∅, id:A₂→A₂: " \
3755  
-           u"∅, id:A₃→A₃: ∅, f₁:A₁→A₂: {unique}, f₂:A₂→A₃: ∅}" \
3756  
-           u" ⟹  {f₂∘f₁:A₁→A₃: {unique}}"
  3750
+    assert pretty(d) == "{f2*f1:A1-->A3: EmptySet(), id:A1-->A1: " \
  3751
+           "EmptySet(), id:A2-->A2: EmptySet(), id:A3-->A3: " \
  3752
+           "EmptySet(), f1:A1-->A2: {unique}, f2:A2-->A3: EmptySet()}" \
  3753
+           " ==> {f2*f1:A1-->A3: {unique}}"
  3754
+    assert upretty(d) == u"{f₂∘f₁:A₁⟶  A₃: ∅, id:A₁⟶  A₁: ∅, id:A₂⟶  A₂: " \
  3755
+           u"∅, id:A₃⟶  A₃: ∅, f₁:A₁⟶  A₂: {unique}, f₂:A₂⟶  A₃: ∅}" \
  3756
+           u" ⟹  {f₂∘f₁:A₁⟶  A₃: {unique}}"

0 notes on commit 25f746a

Please sign in to comment.
Something went wrong with that request. Please try again.