Added a test and fixed some related whitespace errors. --- sympy/physics/secondquant.py | 20 +++++--------------- sympy/physics/tests/test_secondquant.py | 9 +++++---- 2 files changed, 10 insertions(+), 19 deletions(-)
diff --git a/sympy/physics/secondquant.py b/sympy/physics/secondquant.py index 5d3f77b..ce0b80c 100644 --- a/sympy/physics/secondquant.py +++ b/sympy/physics/secondquant.py @@ -146,18 +146,14 @@ class TensorSymbol(Function): class SymTuple(Basic): - - def __new__(cls, arg_tuple, **kw_args): - """ - the wrapped tuple is available as self.args - """ - obj = Basic.__new__(cls,*arg_tuple, **kw_args) - return obj + """ + the wrapped tuple is available as self.args + """ def __getitem__(self,i): if isinstance(i,slice): indices = i.indices(len(self)) - return SymTuple(tuple([self.args[i] for i in range(*indices)])) + return SymTuple(*[self.args[i] for i in range(*indices)]) return self.args[i] def __len__(self): @@ -166,12 +162,6 @@ def __len__(self): def __contains__(self,item): return item in self.args - def _eval_subs(self,old,new): - if self==old: - return new - t=tuple([ el._eval_subs(old,new) for el in self.args]) - return self.__class__(t) - def _tuple_wrapper(method): """ @@ -181,7 +171,7 @@ def wrap_tuples(*args, **kw_args): newargs=[] for arg in args: if type(arg) is tuple: - newargs.append(SymTuple(arg)) + newargs.append(SymTuple(*arg)) else: newargs.append(arg) return method(*newargs, **kw_args) diff --git a/sympy/physics/tests/test_secondquant.py b/sympy/physics/tests/test_secondquant.py index f286098..61b2276 100644 --- a/sympy/physics/tests/test_secondquant.py +++ b/sympy/physics/tests/test_secondquant.py @@ -15,16 +15,17 @@ def test_SymTuple(): - t = (1,2,3,4) - st = SymTuple(t) + t = (1, 2, 3, 4) + st = SymTuple(*t) assert set(t) == set(st) assert len(t) == len(st) assert set(t[:2]) == set(st[:2]) assert isinstance(st[:], SymTuple) - assert st == SymTuple((1,2,3,4)) + assert st == SymTuple(1, 2, 3, 4) + assert st.func(*st.args) == st p,q,r,s = symbols('pqrs') t2=(p,q,r,s) - st2 = SymTuple(t2) + st2 = SymTuple(*t2) assert st2.atoms() == set(t2) def test_PermutationOperator(): -- 1.6.5 -- You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patc...@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.