当前位置: 首页>>代码示例>>Python>>正文


Python TimeSeries.generate_meta方法代码示例

本文整理汇总了Python中pySPACE.resources.data_types.time_series.TimeSeries.generate_meta方法的典型用法代码示例。如果您正苦于以下问题:Python TimeSeries.generate_meta方法的具体用法?Python TimeSeries.generate_meta怎么用?Python TimeSeries.generate_meta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pySPACE.resources.data_types.time_series.TimeSeries的用法示例。


在下文中一共展示了TimeSeries.generate_meta方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: next

# 需要导入模块: from pySPACE.resources.data_types.time_series import TimeSeries [as 别名]
# 或者: from pySPACE.resources.data_types.time_series.TimeSeries import generate_meta [as 别名]
    def next(self, debug=False):
        """Return next labeled window when used in iterator context."""
        while len(self.cur_extract_windows) == 0:
            # fetch the next block from data_client
            if debug:
                print "reading next block"
            self._readnextblock()
            self._extract_windows_cur_block()
            if debug:
                print "  buffermarkers", self.buffermarkers
                print "  current block", self.samplebuf.get()[self.prebuflen][1, :]
                # print "  current extracted windows ", self.cur_extract_windows

        (windef_name, current_window, class_, start_time, end_time, markers_cur_win) = self.cur_extract_windows.pop(0)

        # TODO: Replace this by a decorator or something similar
        current_window = numpy.atleast_2d(current_window.transpose())
        current_window = TimeSeries(
            input_array=current_window,
            channel_names=self.data_client.channelNames,
            sampling_frequency=self.data_client.dSamplingInterval,
            start_time=start_time,
            end_time=end_time,
            name="Window extracted @ %d ms, length %d ms, class %s" % (start_time, end_time - start_time, class_),
            marker_name=markers_cur_win,
        )

        current_window.generate_meta()
        current_window.specs["sampling_frequency"] = self.data_client.dSamplingInterval
        current_window.specs["wdef_name"] = windef_name
        self.nwindow += 1

        # return (ndsamplewin, ndmarkerwin)
        return (current_window, class_)
开发者ID:Crespo911,项目名称:pyspace,代码行数:36,代码来源:windower.py

示例2: BaseDataTestCase

# 需要导入模块: from pySPACE.resources.data_types.time_series import TimeSeries [as 别名]
# 或者: from pySPACE.resources.data_types.time_series.TimeSeries import generate_meta [as 别名]
class BaseDataTestCase(unittest.TestCase):
    """Test BaseData data type"""
    def setUp(self):
        """Create some example data """
        # Create some TimeSeries:
        self.x1 = TimeSeries([1,2,3,4,5,6], ['a','b','c','d','e','f'], 12,
                        marker_name='S4', name='Name_text ending with Standard',
                        start_time=1000.0, end_time=1004.0)
        
        self.x1.specs={'Nice_Parameter': 1, 'Less_Nice_Param': '2'}
        self.x1.generate_meta() #automatically generate key and tag
                        
        self.x2 = TimeSeries([1,2,3,4,5,6], ['a','b','c','d','e','f'], 12,
                        marker_name='S4', start_time=2000.0, end_time=2004.0, 
                        name='Name_text ending with Standard')
        
        #manually generate key and tag
        import uuid
        self.x2_key=uuid.uuid4()
        self.x2.key=self.x2_key
        self.x2.tag='Tag of x2'
        self.x2.specs={'Nice_Parameter': 1, 'Less_Nice_Param': '2'}
                         
        self.x3 = TimeSeries([1,2,3,4,5,6], ['a','b','c','d','e','f'], 12,
                        marker_name='S4', start_time=3000.0, end_time=3004.0)
        
        self.x3.specs={'Nice_Parameter': 1, 'Less_Nice_Param': '2'}
        self.x3.generate_meta()
        
        self.x4 = TimeSeries([1,2,3,4,5,6], ['a','b','c','d','e','f'], 12,marker_name='S4')
        
        self.x4.specs={'Nice_Parameter': 1, 'Less_Nice_Param': '2'}
        
        self.x5 = TimeSeries([1,2], ['a','b'], 12)
        self.x5.inherit_meta_from(self.x2)
        
        self.x6 = TimeSeries([1,2,3,4,5,6], ['a','b','c','d','e','f'], 12)
        
        self.x6.specs={'Nice_Parameter': 11, 'Less_Nice_Param': '21'}
        self.x6.generate_meta()
        #safe information
        self.x6_key=self.x6.key
        
        self.x6.inherit_meta_from(self.x2)
        
        self.some_nice_dict = {'guido': 4127, 'irv': 4127, 'jack': 4098}
        
        self.x6.add_to_history(self.x5, self.some_nice_dict)
        
        # Create some FeatureVectors:
        self.f1 = FeatureVector([1,2,3,4,5,6],['a','b','c','d','e','f'])
        
        self.f1.specs={'NiceParam':1,'LessNiceParam':2}
        
        self.f2 = FeatureVector([1,2,3,4,5,6],['a','b','c','d','e','f'], tag = 'Tag of f2')
        
        self.f2.specs={'NiceParam':1,'LessNiceParam':2}
        
        self.f3 = FeatureVector([1,2], ['a','b'])
        self.f3.inherit_meta_from(self.x2)
        self.f3.add_to_history(self.x5)
        
    def testTag(self):
        """Test tag behavior"""
        # Generate from Meta Data
        self.assertEqual(self.x1.tag,
            'Epoch Start: 1000ms; End: 1004ms; Class: Standard')
        # Tag passed, use that!
        self.assertEqual(self.x2.tag, 'Tag of x2')
        self.assertEqual(self.f2.tag, 'Tag of f2')            
        # No tag and only partial meta passed
        self.assertEqual(self.x3.tag,
            'Epoch Start: 3000ms; End: 3004ms; Class: na')
        # No Tag and no meta passed, Tag remains None
        self.assertEqual(self.x4.tag, None)
        self.assertEqual(self.f1.tag, None)
        
    
    def testKey(self):
        """Test key behavior"""
        import uuid
        self.assertEqual(type(self.x1.key),uuid.UUID)
        # If Key passed, use that!
        self.assertEqual(self.x2.key, self.x2_key)
        
    
    def testInheritAndAddStuff(self):
        """test inheritance of meta data from other objects"""
        # Inherit
        self.assertEqual(self.x5.tag, self.x2.tag)
        self.assertEqual(self.x5.key, self.x2.key)
        
        self.assertEqual(self.f3.tag, self.x2.tag)
        self.assertEqual(self.f3.key, self.x2.key)
        
        #Inherit
        
        #suppress warning of BaseData type and cast data back to numpy
        hist_x6=self.x6.history[0].view(numpy.ndarray)
        data_x5=self.x5.view(numpy.ndarray)
#.........这里部分代码省略.........
开发者ID:AlexanderFabisch,项目名称:pyspace,代码行数:103,代码来源:test_base.py


注:本文中的pySPACE.resources.data_types.time_series.TimeSeries.generate_meta方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。