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


Python timeseries.TimeSeries类代码示例

本文整理汇总了Python中timeseries.TimeSeries的典型用法代码示例。如果您正苦于以下问题:Python TimeSeries类的具体用法?Python TimeSeries怎么用?Python TimeSeries使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_simple_moving_average

 def test_simple_moving_average(self):
     points = [1, 2, 3, 4, 5, 6]
     series = TimeSeries(zip(points, points))
     ma = series.moving_average(3).round()
     self.assertListEqual(ma.points, [ (3, 2), (4, 3), (5, 4), (6, 5) ])
     ma = series.moving_average(5).round()
     self.assertListEqual(ma.points, [ (5, 3), (6, 4) ])
开发者ID:Leoyzen,项目名称:timeseries,代码行数:7,代码来源:test_time_series.py

示例2: test_itertimes

 def test_itertimes(self):
     x = TimeSeries([1, 2, 3, 4],[1, 4, 9, 16])
     i = x.itertimes()
     nextt = next(i)
     self.assertTrue ( nextt == 1 )
     nextt = next(i)
     self.assertTrue ( nextt == 2 )
     self.assertTrue (nextt.dtype == np.int64)
开发者ID:Four-Continents,项目名称:cs207project,代码行数:8,代码来源:test_timeseries.py

示例3: test024

 def test024(self):
     'TimeSeries.write_to_pi_file writes dict to stream with 12 offset'
     stream = mock.Stream()
     obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.2.xml")
     TimeSeries.write_to_pi_file(stream, obj, offset=12)
     target = file(self.testdata + "targetOutput12.xml").read()
     current = ''.join(stream.content)
     self.assertEquals(target.strip(), current.strip())
开发者ID:nens,项目名称:timeseries,代码行数:8,代码来源:timeseries_tests.py

示例4: test_iteritems

 def test_iteritems(self):
     x = TimeSeries([1, 2, 3, 4],[1, 4, 9, 16])
     i = x.iteritems()
     nextt = next(i)
     self.assertTrue ( nextt == (1, 1) )
     nextt = next(i)
     self.assertTrue ( nextt == (2, 4) )
     self.assertTrue (len(nextt) ==2 )
开发者ID:Four-Continents,项目名称:cs207project,代码行数:8,代码来源:test_timeseries.py

示例5: test_111

    def test_111(self):
        'get_event is defined and equal to __getitem__'

        obj = TimeSeries(location_id='loc', parameter_id='par')
        d1 = datetime(1979, 3, 15, 9, 35)
        ## setting
        obj[d1] = 1.23
        ## checking
        self.assertEquals(obj._events[d1], obj.get_event(d1))
开发者ID:nens,项目名称:timeseries,代码行数:9,代码来源:timeseries_tests.py

示例6: test_024

    def test_024(self):
        'getting events of a eventless time series'

        obj = TimeSeries(location_id='loc', parameter_id='par')
        d1 = datetime(1979, 3, 15, 9, 35)
        d3 = datetime(1979, 4, 12, 9, 35)
        self.assertEqual(0, len(obj.get_events()))
        self.assertEqual(0, len(obj.get_events(d3)))
        self.assertEqual(0, len(obj.get_events(d1, d3)))
开发者ID:nens,项目名称:timeseries,代码行数:9,代码来源:timeseries_tests.py

示例7: test_112

    def test_112(self):
        'get_value is defined returns only value, no flags'

        obj = TimeSeries(location_id='loc', parameter_id='par')
        d1 = datetime(1979, 3, 15, 9, 35)
        ## setting
        obj[d1] = 1.23
        ## checking
        self.assertEquals(obj._events[d1][0], obj.get_value(d1))
开发者ID:nens,项目名称:timeseries,代码行数:9,代码来源:timeseries_tests.py

示例8: test000

 def test000(self):
     'TimeSeries.write_to_pi_file writes list to new file'
     obj = TimeSeries.as_list(self.testdata + "read.PI.timezone.2.xml")
     TimeSeries.write_to_pi_file(self.testdata + "current.xml",
                                 obj,
                                 offset=2)
     target = file(self.testdata + "targetOutput.xml").read()
     current = file(self.testdata + "current.xml").read()
     self.assertEquals(target.strip(), current.strip())
开发者ID:nens,项目名称:timeseries,代码行数:9,代码来源:timeseries_tests.py

