2018-03-22 18:11:39 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
2019-09-04 23:34:00 +02:00
|
|
|
from app4triqs import Toto, chain
|
2020-05-28 02:16:37 +02:00
|
|
|
from triqs.archive import *
|
|
|
|
from triqs.utility import mpi
|
2018-03-22 18:11:39 +01:00
|
|
|
|
|
|
|
class test_toto(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_add(self):
|
|
|
|
|
|
|
|
a=Toto(0)
|
|
|
|
b=Toto(2)
|
|
|
|
|
|
|
|
c=a+b
|
2020-08-03 17:32:27 +02:00
|
|
|
self.assertEqual(c, b)
|
2018-03-22 18:11:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_h5(self):
|
|
|
|
|
|
|
|
a=Toto(0)
|
2018-03-26 00:31:39 +02:00
|
|
|
with HDFArchive("f.h5",'w') as A:
|
2018-03-22 18:11:39 +01:00
|
|
|
A["a"] = a
|
|
|
|
with HDFArchive("f.h5",'r') as A:
|
|
|
|
a_read = A["a"]
|
|
|
|
self.assertEqual(a, a_read)
|
|
|
|
|
|
|
|
|
|
|
|
def test_mpi(self):
|
|
|
|
|
|
|
|
a=Toto(0)
|
|
|
|
|
|
|
|
if mpi.is_master_node():
|
|
|
|
a=Toto(1)
|
|
|
|
mpi.bcast(a)
|
|
|
|
|
|
|
|
self.assertEqual(a, Toto(1))
|
|
|
|
|
2019-09-04 23:34:00 +02:00
|
|
|
class test_chain(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_chain(self):
|
|
|
|
|
|
|
|
i = 111
|
|
|
|
j = 222
|
|
|
|
ij = chain(i,j)
|
|
|
|
self.assertEqual(ij, 111222)
|
2018-03-22 18:11:39 +01:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|