当前位置: 首页>>代码示例>>Python>>正文


Python Elements.isValidMaterial方法代码示例

本文整理汇总了Python中PyMca5.PyMcaPhysics.Elements.isValidMaterial方法的典型用法代码示例。如果您正苦于以下问题:Python Elements.isValidMaterial方法的具体用法?Python Elements.isValidMaterial怎么用?Python Elements.isValidMaterial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyMca5.PyMcaPhysics.Elements的用法示例。


在下文中一共展示了Elements.isValidMaterial方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: validate

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import isValidMaterial [as 别名]
 def validate(self, qstring, pos):
     text = str(qstring)
     if text == '-':
         return (self.Valid, pos)
     try:
         # this test is needed even if pyflakes complains!
         float(text)
         return (self.Invalid, pos)
     except:
         pass
     if text.endswith(' '):
         return (self.Invalid, pos)
     if Elements.isValidFormula(text):
         return (self.Valid, pos)
     elif Elements.isValidMaterial(text):
         return (self.Valid, pos)
     else:
         return (self.Invalid,pos)
开发者ID:vasole,项目名称:pymca,代码行数:20,代码来源:MaterialEditor.py

示例2: _checkDensityThickness

# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import isValidMaterial [as 别名]
 def _checkDensityThickness(self, text, row):
     try:
         currentDensity = float(str(self.text(row, 3)))
     except:
         currentDensity = 0.0
     try:
         currentThickness = float(str(self.text(row, 4)))
     except:
         currentThickness = 0.0
     defaultDensity = -1.0
     defaultThickness = -0.1
     #check if default density is there
     if Elements.isValidFormula(text):
         #check if single element
         if text in Elements.Element.keys():
             defaultDensity = Elements.Element[text]['density']
         else:
             elts = [ w for w in re.split('[0-9]', text) if w != '']
             nbs = [ int(w) for w in re.split('[a-zA-Z]', text) if w != '']
             if len(elts) == 1 and len(nbs) == 1:
                 defaultDensity = Elements.Element[elts[0]]['density']
     elif Elements.isValidMaterial(text):
         key = Elements.getMaterialKey(text)
         if key is not None:
             if 'Density' in Elements.Material[key]:
                 defaultDensity = Elements.Material[key]['Density']
             if 'Thickness' in Elements.Material[key]:
                 defaultThickness = Elements.Material[key]['Thickness']
     if defaultDensity >= 0.0:
         self.setText(row, 3, "%g" % defaultDensity)
     elif currentDensity <= 0:
         # should not be better to raise an exception if the
         # entered density or thickness were negative?
         self.setText(row, 3, "%g" % 1.0)
     if defaultThickness >= 0.0:
         self.setText(row, 4, "%g" % defaultThickness)
     elif currentThickness <= 0.0:
         # should not be better to raise an exception if the
         # entered density or thickness were negative?
         self.setText(row, 4, "%g" % 0.1)
开发者ID:dnaudet,项目名称:pymca,代码行数:42,代码来源:AttenuatorsTable.py


注:本文中的PyMca5.PyMcaPhysics.Elements.isValidMaterial方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。