I don't know much about numpy, so this one has me stumped. For some reason numpy.matrix([[0, I]], dtype='complex') fails in Python 2.5 (with the above error), but not in Python 2.6 or 2.7 (I is sympy.I).
Can someone with numpy knowledge give any insight here? Otherwise, I think the solution might have to be to disable numpy support in the quantum code in Python 2.5. I haven't looked at why it kills the test runner yet. I'll look at that now. By the way, a workaround might be to do np.matrix([map(complex, i) for i in m.tolist()], dtype=complex), i.e., manually convert the elements of the Matrix to complex, but this is rather hackish and I would prefer to aviod it if possible. Aaron Meurer On Sun, Jun 19, 2011 at 5:36 PM, Aaron Meurer <[email protected]> wrote: > Thanks for reporting this. It seems you've uncovered two bugs (the > second one is that the error killed the test runner). > > I'll see if I can figure out how to fix at least the numpy one for the > release. Do you know how to fix it? If so, please send a pull > request. > > Aaron Meurer > > On Sat, Jun 18, 2011 at 1:03 PM, Ted Horst <[email protected]> wrote: >> I'm a little late to the party, but I just tested 0.7.0 tip and got this >> error (stopped testing): >> >> This is with python 2.5.1, numpy 1.5.0, no scipy, no gmpy on OSX 10.5.8 PPC >> (big endian). >> >> I can get the error from just importing sympy.physics.quantum.matrixcache. >> It makes sense because we are passing sympy.I with dtype 'complex' to >> numpy. >> >> Ted >> >> Traceback (most recent call last): >> File "setup.py", line 269, in <module> >> 'audit' : audit, >> File >> "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/core.py", >> line 151, in setup >> dist.run_commands() >> File >> "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/dist.py", >> line 974, in run_commands >> self.run_command(cmd) >> File >> "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/dist.py", >> line 994, in run_command >> cmd_obj.run() >> File "setup.py", line 161, in run >> if sympy.test(): >> File "sympy/utilities/runtests.py", line 181, in test >> return t.test(sort=sort) >> File "sympy/utilities/runtests.py", line 487, in test >> self.test_file(f) >> File "sympy/utilities/runtests.py", line 499, in test_file >> execfile(filename, gl) >> File >> "/users/ted/developer/opensource/sympy/sympy_github2/sympy/physics/quantum/tests/test_gate.py", >> line 4, in <module> >> from sympy.physics.quantum.gate import (XGate, YGate, ZGate, >> random_circuit, >> File "sympy/physics/quantum/gate.py", line 31, in <module> >> from sympy.physics.quantum.matrixcache import matrix_cache >> File "sympy/physics/quantum/matrixcache.py", line 92, in <module> >> matrix_cache.cache_matrix('Y', Matrix([[0, -I], [I, 0]])) >> File "sympy/physics/quantum/matrixcache.py", line 38, in cache_matrix >> self._numpy_matrix(name, m) >> File "sympy/physics/quantum/matrixcache.py", line 72, in _numpy_matrix >> m = to_numpy(m, dtype=self.dtype) >> File "sympy/physics/quantum/matrixutils.py", line 99, in to_numpy >> return sympy_to_numpy(m, dtype=dtype) >> File "sympy/physics/quantum/matrixutils.py", line 53, in sympy_to_numpy >> return np.matrix(m.tolist(), dtype=dtype) >> File "numpy/matrixlib/defmatrix.py", line 257, in __new__ >> TypeError: a float is required >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sympy" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
