Ondrej Certik wrote: > Hi Alan! > > On Sun, May 31, 2009 at 5:36 AM, Alan Bromborsky <abro...@verizon.net> wrote: > >> Multivector static member str_rep(mv) called by __str__(self) did not >> complete string processing for grade 0 (scalar) multivectors. Fixed >> problem and removed all spaces from output to reduce length of string. >> > > Thanks for the patch, it's +1. Could you please also add a test for > it? I'll then push both things in. > > Ondrej > > > > >
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patches@googlegroups.com To unsubscribe from this group, send email to sympy-patches+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy-patches?hl=en -~----------~----~----~----~------~----~------~--~---
>From cf70262e390f378d59042fce9deef3cd4e96b6b6 Mon Sep 17 00:00:00 2001 From: Alan Bromborsky <bro...@ga.(none)> Date: Sun, 31 May 2009 15:03:50 -0400 Subject: [PATCH] Fixed special case in __str__ function for multivector and added test for special case. --- sympy/galgebra/GA.py | 6 +++++- sympy/galgebra/tests/test_GA.py | 1 + 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/sympy/galgebra/GA.py b/sympy/galgebra/GA.py index d3cc077..c77ad97 100644 --- a/sympy/galgebra/GA.py +++ b/sympy/galgebra/GA.py @@ -751,10 +751,12 @@ class MV(object): labels = MV.basislabel else: labels = MV.bladelabel + mv.compact() if isinstance(mv.mv[0],types.IntType): value = '' else: value = (mv.mv[0][0]).__str__() + value = value.replace(' ','') dummy = sympy.Symbol('dummy') for igrade in MV.n1rg[1:]: if isinstance(mv.mv[igrade],numpy.ndarray): @@ -762,6 +764,7 @@ class MV(object): for x in mv.mv[igrade]: if x != ZERO: xstr = (x*dummy).__str__() + xstr = xstr.replace(' ','') if xstr[0] != '-' and len(value) > 0: xstr = '+'+xstr if xstr.find('dummy') < 2 and xstr[-5:] != 'dummy': @@ -776,7 +779,8 @@ class MV(object): value += '\n' if value == '': value = '0' - value = value.replace(' ','') + #value = value.replace(' ','') + value = value.replace('dummy','1') return(value) @staticmethod diff --git a/sympy/galgebra/tests/test_GA.py b/sympy/galgebra/tests/test_GA.py index 625ae4b..4f16c90 100644 --- a/sympy/galgebra/tests/test_GA.py +++ b/sympy/galgebra/tests/test_GA.py @@ -271,3 +271,4 @@ def test_str(): assert str(Y) == 'y+y__01*e_1e_2+y__02*e_1e_3+y__12*e_2e_3' Z = X+Y assert str(Z) == 'x+y+x__0*e_1+x__1*e_2+x__2*e_3+(x__01+y__01)*e_1e_2+(x__02+y__02)*e_1e_3+(x__12+y__12)*e_2e_3+x__012*e_1e_2e_3' + assert str(e_1|e_1) == '1' \ No newline at end of file -- 1.6.0.4