本文整理汇总了Python中pyne.binaryreader._FortranRecord函数的典型用法代码示例。如果您正苦于以下问题:Python _FortranRecord函数的具体用法?Python _FortranRecord怎么用?Python _FortranRecord使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_FortranRecord函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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")
示例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")
示例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")
示例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")
示例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")
示例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")
示例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")
示例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")
示例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
示例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")
示例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")
示例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
示例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
示例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