Пример #1
0
 def test_ghg_len_yearly(self):
     idx = pd.date_range('20000101', '20550101', freq='d')
     s = pd.Series(np.ones(len(idx)), index=idx)
     ml = Model(s)
     ml.freq = 'D'
     v = ml.stats.ghg(key='observations', output='yearly')
     assert len(v) == 55
Пример #2
0
 def test_glg(self):
     idx = pd.date_range('20000101', '20550101', freq='d')
     s = pd.Series([x.month + x.day for x in idx], index=idx)
     ml = Model(s)
     ml.freq = 'D'
     v = ml.stats.glg(key='observations')
     assert v == 16.
Пример #3
0
 def test_ghg(self):
     idx = pd.to_datetime(['20160114', '20160115', '20160128', '20160214'])
     s = pd.Series([10., 3., 30., 20], index=idx)
     ml = Model(s)
     ml.freq = 'D'
     v = ml.stats.ghg(key='observations')
     assert v == 20.
Пример #4
0
 def test_ghg_linear(self):
     idx = pd.to_datetime(['20160113', '20160115'])
     s = pd.Series([0., 10.], index=idx)
     ml = Model(s)
     ml.freq = 'D'
     v = ml.stats.ghg(key='observations', fill_method='linear')
     assert v == 5.
Пример #5
0
 def test_q_gvg_nan(self):
     idx = pd.to_datetime(['20160820', '20160901', '20161120'])
     s = pd.Series([0, 5, 10], index=idx)
     ml = Model(s)
     ml.freq = 'D'
     v = ml.stats.q_gvg(key='observations')
     assert np.isnan(v)
Пример #6
0
 def test_q_gvg(self):
     idx = pd.to_datetime(['20160320', '20160401', '20160420'])
     s = pd.Series([0, 5, 10], index=idx)
     ml = Model(s)
     ml.freq = 'D'
     v = ml.stats.q_gvg(key='observations')
     assert v == 2.5
Пример #7
0
 def test_q_gxg_nan(self):
     idx = pd.date_range('20160101', freq='d', periods=3)
     s = pd.Series([1, 3, np.nan], index=idx)
     ml = Model(s)
     ml.freq = 'D'
     v = ml.stats.q_ghg(key='observations', q=.5)
     assert v == 2.
Пример #8
0
 def test_q_glg(self):
     n = 101
     idx = pd.date_range('20160101', freq='d', periods=n)
     s = pd.Series(np.arange(n), index=idx)
     ml = Model(s)
     ml.freq = 'D'
     v = ml.stats.q_glg(key='observations', q=.06)
     assert v == 6.
Пример #9
0
 def test_gvg(self):
     idx = pd.to_datetime(['20170314', '20170328', '20170414', '20170428'])
     s = pd.Series([1., 2., 3., 4], index=idx)
     ml = Model(s)
     ml.freq = 'D'
     v = ml.stats.gvg(key='observations',
                      fill_method='linear',
                      output='mean')
     assert v == 2.
Пример #10
0
 def test_glg_fill_limit_null(self):
     idx = pd.to_datetime(['20170101', '20170131', '20200101'])
     s = pd.Series(np.ones(len(idx)), index=idx)
     ml = Model(s)
     ml.freq = 'D'
     v = ml.stats.glg(key='observations',
                      fill_method='linear',
                      limit=10,
                      output='yearly')
     assert v.count() == 0
Пример #11
0
 def test_gvg_nan(self):
     idx = pd.to_datetime(['20170228', '20170428', '20170429'])
     s = pd.Series([1., 2., 3.], index=idx)
     ml = Model(s)
     ml.freq = 'D'
     v = ml.stats.gvg(
         key='observations',
         fill_method=None,
         output='mean',
     )
     assert np.isnan(v)
Пример #12
0
 def test_q_gxg_series(self):
     s = pd.read_csv('tests/data/hseries_gxg.csv', index_col=0, header=0,
         parse_dates=True, dayfirst=True,
         squeeze=True,)
     ml = Model(s)
     ml.freq = 'D'
     ghg = ml.stats.q_ghg(key='observations')
     glg = ml.stats.q_glg(key='observations')
     gvg = ml.stats.q_gvg(key='observations')
     print('\n')
     print('calculated GXG\'s percentile method: \n')
     print(('GHG: {ghg:.2f} m+NAP\n'
            'GLG: {glg:.2f} m+NAP\n'
            'GVG: {gvg:.2f} m+NAP\n').format(
            ghg=ghg, glg=glg, gvg=gvg))
     print('Menyanthes GXG\'s: \n')
     print(('GHG: {ghg:.2f} m+NAP\n'
            'GLG: {glg:.2f} m+NAP\n'
            'GVG: {gvg:.2f} m+NAP\n').format(
            ghg=-3.23, glg=-3.82, gvg=-3.43))