Beispiel #1
0
 def test_nometa(self):
     '''check NoMetaStructureAdapter.
     '''
     r0, g0 = PDFCalculator()(self.nickel)
     ni1 = self.nickel.copy()
     ni1.pdffit['scale'] = 2.0
     r1, g1 = PDFCalculator()(ni1)
     self.assertTrue(numpy.array_equal(r0, r1))
     self.assertTrue(numpy.allclose(2 * g0, g1))
     ni1nm = nometa(ni1)
     self.assertTrue(ni1nm is nometa(ni1nm))
     r1nm, g1nm = PDFCalculator()(ni1nm)
     self.assertTrue(numpy.array_equal(r0, r1nm))
     self.assertTrue(numpy.allclose(g0, g1nm))
     ni2 = self.nickel.copy()
     ni2.pdffit['delta2'] = 4
     r2, g2 = PDFCalculator()(ni2)
     r2, g2nm = PDFCalculator()(nometa(ni2))
     self.assertFalse(numpy.allclose(g0, g2))
     self.assertTrue(numpy.allclose(g0, g2nm))
     adpt2 = createStructureAdapter(ni2)
     ra2, ga2 = PDFCalculator()(adpt2)
     ra2, ga2nm = PDFCalculator()(nometa(adpt2))
     self.assertTrue(numpy.allclose(g2, ga2))
     self.assertTrue(numpy.allclose(g0, ga2nm))
     return
 def test_nometa(self):
     '''check NoMetaStructureAdapter.
     '''
     r0, g0 = PDFCalculator()(self.nickel)
     ni1 = Structure(self.nickel)
     ni1.pdffit['scale'] = 2.0
     r1, g1 = PDFCalculator()(ni1)
     self.assertTrue(numpy.array_equal(r0, r1))
     self.assertTrue(numpy.allclose(2 * g0, g1))
     ni1nm = nometa(ni1)
     self.assertTrue(ni1nm is nometa(ni1nm))
     r1nm, g1nm = PDFCalculator()(ni1nm)
     self.assertTrue(numpy.array_equal(r0, r1nm))
     self.assertTrue(numpy.allclose(g0, g1nm))
     ni2 = Structure(self.nickel)
     ni2.pdffit['delta2'] = 4
     r2, g2 = PDFCalculator()(ni2)
     r2, g2nm = PDFCalculator()(nometa(ni2))
     self.assertFalse(numpy.allclose(g0, g2))
     self.assertTrue(numpy.allclose(g0, g2nm))
     adpt2 = createStructureAdapter(ni2)
     ra2, ga2 = PDFCalculator()(adpt2)
     ra2, ga2nm = PDFCalculator()(nometa(adpt2))
     self.assertTrue(numpy.allclose(g2, ga2))
     self.assertTrue(numpy.allclose(g0, ga2nm))
     return
Beispiel #3
0
    def _getSrRealStructure(self):
        """Get the structure object for use with SrReal calculators.

        If this is periodic, then return the structure, otherwise, pass it
        inside of a nosymmetry wrapper. This takes the extra step of wrapping
        the structure in a nometa wrapper.

        """
        stru = SrRealParSet._getSrRealStructure(self)
        return nometa(stru)
Beispiel #4
0
    def _getSrRealStructure(self):
        """Get the structure object for use with SrReal calculators.

        If this is periodic, then return the structure, otherwise, pass it
        inside of a nosymmetry wrapper. This takes the extra step of wrapping
        the structure in a nometa wrapper.

        """
        from diffpy.srreal.structureadapter import nometa
        stru = SrRealParSet._getSrRealStructure(self)
        return nometa(stru)
 def test_nometa_pickling(self):
     '''check pickling of the NoMetaStructureAdapter wrapper.
     '''
     r0, g0 = PDFCalculator()(self.nickel)
     ni1 = Structure(self.nickel)
     ni1.pdffit['scale'] = 2.0
     ni1nm = cPickle.loads(cPickle.dumps(nometa(ni1)))
     self.assertFalse(ni1nm is ni1)
     r1nm, g1nm = PDFCalculator()(ni1nm)
     self.assertTrue(numpy.array_equal(r0, r1nm))
     self.assertTrue(numpy.array_equal(g0, g1nm))
     return
Beispiel #6
0
 def test_nometa_pickling(self):
     '''check pickling of the NoMetaStructureAdapter wrapper.
     '''
     r0, g0 = PDFCalculator()(self.nickel)
     ni1 = self.nickel.copy()
     ni1.pdffit['scale'] = 2.0
     ni1nm = pickle.loads(pickle.dumps(nometa(ni1)))
     self.assertFalse(ni1nm is ni1)
     r1nm, g1nm = PDFCalculator()(ni1nm)
     self.assertTrue(numpy.array_equal(r0, r1nm))
     self.assertTrue(numpy.array_equal(g0, g1nm))
     return
Beispiel #7
0
 def test_nometa_pickling(self):
     '''check pickling of the NoMetaStructureAdapter wrapper.
     '''
     r0, g0 = PDFCalculator()(nickel)
     ni1 = Structure(nickel)
     ni1.pdffit['scale'] = 2.0
     ni1nm = cPickle.loads(cPickle.dumps(nometa(ni1)))
     self.failIf(ni1nm is ni1)
     r1nm, g1nm = PDFCalculator()(ni1nm)
     self.failUnless(numpy.array_equal(r0, r1nm))
     self.failUnless(numpy.array_equal(g0, g1nm))
     return
 def test_nometa_twice(self):
     '''check that second call of nometa returns the same object.
     '''
     adpt1 = nometa(self.nickel)
     adpt2 = nometa(adpt1)
     self.assertTrue(adpt1 is adpt2)
Beispiel #9
0
 def test_nometa_twice(self):
     '''check that second call of nometa returns the same object.
     '''
     adpt1 = nometa(self.nickel)
     adpt2 = nometa(adpt1)
     self.assertTrue(adpt1 is adpt2)
Beispiel #10
0
 def test_nometa_twice(self):
     '''check that second call of nometa returns the same object.
     '''
     adpt1 = nometa(nickel)
     adpt2 = nometa(adpt1)
     self.failUnless(adpt1 is adpt2)
 def test_nometa_twice(self):
     '''check that second call of nometa returns the same object.
     '''
     adpt1 = nometa(nickel)
     adpt2 = nometa(adpt1)
     self.failUnless(adpt1 is adpt2)