If there is a consensus on this I will be happy to change it.

Otherwise is the patch ok? If it is to whom should I send it?
Here is the second part that adds _distance_string_label to the bras

On 1 April 2011 18:29, Brian Granger <elliso...@gmail.com> wrote:

> On Fri, Apr 1, 2011 at 9:27 AM, Julien Rioux <julien.ri...@gmail.com>
> wrote:
> > On Apr 1, 12:21 pm, "krastanov.ste...@gmail.com"
> > <krastanov.ste...@gmail.com> wrote:
> >> The problem is that innerproduct uses print_label and not print_content
> for
> >> the bra which is the way it should be, at least for TimeDepKet.
> >>
> >
> > I see. Well I don't agree that ⟨ψ❘ψ;t⟩ is how it should be. I think it
> > should be ⟨ψ;t❘ψ;t⟩.
>
> +1
>
> > --
> > You received this message because you are subscribed to the Google Groups
> "sympy" group.
> > To post to this group, send email to sympy@googlegroups.com.
> > To unsubscribe from this group, send email to
> sympy+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
> >
> >
>
>
>
> --
> Brian E. Granger
> Cal Poly State University, San Luis Obispo
> bgran...@calpoly.edu and elliso...@gmail.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to sympy@googlegroups.com.
> To unsubscribe from this group, send email to
> sympy+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

From 08e877d664a150daa45b1becd801eea3d2c51c25 Mon Sep 17 00:00:00 2001
From: Stefan Krastanov <krastanov.ste...@gmail.com>
Date: Fri, 1 Apr 2011 16:14:25 +0200
Subject: [PATCH 1/2] Changing the printing methods of quantum.Spin

The JzKet(a,b), JxKet(a,b) and JyKet(a,b) are all
printed with the same string.
To fix the ambiguity I have added a string prefix
to the output of _print_contents*.
---
 sympy/physics/quantum/spin.py |   49 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/sympy/physics/quantum/spin.py b/sympy/physics/quantum/spin.py
index 770e21f..007efe7 100644
--- a/sympy/physics/quantum/spin.py
+++ b/sympy/physics/quantum/spin.py
@@ -424,10 +424,55 @@ def m(self):
     def _eval_hilbert_space(cls, label):
         return ComplexSpace(2*label[0]+1)
 
+    #-------------------------------------------------------------------------
+    # Printing
+    #-------------------------------------------------------------------------
+
+    _direction_string_label = None
+
+    def _print_direction(self, printer, *args):
+        return printer._print(self._direction_string_label, *args)
+
+    _print_direction_repr = _print_direction
+    _print_direction_latex = _print_direction
+
+    def _print_direction_pretty(self, printer, *args):
+        pform = printer._print(self._direction_string_label, *args)
+        return pform
+
+    def _print_contents(self, printer, *args):
+        label = self._print_label(printer, *args)
+        direction = self._print_direction(printer, *args)
+        return '%s%s:%s%s' % (self.lbracket, direction, label, self.rbracket)
+
+    def _print_contents_repr(self, printer, *args):
+        label = self._print_label_repr(printer, *args)
+        direction = self._print_direction_repr(printer, *args)
+        return '%s,%s' % (direction, label)
+
+    def _print_contents_pretty(self, printer, *args):
+        pform = self._print_direction_pretty(printer, *args)
+        pform = prettyForm(*pform.left((self.lbracket_pretty)))
+        pform = prettyForm(*pform.right((':')))
+        nextpform = self._print_label_pretty(printer, *args)
+        pform = prettyForm(*pform.right((nextpform)))
+        pform = prettyForm(*pform.right((self.rbracket_pretty)))
+        return pform
+
+    def _print_contents_latex(self, printer, *args):
+        label = self._print_label_latex(printer, *args)
+        direction = self._print_direction_latex(printer, *args)
+        # The extra {} brackets are needed to get matplotlib's latex
+        # rendered to render this properly.
+        return '{%s%s:%s%s}' %\
+            (self.lbracket_latex, direction, label, self.rbracket_latex)
+
 
 class JzKet(SpinState, Ket):
     """Eigenket of Jz."""
 
+    _direction_string_label="z"
+
     def _eval_innerproduct_JzBra(self, bra, **hints):
         d1 = KroneckerDelta(self.j, bra.j)
         d2 = KroneckerDelta(self.m, bra.m)
@@ -459,6 +504,8 @@ def dual_class(self):
 class JxKet(SpinState, Ket):
     """Eigenket of Jx."""
 
+    _direction_string_label="x"
+
     @property
     def dual_class(self):
         return JxBra
@@ -490,6 +537,8 @@ def dual_class(self):
 class JyKet(SpinState, Ket):
     """Eigenket of Jy."""
 
+    _direction_string_label="y"
+
     @property
     def dual_class(self):
         return JyBra
-- 
1.7.1

From 687c2f7d2d17692097988fade0898bde29b9552c Mon Sep 17 00:00:00 2001
From: Stefan Krastanov <krastanov.ste...@gmail.com>
Date: Fri, 1 Apr 2011 18:27:24 +0200
Subject: [PATCH 2/2] Changing the printing methods of quantum.Spin 2

Adding the needed field to J?Bra.
---
 sympy/physics/quantum/spin.py |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/sympy/physics/quantum/spin.py b/sympy/physics/quantum/spin.py
index 007efe7..ba5584b 100644
--- a/sympy/physics/quantum/spin.py
+++ b/sympy/physics/quantum/spin.py
@@ -496,6 +496,8 @@ def _represent_JzOp(self, basis, **options):
 class JzBra(SpinState, Bra):
     """Eigenbra of Jz."""
 
+    _direction_string_label="z"
+
     @property
     def dual_class(self):
         return JzKet
@@ -529,6 +531,8 @@ def _represent_JzOp(self, basis, **options):
 class JxBra(SpinState, Bra):
     """Eigenbra of Jx."""
 
+    _direction_string_label="x"
+
     @property
     def dual_class(self):
         return JxKet
@@ -562,6 +566,8 @@ def _represent_JzOp(self, basis, **options):
 class JyBra(SpinState, Bra):
     """Eigenbra of Jy."""
 
+    _direction_string_label="y"
+
     @property
     def dual_class(self):
         return JyKet
-- 
1.7.1

Reply via email to