Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tools
frackit
Commits
fcffe0aa
Commit
fcffe0aa
authored
Nov 29, 2020
by
Dennis Gläser
Browse files
[samplingstatus] allow reason-specific rejection
parent
0b2eae94
Changes
1
Hide whitespace changes
Inline
Side-by-side
frackit/sampling/status.hh
View file @
fcffe0aa
...
...
@@ -25,6 +25,7 @@
#ifndef FRACKIT_SAMPLING_STATUS_HH
#define FRACKIT_SAMPLING_STATUS_HH
#include
<string>
#include
<iomanip>
#include
<iostream>
#include
<algorithm>
...
...
@@ -67,9 +68,11 @@ public:
void
reset
()
{
headerPrinted_
=
false
;
rejectedCount_
=
0
;
unspecifiedRejectedCount_
=
0
;
count_
.
clear
();
targetCount_
.
clear
();
rejectedCount_
.
clear
();
}
/*!
...
...
@@ -77,7 +80,9 @@ public:
*/
void
resetCounters
()
{
for
(
auto
&
count
:
count_
)
count
.
second
=
0
;
std
::
for_each
(
count_
.
begin
(),
count_
.
end
(),
[]
(
auto
&
idCountPair
)
{
idCountPair
.
second
=
0.0
;
});
}
/*!
...
...
@@ -127,7 +132,16 @@ public:
*/
void
increaseRejectedCounter
()
{
rejectedCount_
++
;
unspecifiedRejectedCount_
++
;
}
/*!
* \brief Increase counter of rejected samples
* with a specific rejection reason.
*/
void
increaseRejectedCounter
(
const
std
::
string
&
reason
)
{
rejectedCount_
[
reason
]
++
;
}
/*!
...
...
@@ -139,7 +153,7 @@ public:
/*!
* \brief Returns the overall entity count.
*/
std
::
size_t
getCount
()
std
::
size_t
getCount
()
const
{
return
std
::
accumulate
(
count_
.
begin
(),
count_
.
end
(),
...
...
@@ -163,10 +177,12 @@ public:
std
::
size_t
curCount
=
0
;
std
::
size_t
curTargetCount
=
0
;
std
::
size_t
curRejectedCount
=
unspecifiedRejectedCount_
;
for
(
const
auto
&
pair
:
count_
)
curCount
+=
pair
.
second
;
for
(
const
auto
&
pair
:
targetCount_
)
curTargetCount
+=
pair
.
second
;
for
(
const
auto
&
pair
:
rejectedCount_
)
curRejectedCount
+=
pair
.
second
;
const
auto
ratio
=
100.0
*
double
(
double
(
curCount
)
/
double
(
curCount
+
r
ejectedCount
_
));
const
auto
ratio
=
100.0
*
double
(
double
(
curCount
)
/
double
(
curCount
+
curR
ejectedCount
));
const
auto
progress
=
100.0
*
double
(
curCount
)
/
double
(
curTargetCount
);
std
::
cout
<<
std
::
setprecision
(
2
)
<<
std
::
fixed
;
...
...
@@ -174,7 +190,7 @@ public:
const
auto
progressNumChars
=
std
::
to_string
(
int
(
progress
)).
size
()
+
3
;
const
auto
countString
=
std
::
to_string
(
curCount
);
const
auto
rejectedCountString
=
std
::
to_string
(
r
ejectedCount
_
);
const
auto
rejectedCountString
=
std
::
to_string
(
curR
ejectedCount
);
using
std
::
max
;
const
std
::
size_t
zero
=
0
;
...
...
@@ -191,9 +207,11 @@ public:
private:
bool
headerPrinted_
=
false
;
std
::
size_t
rejectedCount_
=
0
;
std
::
unordered_map
<
std
::
size_t
,
std
::
size_t
>
count_
;
std
::
unordered_map
<
std
::
size_t
,
std
::
size_t
>
targetCount_
;
std
::
unordered_map
<
std
::
string
,
std
::
size_t
>
rejectedCount_
;
std
::
size_t
unspecifiedRejectedCount_
=
0
;
};
}
// end namespace Frackit
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment