1111#include < core/CRapidXmlParser.h>
1212#include < core/CRapidXmlStatePersistInserter.h>
1313#include < core/CRapidXmlStateRestoreTraverser.h>
14+ #include < core/Constants.h>
1415
1516#include < maths/CSeasonalComponentAdaptiveBucketing.h>
1617#include < maths/CSeasonalTime.h>
@@ -36,14 +37,14 @@ using TMaxAccumulator = maths::CBasicStatistics::SMax<double>::TAccumulator;
3637}
3738
3839void CSeasonalComponentAdaptiveBucketingTest::testInitialize () {
39- maths::CDiurnalTime time (0 , 1 , 101 , 100 );
40+ maths::CGeneralPeriodTime time (100 );
4041 maths::CSeasonalComponentAdaptiveBucketing bucketing (time);
4142
4243 CPPUNIT_ASSERT (!bucketing.initialize (0 ));
4344
4445 const std::string expectedEndpoints (" [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]" );
45- const std::string expectedKnots (" [0, 4, 14, 24, 34, 44, 54, 64, 74, 84, 94 , 100]" );
46- const std::string expectedValues (" [41 , 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 41 ]" );
46+ const std::string expectedKnots (" [0, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95 , 100]" );
47+ const std::string expectedValues (" [50 , 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 50 ]" );
4748
4849 CPPUNIT_ASSERT (bucketing.initialize (10 ));
4950 const TFloatVec& endpoints = bucketing.endpoints ();
@@ -62,7 +63,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testInitialize() {
6263}
6364
6465void CSeasonalComponentAdaptiveBucketingTest::testSwap () {
65- maths::CDiurnalTime time1 (0 , 0 , 100 , 100 );
66+ maths::CGeneralPeriodTime time1 (100 );
6667 maths::CSeasonalComponentAdaptiveBucketing bucketing1 (time1, 0.05 );
6768
6869 test::CRandomNumbers rng;
@@ -82,7 +83,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testSwap() {
8283 bucketing1.propagateForwardsByTime (1.0 );
8384 }
8485
85- maths::CDiurnalTime time2 (10 , 10 , 120 , 110 );
86+ maths::CGeneralPeriodTime time2 (120 );
8687 maths::CSeasonalComponentAdaptiveBucketing bucketing2 (time2, 0.1 );
8788
8889 uint64_t checksum1 = bucketing1.checksum ();
@@ -109,7 +110,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testRefine() {
109110 double function[] = {10 , 10 , 10 , 10 , 100 , 90 , 80 ,
110111 90 , 100 , 20 , 10 , 10 , 10 , 10 };
111112
112- maths::CDiurnalTime time (0 , 0 , 86400 , 86400 );
113+ maths::CDiurnalTime time (0 , 0 , core::constants::WEEK, core::constants::DAY );
113114 maths::CSeasonalComponentAdaptiveBucketing bucketing1 (time);
114115 maths::CSeasonalComponentAdaptiveBucketing bucketing2 (time);
115116
@@ -188,7 +189,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testRefine() {
188189 // Test that the variance in each bucket is approximately equal.
189190 // The test function is y = (x - 50)^2 / 50.
190191
191- maths::CDiurnalTime time (0 , 0 , 100 , 100 );
192+ maths::CGeneralPeriodTime time (100 );
192193 maths::CSeasonalComponentAdaptiveBucketing bucketing (time, 0.05 );
193194
194195 bucketing.initialize (10 );
@@ -294,7 +295,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testPropagateForwardsByTime() {
294295 // the bucket values and that the rate at which the total
295296 // count is reduced uniformly.
296297
297- maths::CDiurnalTime time (0 , 0 , 100 , 100 );
298+ maths::CGeneralPeriodTime time (100 );
298299 maths::CSeasonalComponentAdaptiveBucketing bucketing (time, 0.2 );
299300
300301 bucketing.initialize (10 );
@@ -331,7 +332,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testMinimumBucketLength() {
331332
332333 core_t ::TTime period = static_cast <core_t ::TTime>(n) *
333334 static_cast <core_t ::TTime>(bucketLength);
334- maths::CDiurnalTime time (0 , 0 , period, period);
335+ maths::CGeneralPeriodTime time (period);
335336 maths::CSeasonalComponentAdaptiveBucketing bucketing1 (time, 0.0 , 0.0 );
336337 maths::CSeasonalComponentAdaptiveBucketing bucketing2 (time, 0.0 , 3000.0 );
337338 bucketing1.initialize (n);
@@ -389,7 +390,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testUnintialized() {
389390 // Check that all the functions work and return the expected
390391 // values on an uninitialized bucketing.
391392
392- maths::CDiurnalTime time (0 , 0 , 10 , 10 );
393+ maths::CGeneralPeriodTime time (10 );
393394 maths::CSeasonalComponentAdaptiveBucketing bucketing (time, 0.1 );
394395
395396 bucketing.add (0 , 1.0 , 1.0 );
@@ -436,7 +437,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testKnots() {
436437
437438 LOG_DEBUG (<< " *** Values ***" );
438439 {
439- maths::CDiurnalTime time (0 , 0 , 86400 , 86400 );
440+ maths::CDiurnalTime time (0 , 0 , core::constants::WEEK, core::constants::DAY );
440441 maths::CSeasonalComponentAdaptiveBucketing bucketing (time, 0.1 , 864.0 );
441442
442443 bucketing.initialize (20 );
@@ -479,7 +480,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testKnots() {
479480 }
480481 LOG_DEBUG (<< " *** Variances ***" );
481482 {
482- maths::CDiurnalTime time (0 , 0 , 86400 , 86400 );
483+ maths::CDiurnalTime time (0 , 0 , core::constants::WEEK, core::constants::DAY );
483484 maths::CSeasonalComponentAdaptiveBucketing bucketing (time, 0.1 , 864.0 );
484485
485486 bucketing.initialize (20 );
@@ -530,7 +531,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testLongTermTrendKnots() {
530531
531532 test::CRandomNumbers rng;
532533
533- maths::CDiurnalTime time (0 , 0 , 86400 , 86400 );
534+ maths::CDiurnalTime time (0 , 0 , core::constants::WEEK, core::constants::DAY );
534535 maths::CSeasonalComponentAdaptiveBucketing bucketing (time, 0.1 , 864.0 );
535536 maths::CSeasonalComponentAdaptiveBucketing::TFloatMeanAccumulatorVec empty;
536537
@@ -588,7 +589,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testShiftValue() {
588589 // Test that applying a shift translates the predicted values
589590 // but doesn't alter the slope or predicted variances.
590591
591- maths::CDiurnalTime time (0 , 0 , 86400 , 86400 );
592+ maths::CDiurnalTime time (0 , 0 , core::constants::WEEK, core::constants::DAY );
592593 maths::CSeasonalComponentAdaptiveBucketing bucketing (time, 0.1 , 600.0 );
593594 maths::CSeasonalComponentAdaptiveBucketing::TFloatMeanAccumulatorVec empty;
594595
@@ -632,7 +633,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testShiftValue() {
632633void CSeasonalComponentAdaptiveBucketingTest::testSlope () {
633634 // Test that the slope increases by the shift.
634635
635- maths::CDiurnalTime time (0 , 0 , 86400 , 86400 );
636+ maths::CDiurnalTime time (0 , 0 , core::constants::WEEK, core::constants::DAY );
636637 maths::CSeasonalComponentAdaptiveBucketing bucketing (time, 0.1 , 600.0 );
637638 maths::CSeasonalComponentAdaptiveBucketing::TFloatMeanAccumulatorVec empty;
638639
@@ -669,7 +670,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testPersist() {
669670 double decayRate = 0.1 ;
670671 double minimumBucketLength = 1.0 ;
671672
672- maths::CDiurnalTime time (0 , 0 , 86400 , 86400 );
673+ maths::CDiurnalTime time (0 , 0 , core::constants::WEEK, core::constants::DAY );
673674 maths::CSeasonalComponentAdaptiveBucketing origBucketing (time, decayRate, minimumBucketLength);
674675
675676 origBucketing.initialize (10 );
@@ -723,7 +724,7 @@ void CSeasonalComponentAdaptiveBucketingTest::testUpgrade() {
723724 double decayRate = 0.1 ;
724725 double minimumBucketLength = 1.0 ;
725726
726- maths::CDiurnalTime time (0 , 0 , 86400 , 86400 );
727+ maths::CDiurnalTime time (0 , 0 , core::constants::WEEK, core::constants::DAY );
727728 maths::CSeasonalComponentAdaptiveBucketing expectedBucketing (time, decayRate, minimumBucketLength);
728729
729730 expectedBucketing.initialize (10 );
0 commit comments