예제 #1
0
파일: test_io.py 프로젝트: PiQuer/pycppqed
 def test_splitstatevector(self):
     testdir = self.cppqeddir
     for name in os.listdir(testdir):
         readpath = os.path.join(testdir, name)
         evs, qs = io.load_cppqed(readpath)
         tempdirpath = tempfile.mkdtemp(prefix="pycppqed_test_")
         writepath = os.path.join(tempdirpath, "cppqed")
         io.split_cppqed(readpath, writepath)
         evs2, qs2 = io.load_cppqed(writepath)
         svnames = os.listdir(tempdirpath)
         svnames.sort()
         svs2 = [io.load_statevector(os.path.join(tempdirpath, svname))\
                 for svname in svnames[1:]]
         shutil.rmtree(tempdirpath)
         self.assert_((evs2==evs).all())
         svs2 = statevector.StateVectorTrajectory(svs2)
         self.assert_((svs2==qs.statevector).all())
예제 #2
0
파일: test_io.py 프로젝트: PiQuer/pycppqed
 def test_saveloadstatevector(self):
     SV = statevector.StateVector
     a = SV((1,2,3), time=1)
     b = SV((0,2+1j,5-2j,6), time=1.2)
     pars = (
         a,
         b,
         a^b,
         a^b^a,
         a^a^a^a,
         )
     for sv in pars:
         f, path = tempfile.mkstemp(prefix="pycppqed_test_")
         io.save_statevector(path, sv)
         sv2 = io.load_statevector(path)
         os.remove(path)
         self.assert_((sv==sv2).all())