本文整理汇总了Python中pyne.binaryreader._FortranRecord函数的典型用法代码示例。如果您正苦于以下问题:Python _FortranRecord函数的具体用法?Python _FortranRecord怎么用?Python _FortranRecord使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_FortranRecord函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_write_BR
def test_write_BR():
binary_file = _BinaryReader('test.file', 'wb')
if not binary_file.f:
raise ValueError("Failed to open new file for writing.")
set_int = 8
set_float = 3.14
set_double_list = [1.6e-19, 6.02e23]
set_string = "Hello World!"
test_record = _FortranRecord('', 0)
test_record.put_int([set_int])
test_record.put_string([set_string], len(set_string))
test_record.put_double(set_double_list)
test_record.put_float([set_float])
test_record.reset()
binary_file.put_fortran_record(test_record)
binary_file.close()
if not filecmp.cmp('test.file', 'test_readBR.ref'):
raise ValueError('Created file does not match reference.')
return 1
开发者ID:NukespudWork,项目名称:pyne,代码行数:26,代码来源:test_binaryreader.py
示例2: test_write_FR_double_list
def test_write_FR_double_list():
set_double_list = [3.14, 0.3333]
set_num_bytes = 16
set_data = b'\x1f\x85\xebQ\xb8\x1e\[email protected]\xf0\x85\xc9T\xd5?'
test_record = _FortranRecord('', 0)
test_record.put_double(set_double_list)
return check_write_record_data(test_record, set_num_bytes, set_num_bytes,
set_data, "list of doubles")
开发者ID:NukespudWork,项目名称:pyne,代码行数:10,代码来源:test_binaryreader.py
示例3: test_write_FR_float_list
def test_write_FR_float_list():
set_floatList = [3.14, 0.3333]
set_num_bytes = 8
set_data = b'\xc3\[email protected]\xa6\xaa>'
test_record = _FortranRecord('', 0)
test_record.put_float(set_floatList)
return check_write_record_data(test_record, set_num_bytes, set_num_bytes,
set_data, "list of floats")
开发者ID:NukespudWork,项目名称:pyne,代码行数:10,代码来源:test_binaryreader.py
示例4: test_write_FR_string_list
def test_write_FR_string_list():
set_string_list = ["Hello ", "World!"]
set_length = len(set_string_list[0])
set_num_bytes = 12
set_data = b'Hello World!'
test_record = _FortranRecord('', 0)
test_record.put_string(set_string_list, set_length)
return check_write_record_data(test_record, set_num_bytes, set_num_bytes,
set_data, "list of strings")
开发者ID:NukespudWork,项目名称:pyne,代码行数:11,代码来源:test_binaryreader.py
示例5: test_write_FR_long_list
def test_write_FR_long_list():
set_long_list = [8, 16]
set_num_bytes = 16
set_data = \
b'\x08\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00'
test_record = _FortranRecord('', 0)
test_record.put_long(set_long_list)
return check_write_record_data(test_record, set_num_bytes, set_num_bytes,
set_data, "list of 8-byte integers")
开发者ID:NukespudWork,项目名称:pyne,代码行数:11,代码来源:test_binaryreader.py
示例6: test_write_FR_int_list
def test_write_FR_int_list():
set_intList = [8, 16]
set_num_bytes = 8
set_data = b'\x08\x00\x00\x00\x10\x00\x00\x00'
test_record = _FortranRecord('', 0)
# write integer list
test_record.put_int(set_intList)
return check_write_record_data(test_record, set_num_bytes, set_num_bytes,
set_data, "list of 4-byte integers")
开发者ID:NukespudWork,项目名称:pyne,代码行数:12,代码来源:test_binaryreader.py
示例7: test_write_FR_single_int
def test_write_FR_single_int():
set_int = 8
set_num_bytes = 4
set_data = b'\x08\x00\x00\x00'
# create new record
test_record = _FortranRecord('', 0) # already tested
# write integer
test_record.put_int(set_int)
return check_write_record_data(test_record, set_num_bytes, set_num_bytes,
set_data, "4-byte integer")
开发者ID:NukespudWork,项目名称:pyne,代码行数:13,代码来源:test_binaryreader.py
示例8: test_write_FR_single_double
def test_write_FR_single_double():
set_double = 3.14
set_num_bytes = 8
set_data = b'\x1f\x85\xebQ\xb8\x1e\[email protected]'
# create new record
test_record = _FortranRecord('', 0) # already tested
# write double
test_record.put_double(set_double)
return check_write_record_data(test_record, set_num_bytes, set_num_bytes,
set_data, "double")
开发者ID:NukespudWork,项目名称:pyne,代码行数:13,代码来源:test_binaryreader.py
示例9: test_write_FR_single_float
def test_write_FR_single_float():
set_float = 3.14
set_num_bytes = 4
set_data = b'\xc3\[email protected]'
# create new record
test_record = _FortranRecord('', 0) # already tested
# write float
test_record.put_float(set_float)
return check_write_record_data(test_record, set_num_bytes, set_num_bytes,
set_data, "float")
开发者ID:NukespudWork,项目名称:pyne,代码行数:13,代码来源:test_binaryreader.py
示例10: test_make_empty_FR
def test_make_empty_FR():
test_record = _FortranRecord('', 0)
if len(test_record.data) != 0:
raise ValueError("Failed to make an new empty _FortranRecord. "
" Record has data.")
if test_record.num_bytes != 0:
raise ValueError("Failed to make an new empty _FortranRecord. "
" Record has num_bytes>0.")
if test_record.pos != 0:
raise ValueError("Failed to make an new empty _FortranRecord. "
" Position is not at 0.")
return 1
开发者ID:NukespudWork,项目名称:pyne,代码行数:14,代码来源:test_binaryreader.py
示例11: test_write_FR_single_string
def test_write_FR_single_string():
set_string = "Hello World!"
set_length = len(set_string)
set_num_bytes = 12
set_data = b'Hello World!'
# create new record
test_record = _FortranRecord('', 0) # already tested
# write string
test_record.put_string([set_string], 12, 1)
return check_write_record_data(test_record, set_num_bytes, set_num_bytes,
set_data, "string")
开发者ID:NukespudWork,项目名称:pyne,代码行数:14,代码来源:test_binaryreader.py
示例12: test_write_FR_single_long
def test_write_FR_single_long():
set_long = 8
set_num_bytes = 8
set_data = b'\x08\x00\x00\x00\x00\x00\x00\x00'
# create new record
test_record = _FortranRecord('', 0) # already tested
# write long
test_record.put_long(set_long)
return check_write_record_data(test_record, set_num_bytes, set_num_bytes,
set_data, "8-byte integer")
开发者ID:NukespudWork,项目名称:pyne,代码行数:14,代码来源:test_binaryreader.py
示例13: test_make_empty_FR
def test_make_empty_FR():
testRecord = _FortranRecord('',0)
if testRecord.data != '':
raise FortranRecordError("Failed to make an new empty _FortranRecord. "
"Record has data.")
if testRecord.numBytes != 0:
raise FortranRecordError("Failed to make an new empty _FortranRecord. "
"Record has numBytes>0.")
if testRecord.pos != 0:
raise FortranRecordError("Failed to make an new empty _FortranRecord. "
"Position is not at 0.")
return 1
开发者ID:AliZeineddine,项目名称:pyne,代码行数:14,代码来源:test_binaryreader.py
示例14: test_read_FR_string_list
def test_read_FR_string_list():
set_string_list = ["Hello ", "World!"]
set_length = len(set_string_list[0])
test_record = _FortranRecord('', 0)
test_record.put_string(set_string_list, set_length)
test_record.reset()
test_string_list = test_record.get_string(set_length, 2)
if test_string_list != set_string_list:
raise ValueError("List from get_string doesn't match value "
"from put_string.")
return 1
开发者ID:NukespudWork,项目名称:pyne,代码行数:15,代码来源:test_binaryreader.py
示例15: test_read_FR_single_int
def test_read_FR_single_int():
set_int = 8
test_record = _FortranRecord('', 0) # already tested
test_record.put_int([set_int]) # already tested
test_record.reset() # already tested
test_int = test_record.get_int()[0]
if test_int != set_int:
raise ValueError("Value from get_int doesn't match value "
"from put_int.")
return 1
开发者ID:NukespudWork,项目名称:pyne,代码行数:15,代码来源:test_binaryreader.py
示例16: test_read_FR_double_list
def test_read_FR_double_list():
double_list = [2.34, 8.65]
test_record = _FortranRecord('', 0)
test_record.put_double(double_list)
test_record.reset()
testList = test_record.get_double(2)
if testList != double_list:
raise ValueError("List from get_double doesn't match value "
"from put_double.")
return 1
开发者ID:NukespudWork,项目名称:pyne,代码行数:15,代码来源:test_binaryreader.py
示例17: test_reset_FR
def test_reset_FR():
temp_pos = 4
test_record = _FortranRecord('', 0) # already tested
test_record.pos = temp_pos
if test_record.pos != temp_pos:
raise ValueError("Internal error: unable to update test_record.pos")
test_record.reset()
if test_record.pos != 0:
raise ValueError("reset() method did not reset pos")
return 1
开发者ID:NukespudWork,项目名称:pyne,代码行数:15,代码来源:test_binaryreader.py
示例18: test_read_FR_single_double
def test_read_FR_single_double():
set_double = 1.43
test_record = _FortranRecord('', 0)
test_record.put_double([set_double])
test_record.reset()
testDouble = test_record.get_double()[0]
if testDouble != set_double:
raise ValueError("Value from get_double doesn't match value "
"from put_double.")
return 1
开发者ID:NukespudWork,项目名称:pyne,代码行数:15,代码来源:test_binaryreader.py
示例19: test_read_FR_single_long
def test_read_FR_single_long():
set_long = 8
test_record = _FortranRecord('', 0) # already tested
test_record.put_long([set_long]) # already tested
test_record.reset() # already tested
testLong = test_record.get_long()[0]
if testLong != set_long:
raise ValueError("Value from get_long doesn't match value "
"from put_long.")
return 1
开发者ID:NukespudWork,项目名称:pyne,代码行数:15,代码来源:test_binaryreader.py
示例20: test_read_FR_int_list
def test_read_FR_int_list():
set_intList = [8, 16]
num_ints = 2
test_record = _FortranRecord('', 0) # already tested
test_record.put_int(set_intList) # already tested
test_record.reset() # already tested
test_int = test_record.get_int(num_ints)
if test_int != set_intList:
raise ValueError("Value from get_int doesn't match value "
"from put_int.")
return 1
开发者ID:NukespudWork,项目名称:pyne,代码行数:16,代码来源:test_binaryreader.py
注:本文中的pyne.binaryreader._FortranRecord函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论