當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。