本文整理汇总了Python中pyne.material.Material.write_text方法的典型用法代码示例。如果您正苦于以下问题:Python Material.write_text方法的具体用法?Python Material.write_text怎么用?Python Material.write_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyne.material.Material
的用法示例。
在下文中一共展示了Material.write_text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_write_text
# 需要导入模块: from pyne.material import Material [as 别名]
# 或者: from pyne.material.Material import write_text [as 别名]
def test_write_text():
if 'leu.txt' in os.listdir('.'):
os.remove('leu.txt')
leu = Material({'U235': 0.04, 'U238': 0.96}, 42.0, 1.0, 1.0)
leu.write_text('leu.txt')
with open('leu.txt') as f:
written = f.read()
expected = ("Mass 42\n"
"Density 1\n"
"APerM 1\n"
"U235 0.04\n"
"U238 0.96\n")
assert_equal(written, expected)
read_leu = from_text('leu.txt')
assert_equal(leu.mass, read_leu.mass)
assert_equal(leu.atoms_per_molecule, read_leu.atoms_per_molecule)
assert_equal(leu.comp, read_leu.comp)
os.remove('leu.txt')