本文整理汇总了Python中mi.dataset.parser.mopak_o_dcl.MopakODclParser.get_records方法的典型用法代码示例。如果您正苦于以下问题:Python MopakODclParser.get_records方法的具体用法?Python MopakODclParser.get_records怎么用?Python MopakODclParser.get_records使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mi.dataset.parser.mopak_o_dcl.MopakODclParser
的用法示例。
在下文中一共展示了MopakODclParser.get_records方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simple
# 需要导入模块: from mi.dataset.parser.mopak_o_dcl import MopakODclParser [as 别名]
# 或者: from mi.dataset.parser.mopak_o_dcl.MopakODclParser import get_records [as 别名]
def test_simple(self):
"""
Read test data and pull out data particles one at a time.
Assert that the results are those we expected.
"""
stream_handle = open(os.path.join(RESOURCE_PATH, 'first.mopak.log'))
parser = MopakODclParser(self.config, stream_handle,
'20140120_140004.mopak.log',
self.exception_callback)
# next get acceleration records
result = parser.get_records(1)
self.assertEqual(result[0], self.particle_a_accel)
self.assertEqual(self.exception_callback_value, [])
result = parser.get_records(1)
self.assertEqual(result[0], self.particle_b_accel)
self.assertEqual(self.exception_callback_value, [])
result = parser.get_records(1)
self.assertEqual(result[0], self.particle_c_accel)
self.assertEqual(self.exception_callback_value, [])
result = parser.get_records(1)
self.assertEqual(result[0], self.particle_d_accel)
self.assertEqual(self.exception_callback_value, [])
result = parser.get_records(1)
self.assertEqual(result[0], self.particle_e_accel)
self.assertEqual(self.exception_callback_value, [])
# no data left, don't move the position
result = parser.get_records(1)
self.assertEqual(result, [])
self.assertEqual(self.exception_callback_value, [])
示例2: test_long_stream_rate
# 需要导入模块: from mi.dataset.parser.mopak_o_dcl import MopakODclParser [as 别名]
# 或者: from mi.dataset.parser.mopak_o_dcl.MopakODclParser import get_records [as 别名]
def test_long_stream_rate(self):
"""
Test a long (normal length file) with accel and rate particles
"""
stream_handle = open(os.path.join(RESOURCE_PATH,
'20140313_191853.3dmgx3.log'))
parser = MopakODclParser(self.config, stream_handle,
'20140313_191853.3dmgx3.log',
self.exception_callback)
result = parser.get_records(148)
self.assertEqual(result[0], self.particle_a11_accel)
self.assertEqual(result[-1], self.particle_last_rate)
self.assertEqual(self.exception_callback_value, [])
示例3: test_long_stream_yml
# 需要导入模块: from mi.dataset.parser.mopak_o_dcl import MopakODclParser [as 别名]
# 或者: from mi.dataset.parser.mopak_o_dcl.MopakODclParser import get_records [as 别名]
def test_long_stream_yml(self):
"""
Verify an entire file against a yaml result file.
"""
with open(os.path.join(RESOURCE_PATH, '20140120_140004.mopak.log'), 'rb') as stream_handle:
parser = MopakODclParser(self.config, stream_handle,
'20140120_140004.mopak.log',
self.exception_callback)
particles = parser.get_records(10)
self.assert_particles(particles, 'first_mopak_recov.result.yml', RESOURCE_PATH)
self.assertEqual(self.exception_callback_value, [])
示例4: test_long_stream
# 需要导入模块: from mi.dataset.parser.mopak_o_dcl import MopakODclParser [as 别名]
# 或者: from mi.dataset.parser.mopak_o_dcl.MopakODclParser import get_records [as 别名]
def test_long_stream(self):
"""
Test a long (normal length file)
"""
stream_handle = open(os.path.join(RESOURCE_PATH,
'20140120_140004_extradata.mopak.log'))
parser = MopakODclParser(self.config, stream_handle,
'20140120_140004.mopak.log',
self.exception_callback)
result = parser.get_records(11964)
self.assertEqual(result[0], self.particle_a_accel)
self.assertEqual(result[-1], self.particle_last_accel)
self.assertEqual(self.exception_callback_value, [])
示例5: test_get_many
# 需要导入模块: from mi.dataset.parser.mopak_o_dcl import MopakODclParser [as 别名]
# 或者: from mi.dataset.parser.mopak_o_dcl.MopakODclParser import get_records [as 别名]
def test_get_many(self):
"""
Read test data and pull out multiple data particles at one time.
Assert that the results are those we expected.
"""
stream_handle = open(os.path.join(RESOURCE_PATH,
'first.mopak.log'))
parser = MopakODclParser(self.config, stream_handle,
'20140120_140004.mopak.log',
self.exception_callback)
# next get accel records
result = parser.get_records(5)
self.assertEqual(result, [self.particle_a_accel,
self.particle_b_accel,
self.particle_c_accel,
self.particle_d_accel,
self.particle_e_accel])
self.assertEqual(self.exception_callback_value, [])
示例6: test_bad_checksum
# 需要导入模块: from mi.dataset.parser.mopak_o_dcl import MopakODclParser [as 别名]
# 或者: from mi.dataset.parser.mopak_o_dcl.MopakODclParser import get_records [as 别名]
def test_bad_checksum(self):
"""
This tests that the parser raises a Configuration Exception if the
required configuration items are not present
"""
stream_handle = open(os.path.join(RESOURCE_PATH,
'20140313_191853_bad_chksum.3dmgx3.log'))
parser = MopakODclParser(self.config, stream_handle,
'20140313_191853.3dmgx3.log',
self.exception_callback)
result = parser.get_records(10)
self.assertEqual(len(result), 5)
self.assertEqual(len(self.exception_callback_value), 2)
self.assert_(isinstance(self.exception_callback_value[0], SampleException))
self.assert_(isinstance(self.exception_callback_value[1], SampleException))
示例7: test_non_data_exception
# 需要导入模块: from mi.dataset.parser.mopak_o_dcl import MopakODclParser [as 别名]
# 或者: from mi.dataset.parser.mopak_o_dcl.MopakODclParser import get_records [as 别名]
def test_non_data_exception(self):
"""
Test that we get a sample exception from non data being found in the file
"""
stream_handle = open(os.path.join(RESOURCE_PATH, 'noise.mopak.log'))
parser = MopakODclParser(self.config, stream_handle,
'20140120_140004.mopak.log',
self.exception_callback)
# next get accel records
result = parser.get_records(5)
self.assertEqual(result, [self.particle_a_accel,
self.particle_b_accel,
self.particle_c_accel,
self.particle_d_accel,
self.particle_e_accel])
self.assertEqual(len(self.exception_callback_value), 1)
self.assert_(isinstance(self.exception_callback_value[0], SampleException))
示例8: MopakODclParserUnitTestCase
# 需要导入模块: from mi.dataset.parser.mopak_o_dcl import MopakODclParser [as 别名]
# 或者: from mi.dataset.parser.mopak_o_dcl.MopakODclParser import get_records [as 别名]
#.........这里部分代码省略.........
for val in particle_dict.get('values'):
if isinstance(val.get('value'), float):
fid.write(' %s: %16.20f\n' % (val.get('value_id'), val.get('value')))
else:
fid.write(' %s: %s\n' % (val.get('value_id'), val.get('value')))
fid.close()
def assert_result(self, result, position, particle, ingested, timer_start, timer_rollover=0):
self.assertEqual(result, [particle])
self.assertEqual(self.file_ingested_value, ingested)
self.assertEqual(self.parser._state[StateKey.POSITION], position)
self.assertEqual(self.state_callback_value[StateKey.POSITION], position)
self.assertEqual(self.parser._state[StateKey.TIMER_ROLLOVER], timer_rollover)
self.assertEqual(self.state_callback_value[StateKey.TIMER_ROLLOVER], timer_rollover)
self.assertEqual(self.parser._state[StateKey.TIMER_START], timer_start)
self.assertEqual(self.state_callback_value[StateKey.TIMER_START], timer_start)
self.assert_(isinstance(self.publish_callback_value, list))
self.assertEqual(self.publish_callback_value[0], particle)
def test_simple(self):
"""
Read test data and pull out data particles one at a time.
Assert that the results are those we expected.
"""
self.stream_handle = open(os.path.join(RESOURCE_PATH,
'first.mopak.log'))
self.parser = MopakODclParser(self.config, self.start_state, self.stream_handle,
'20140120_140004.mopak.log',
self.state_callback, self.pub_callback,
self.except_callback)
# next get acceleration records
result = self.parser.get_records(1)
self.assert_result(result, 43, self.particle_a_accel, False, self._timer_start)
result = self.parser.get_records(1)
self.assert_result(result, 86, self.particle_b_accel, False, self._timer_start)
result = self.parser.get_records(1)
self.assert_result(result, 129, self.particle_c_accel, False, self._timer_start)
result = self.parser.get_records(1)
self.assert_result(result, 172, self.particle_d_accel, False, self._timer_start)
result = self.parser.get_records(1)
self.assert_result(result, 215, self.particle_e_accel, True, self._timer_start)
# no data left, dont move the position
result = self.parser.get_records(1)
self.assertEqual(result, [])
self.assertEqual(self.parser._state[StateKey.POSITION], 215)
self.assertEqual(self.state_callback_value[StateKey.POSITION], 215)
self.assert_(isinstance(self.publish_callback_value, list))
self.assertEqual(self.publish_callback_value[0], self.particle_e_accel)
self.assertEqual(self.exception_callback_value, None)
def test_simple_rate(self):
"""
Read test data and pull out data particles one at a time.
Assert that the results are those we expected.
"""
self.stream_handle = open(os.path.join(RESOURCE_PATH,
'first_rate.mopak.log'))
self.parser = MopakODclParser(self.config, self.start_state, self.stream_handle,
'20140313_191853.mopak.log',
self.state_callback, self.pub_callback,
self.except_callback)
# next get accel and rate records
result = self.parser.get_records(1)