本文整理汇总了Python中diffpy.srreal.pdfcalculator.PDFCalculator._namesOfDoubleAttributes方法的典型用法代码示例。如果您正苦于以下问题:Python PDFCalculator._namesOfDoubleAttributes方法的具体用法?Python PDFCalculator._namesOfDoubleAttributes怎么用?Python PDFCalculator._namesOfDoubleAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类diffpy.srreal.pdfcalculator.PDFCalculator
的用法示例。
在下文中一共展示了PDFCalculator._namesOfDoubleAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test__namesOfWritableDoubleAttributes
# 需要导入模块: from diffpy.srreal.pdfcalculator import PDFCalculator [as 别名]
# 或者: from diffpy.srreal.pdfcalculator.PDFCalculator import _namesOfDoubleAttributes [as 别名]
def test__namesOfWritableDoubleAttributes(self):
"""check Attributes._namesOfDoubleAttributes()
"""
a = Attributes()
self.assertEqual(0, len(a._namesOfDoubleAttributes()))
a._registerDoubleAttribute('bar', lambda obj: 13)
self.assertEqual(13, a._getDoubleAttr('bar'))
self.assertEqual(13, a.bar)
self.assertEqual(1, len(a._namesOfDoubleAttributes()))
self.assertEqual(0, len(a._namesOfWritableDoubleAttributes()))
pdfc = PDFCalculator()
self.failUnless('extendedrmin' in pdfc._namesOfDoubleAttributes())
self.failUnless('extendedrmax' in pdfc._namesOfDoubleAttributes())
self.failIf('extendedrmin' in pdfc._namesOfWritableDoubleAttributes())
self.failIf('extendedrmax' in pdfc._namesOfWritableDoubleAttributes())
return
示例2: TestPDFCalculator
# 需要导入模块: from diffpy.srreal.pdfcalculator import PDFCalculator [as 别名]
# 或者: from diffpy.srreal.pdfcalculator.PDFCalculator import _namesOfDoubleAttributes [as 别名]
class TestPDFCalculator(unittest.TestCase):
nickel = None
tio2rutile = None
def setUp(self):
self.pdfcalc = PDFCalculator()
if not self.nickel:
type(self).nickel = loadDiffPyStructure('Ni.stru')
if not self.tio2rutile:
type(self).tio2rutile = (
loadDiffPyStructure('TiO2_rutile-fit.stru'))
return
def tearDown(self):
return
def test___init__(self):
"""check PDFCalculator.__init__()
"""
pdfc = PDFCalculator(qmin=13, rmin=4, rmax=99)
self.assertEqual(13, pdfc.qmin)
self.assertEqual(4, pdfc.rmin)
self.assertEqual(99, pdfc.rmax)
self.assertEqual(99, pdfc._getDoubleAttr('rmax'))
return
def test___call__(self):
"""Check PDFCalculator.__call__()
"""
from diffpy.Structure import Structure
r0, g0 = self.pdfcalc(self.tio2rutile, rmin=2)
self.assertEqual(2.0, r0[0])
r1, g1 = self.pdfcalc(self.tio2rutile, scale=7)
self.assertAlmostEqual(7.0, g1[0] / g0[0])
# check application of spdiameter
rutile2 = Structure(self.tio2rutile)
# work around Structure bug of shared pdffit dictionary
rutile2.pdffit = dict(self.tio2rutile.pdffit)
rutile2.pdffit['spdiameter'] = 5.0
r3, g3 = self.pdfcalc(rutile2)
self.assertEqual(0.0, sum(g3[r3 >= 5] ** 2))
r4, g4 = self.pdfcalc(rutile2, scale=1, spdiameter=0)
self.failUnless(numpy.all(r4 == r0))
self.failUnless(numpy.all(g4 == g0))
return
def test__getDoubleAttr(self):
"""check PDFCalculator._getDoubleAttr()
"""
gdba = self.pdfcalc._getDoubleAttr
self.assertEqual(1.0, gdba('scale'))
self.assertEqual(0.0, gdba('qdamp'))
self.assertRaises(Exception, gdba, 'notanattribute')
return
def test__hasDoubleAttr(self):
"""check PDFCalculator._hasDoubleAttr()
"""
self.failUnless(self.pdfcalc._hasDoubleAttr('scale'))
self.failIf(self.pdfcalc._hasDoubleAttr('notanattribute'))
return
def test__namesOfDoubleAttributes(self):
"""check PDFCalculator._namesOfDoubleAttributes()
"""
self.failUnless(type(self.pdfcalc._namesOfDoubleAttributes()) is set)
self.failUnless('qmax' in self.pdfcalc._namesOfDoubleAttributes())
return
def test__setDoubleAttr(self):
"""check PDFCalculator._setDoubleAttr()
"""
gdba = self.pdfcalc._getDoubleAttr
sdba = self.pdfcalc._setDoubleAttr
self.assertEqual(0.0, gdba('rmin'))
sdba('rmin', 3.0)
self.assertEqual(3.0, gdba('rmin'))
return
def test_eval_nickel(self):
"""check PDFCalculator.eval() on simple Nickel data
"""
fnipf2 = datafile('Ni-fit.fgr')
gpf2 = numpy.loadtxt(fnipf2, usecols=(1,))
self.pdfcalc._setDoubleAttr('rmax', 10.0001)
self.pdfcalc.eval(self.nickel)
gcalc = self.pdfcalc.pdf
self.failUnless(_maxNormDiff(gpf2, gcalc) < 0.0091)
return
def test_eval_rutile(self):
"""check PDFCalculator.eval() on anisotropic rutile data
"""
frutile = datafile('TiO2_rutile-fit.fgr')
gpf2 = numpy.loadtxt(frutile, usecols=(1,))
# configure calculator according to testdata/TiO2_ruitile-fit.fgr
self.pdfcalc.qmax = 26
self.pdfcalc.qdamp = 0.0665649
dscale = 0.655857
#.........这里部分代码省略.........