-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move data validation to specialized functions [ANT-1213] #2149
Changes from 3 commits
6c2b437
76fe488
f2b01b3
6df0fd9
660372c
c0b5a8c
5eebab1
70b3924
e6f4537
4c42528
888fe91
7f69b21
b01868a
7233379
2fccc96
83131db
8806510
67e74fe
3c75a26
f9a4f2e
4446cfe
226e481
988fd79
b142bd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,24 @@ HydroMaxTimeSeriesReader::HydroMaxTimeSeriesReader(PartHydro& hydro, | |
dailyMaxPumpAndGen.reset(4U, DAYS_PER_YEAR, true); | ||
} | ||
|
||
static bool checkPower(const Matrix<>& dailyMaxPumpAndGen, const std::string& areaName) | ||
{ | ||
for (uint i = 0; i < 4U; ++i) | ||
{ | ||
auto& col = dailyMaxPumpAndGen[i]; | ||
for (uint day = 0; day < DAYS_PER_YEAR; ++day) | ||
{ | ||
if (col[day] < 0. || (i % 2U /*column hours*/ && col[day] > 24.)) | ||
{ | ||
logs.error() << areaName << ": invalid power or energy value"; | ||
return false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Carefull There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (!errorPower avoided going into this scope after the first error, I simplified while keeping the same behavior There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No you don't keep the same behavior. The user will only see the 1st error, not the following ones if any. |
||
} | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool HydroMaxTimeSeriesReader::loadDailyMaxPowersAndEnergies(const AnyString& folder, | ||
bool usedBySolver) | ||
{ | ||
|
@@ -90,21 +108,8 @@ bool HydroMaxTimeSeriesReader::loadDailyMaxPowersAndEnergies(const AnyString& fo | |
Matrix<>::optFixedSize, | ||
&fileContent) | ||
&& ret; | ||
ret = checkPower(dailyMaxPumpAndGen, areaName_) && ret; | ||
|
||
bool errorPowers = false; | ||
for (uint i = 0; i < 4U; ++i) | ||
{ | ||
auto& col = dailyMaxPumpAndGen[i]; | ||
for (uint day = 0; day < DAYS_PER_YEAR; ++day) | ||
{ | ||
if (!errorPowers && (col[day] < 0. || (i % 2U /*column hours*/ && col[day] > 24.))) | ||
{ | ||
logs.error() << areaName_ << ": invalid power or energy value"; | ||
errorPowers = true; | ||
ret = false; | ||
} | ||
} | ||
} | ||
} | ||
return ret; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible (or usefull) to use std::filesystem::path for folder ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be done in another PR