• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python timeseries.TimeSeries类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_201

    def test_201(self):
        'represent TimeSeries with two events as Element'

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


示例17: test010

 def test010(self):
     '''result of TimeSeries.as_dict is indexed on locationId
     parameterId 2-tuples'''
     obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.2.xml")
     self.assertEquals(set([("600", "P1201"), ("600", "P2504")]),
                       set(obj.keys()))
     self.assertTrue(isinstance(obj[("600", "P1201")], TimeSeries))
     self.assertTrue(isinstance(obj[("600", "P2504")], TimeSeries))
开发者ID:nens,项目名称:timeseries,代码行数:8,代码来源:timeseries_tests.py


示例18: test111

 def test111(self):
     'TimeSeries.as_dict reads events of series (b)'
     obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.2.xml")
     ts = obj[("600", "P2504")]
     self.assertEquals([
             (str_to_datetime("2010-04-05", "00:00:00", 2), 17),
             (str_to_datetime("2010-04-08", "00:00:00", 2), 22),
             (str_to_datetime("2010-04-10", "00:00:00", 2), 24), ],
                       ts.get_values())
开发者ID:nens,项目名称:timeseries,代码行数:9,代码来源:timeseries_tests.py


示例19: test113

 def test113(self):
     'TimeSeries.get_values with only requested timeseries'
     obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.2.xml")
     ts = obj[("600", "P2504")]
     dates = [str_to_datetime("2010-04-05", "00:00:00", 2),
              str_to_datetime("2010-04-10", "00:00:00", 2)]
     self.assertEquals([
             (str_to_datetime("2010-04-05", "00:00:00", 2), (17, 0, '')),
             (str_to_datetime("2010-04-10", "00:00:00", 2), (24, 0, '')), ],
                       ts.get_events(dates=dates))
开发者ID:nens,项目名称:timeseries,代码行数:10,代码来源:timeseries_tests.py


示例20: test_042

    def test_042(self):
        'using deprecated events function'

        root = logging.getLogger()
        handler = mock.Handler()
        root.addHandler(handler)
        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(62, len(list(obj.events())))
        self.assertEqual(34, len(list(obj.events(d3))))
        self.assertEqual(29, len(list(obj.events(d1, d3))))
        self.assertEqual(3, len(handler.content))
        self.assertEqual("timeseries.timeseries|WARNING|Call to deprecated function events.",
                         handler.content[0])
        root.removeHandler(handler)
开发者ID:nens,项目名称:timeseries,代码行数:20,代码来源:timeseries_tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python db_session.add函数代码示例发布时间:2022-05-27
下一篇:
Python times.to_universal函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap