Esempio n. 1
0
 def test_pickling(self):
     '''check pickling and unpickling of PairQuantity.
     '''
     from diffpy.srreal.tests.testutils import DerivedStructureAdapter
     stru0 = DerivedStructureAdapter()
     self.pq.setStructure(stru0)
     self.assertEqual(1, stru0.cpqcount)
     spkl = cPickle.dumps(self.pq)
     pq1 = cPickle.loads(spkl)
     self.failUnless(stru0 is self.pq.getStructure())
     stru1 = pq1.getStructure()
     self.failUnless(type(stru1) is DerivedStructureAdapter)
     self.failIf(stru1 is stru0)
     self.assertEqual(1, stru1.cpqcount)
     return
 def test_pickling_derived_structure(self):
     '''check pickling of OverlapCalculator with DerivedStructureAdapter.
     '''
     from diffpy.srreal.tests.testutils import DerivedStructureAdapter
     olc = self.olc
     stru0 = DerivedStructureAdapter()
     olc.setStructure(stru0)
     self.assertEqual(1, stru0.cpqcount)
     spkl = pickle.dumps(olc)
     olc1 = pickle.loads(spkl)
     self.assertTrue(stru0 is olc.getStructure())
     stru1 = olc1.getStructure()
     self.assertTrue(type(stru1) is DerivedStructureAdapter)
     self.assertFalse(stru1 is stru0)
     self.assertEqual(1, stru1.cpqcount)
     return
Esempio n. 3
0
 def test_pickling_derived_structure(self):
     '''check pickling of BondCalculator with DerivedStructureAdapter.
     '''
     from diffpy.srreal.tests.testutils import DerivedStructureAdapter
     bdc = self.bdc
     stru0 = DerivedStructureAdapter()
     bdc.setStructure(stru0)
     self.assertEqual(1, stru0.cpqcount)
     spkl = cPickle.dumps(bdc)
     bdc1 = cPickle.loads(spkl)
     self.failUnless(stru0 is bdc.getStructure())
     stru1 = bdc1.getStructure()
     self.failUnless(type(stru1) is DerivedStructureAdapter)
     self.failIf(stru1 is stru0)
     self.assertEqual(1, stru1.cpqcount)
     return
Esempio n. 4
0
 def test_pickling_derived_structure(self):
     '''check pickling of DebyePDFCalculator with DerivedStructureAdapter.
     '''
     from diffpy.srreal.tests.testutils import DerivedStructureAdapter
     dpdfc = self.dpdfc
     stru0 = DerivedStructureAdapter()
     dpdfc.setStructure(stru0)
     self.assertEqual(1, stru0.cpqcount)
     spkl = pickle.dumps(dpdfc)
     dpdfc1 = pickle.loads(spkl)
     self.assertTrue(stru0 is dpdfc.getStructure())
     stru1 = dpdfc1.getStructure()
     self.assertTrue(type(stru1) is DerivedStructureAdapter)
     self.assertFalse(stru1 is stru0)
     self.assertEqual(1, stru1.cpqcount)
     return
Esempio n. 5
0
 def test_pickling(self):
     '''check pickling and unpickling of PairQuantity.
     '''
     from diffpy.srreal.tests.testutils import DerivedStructureAdapter
     stru0 = DerivedStructureAdapter()
     self.pq.setStructure(stru0)
     self.assertEqual(1, stru0.cpqcount)
     spkl = pickle.dumps(self.pq)
     pq1 = pickle.loads(spkl)
     self.assertTrue(stru0 is self.pq.getStructure())
     stru1 = pq1.getStructure()
     self.assertTrue(type(stru1) is DerivedStructureAdapter)
     self.assertFalse(stru1 is stru0)
     self.assertEqual(1, stru1.cpqcount)
     # check pickling of attributes
     pcnt = PQCounter()
     pcnt.foo = "asdf"
     pcnt2 = pickle.loads(pickle.dumps(pcnt))
     self.assertTrue(isinstance(pcnt2, PQCounter))
     self.assertEqual("asdf", pcnt2.foo)
     return