示例9: test030

 def test030(self):
     'TimeSeries.write_to_pi_file appends children to stream'
     stream = mock.Stream()
     obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.2.xml")
     TimeSeries.write_to_pi_file(stream, obj, offset=0, append=True)
     target_lines = file(self.testdata + "targetOutput00.xml").readlines()[3:-1]
     target = ''.join(i.strip() for i in target_lines)
     current = ''.join(i.strip() for i in ''.join(stream.content).split('\n'))
     self.assertEquals(target, current)
开发者ID:nens,项目名称:timeseries,代码行数:9,代码来源:timeseries_tests.py

示例10: test_110

    def test_110(self):
        'add_value is defined and equal to __setitem__'

        obj = TimeSeries(location_id='loc', parameter_id='par')
        d1 = datetime(1979, 3, 15, 9, 35)
        ## setting
        obj.add_value(d1, 1.23)
        ## checking
        self.assertEquals(obj._events[d1], obj[d1])
开发者ID:nens,项目名称:timeseries,代码行数:9,代码来源:timeseries_tests.py

示例11: test_periodic_decomposition

 def test_periodic_decomposition(self):
     series = TimeSeries([ (1, 100), (2, 200), (3, 100), (4, 200), (5, 100) ])
     decomposed = series.decompose(2, periodic=True).round()
     self.assertTrue(isinstance(decomposed, DataFrame))
     self.assertEquals(len(decomposed), 3)
     for series in decomposed.itervalues():
         self.assertListEqual(series.timestamps, [1, 2, 3, 4, 5])
     self.assertListEqual(decomposed['trend'].values, [150] * 5)
     self.assertListEqual(decomposed['seasonal'].values, [-50, 50, -50, 50, -50])
     self.assertListEqual(decomposed['residual'].values, [0] * 5)
开发者ID:Leoyzen,项目名称:timeseries,代码行数:10,代码来源:test_time_series.py

示例12: test_022

    def test_022(self):
        'start and end of a time series with events'

        obj = TimeSeries(location_id='loc', parameter_id='par')
        d1 = datetime(1979, 3, 15, 9, 35)
        d3 = datetime(1979, 4, 12, 9, 35)
        d2 = datetime(1979, 5, 15, 9, 35)
        obj[d1] = 1.23
        obj[d3] = 0.23
        obj[d2] = -3.01
        self.assertEqual(d1, obj.get_start_date())
        self.assertEqual(d2, obj.get_end_date())
开发者ID:nens,项目名称:timeseries,代码行数:12,代码来源:timeseries_tests.py

示例13: test_115

    def test_115(self):
        'can use .get with default value'

        obj = TimeSeries(location_id='loc', parameter_id='par')
        d1 = datetime(1979, 3, 15, 9, 35)
        obj.add_value(d1, 1.23)  # executing __setitem__
        ## finds values that are there
        [self.assertEquals(obj._events[d], obj.get(d))
         for d in obj._events.keys()]
        d2 = datetime(1979, 5, 15, 9, 35)
        ## returns default value if event is not there
        self.assertEquals(None, obj.get(d2))
开发者ID:nens,项目名称:timeseries,代码行数:12,代码来源:timeseries_tests.py

示例14: test_200

    def test_200(self):
        'represent empty TimeSeries as Element'

        obj = TimeSeries(location_id='loc', parameter_id='par')
        
        current = obj._as_element()
        self.assertTrue(isinstance(current, ElementTree.Element))
        self.assertEquals('series', current.tag)
        childElements = [i for i in current.getchildren()]
        self.assertEquals(1, len(childElements))
        self.assertEquals(['header'], [i.tag for i in childElements])
        self.assertEquals({}, current.attrib)
开发者ID:nens,项目名称:timeseries,代码行数:12,代码来源:timeseries_tests.py

示例15: test_023

    def test_023(self):
        'getting events of a non empty time series'

        obj = TimeSeries(location_id='loc', parameter_id='par')
        d1 = datetime(1979, 3, 15, 9, 35)
        d3 = datetime(1979, 4, 12, 9, 35)
        d2 = datetime(1979, 5, 15, 9, 35)
        obj[d1] = 1.23
        obj[d3] = 0.23
        obj[d2] = -3.01
        self.assertEqual(3, len(obj.get_events()))
        self.assertEqual(2, len(obj.get_events(d3)))
        self.assertEqual(2, len(obj.get_events(d1, d3)))
开发者ID:nens,项目名称:timeseries,代码行数:13,代码来源:timeseries_tests.py


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