Skip to content

Commit

Permalink
WIP step 6
Browse files Browse the repository at this point in the history
Validation sur LearningTest\TestKhiops\Rules\DateTimeRules
  • Loading branch information
marcboulle committed Nov 27, 2023
1 parent 58785f8 commit a0e1d7a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
46 changes: 22 additions & 24 deletions src/Learning/KWData/KWTimestamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,18 @@ void Timestamp::UnitTest(int nYear, int nMonth, int nDay, int nHour, int nMinute
{
Timestamp tsValue;
Timestamp tsCopy;
DoubleVector dvSeconds;
int i;

// Liste des increments en secondes a prendre en compte
dvSeconds.Add(0);
dvSeconds.Add(0.1);
dvSeconds.Add(1);
dvSeconds.Add(60);
dvSeconds.Add(3600);
dvSeconds.Add(86400);

// Tests complets
tsValue.Init(nYear, nMonth, nDay, nHour, nMinute, dSecond);
tsCopy = tsValue;
cout << "(" << nYear << ", " << nMonth << ", " << nDay << ", " << nHour << ", " << nMinute << ", " << dSecond
Expand All @@ -158,30 +169,16 @@ void Timestamp::UnitTest(int nYear, int nMonth, int nDay, int nHour, int nMinute
if (tsValue.Check())
{
cout << tsValue.GetAbsoluteSecond() << "\t";
tsCopy = tsValue;
tsCopy.AddSeconds(0);
cout << tsCopy << " ,\t" << flush;
cout << tsValue.Diff(tsCopy) << "\t";
tsCopy = tsValue;
tsCopy.AddSeconds(0.1);
cout << tsCopy << " ,\t";
cout << tsValue.Diff(tsCopy) << "\t";
tsCopy = tsValue;
tsCopy.AddSeconds(1);
cout << tsCopy << " ,\t";
cout << tsValue.Diff(tsCopy) << "\t";
tsCopy = tsValue;
tsCopy.AddSeconds(60);
cout << tsCopy << " ,\t";
cout << tsValue.Diff(tsCopy) << "\t";
tsCopy = tsValue;
tsCopy.AddSeconds(3600);
cout << tsCopy << " ,\t";
cout << tsValue.Diff(tsCopy) << "\t";
tsCopy = tsValue;
tsCopy.AddSeconds(86400);
cout << tsCopy << " ,\t";
cout << tsValue.Diff(tsCopy) << "\t";

// Prise en compte de tous les increments en secondes
for (i = 0; i < dvSeconds.GetSize(); i++)
{
tsCopy = tsValue;
tsCopy.AddSeconds(dvSeconds.GetAt(i));
cout << tsCopy << " ,\t" << flush;
cout << tsValue.Diff(tsCopy) << "\t";
assert(fabs(tsValue.Diff(tsCopy) + dvSeconds.GetAt(i)) < 1e-3);
}
}
cout << endl;
}
Expand Down Expand Up @@ -228,6 +225,7 @@ void Timestamp::Test()
tsTimestamp = tsOrigin;
tsTimestamp.AddSeconds(86400.0 * (i - nOriginAbsoluteDay));
assert(tsTimestamp.GetDate().GetAbsoluteDay() == i);
assert(tsTimestamp.Diff(tsOrigin) == 86400.0 * (i - nOriginAbsoluteDay));
if (tsTimestamp.GetDate().GetYear() != tsPreviousTimestamp.GetDate().GetYear())
nTotalYearNumber++;
if (tsTimestamp.GetDate().GetMonth() != tsPreviousTimestamp.GetDate().GetMonth())
Expand Down
6 changes: 5 additions & 1 deletion src/Learning/KWData/KWTimestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,17 @@ inline int Timestamp::Compare(const Timestamp tsOtherTimestamp) const

inline void Timestamp::SetForbiddenValue()
{
timestampValue.lBytes = DateTime::lForbiddenValue;
/*DDD
GetInternalDate().SetForbiddenValue();
GetInternalTime().SetForbiddenValue();
*/
}

inline boolean Timestamp::IsForbiddenValue() const
{
return GetDate().IsForbiddenValue() or GetTime().IsForbiddenValue();
return (timestampValue.lBytes == DateTime::lForbiddenValue);
//DDD return GetDate().IsForbiddenValue() or GetTime().IsForbiddenValue();
}

inline Date& Timestamp::GetInternalDate() const
Expand Down
5 changes: 3 additions & 2 deletions src/Learning/MODL/MODL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ int main(int argc, char** argv)

//DDD
//DDD DateTime::Test();
/*DDD
cout << "TEST Time\n";
Time::Test();
cout << "TEST Date\n";
Expand All @@ -42,9 +43,8 @@ int main(int argc, char** argv)
Timestamp::Test();
cout << "TEST TimestampTZ\n";
TimestampTZ::Test();
/*DDD
*/
return 0;
*/

// Activation de la gestion des signaux via des erreurs, pour afficher des messages d'erreur explicites
// A potentiellement commenter sur certains IDE lors des phases de debuggage
Expand All @@ -53,6 +53,7 @@ int main(int argc, char** argv)
// Choix du repertoire de lancement pour le debugage sous Windows (a commenter apres fin du debug)
// SetWindowsDebugDir("Standard", "IrisLight");
// SetWindowsDebugDir("Standard", "Iris2D");
SetWindowsDebugDir("Rules", "DateTimeRules");

// Parametrage des logs memoires depuis les variables d'environnement, pris en compte dans KWLearningProject
// KhiopsMemStatsLogFileName, KhiopsMemStatsLogFrequency, KhiopsMemStatsLogToCollect
Expand Down

0 comments on commit a0e1d7a

Please sign in to comment.