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
Add SGIO::progress unit tests and enhance SGIO::progress #3705
Conversation
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.
I like having unit tested progress bars :)
Some minor things required, then good to merge
src/shogun/io/SGIO.cpp
Outdated
@@ -165,7 +165,16 @@ void SGIO::progress( | |||
float64_t v=-1, estimate=0, total_estimate=0 ; | |||
|
|||
if (max_val-min_val>0.0) | |||
{ |
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.
we usually dont do extra {} for single lines
src/shogun/io/SGIO.cpp
Outdated
} | ||
else | ||
{ | ||
/* Wrong range, exit */ |
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.
superflous comment
@@ -189,6 +196,7 @@ void SGIO::progress( | |||
if (current_val >= max_val-1) | |||
{ | |||
v = 100; | |||
last_progress=v-1e-6; |
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.
if you do that, why not initialise it with 0 above rather than -1?
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.
Are you referring to last_progress
or v
? If you're referring to last_progress
I think of -1 as a value that means not initialized and I used it since there are cases in which last_progress
is not set (for example when max_val-min_val<=0
). Obviously, this is completely subjective. Using 0 instead of -1 should not make any difference. :)
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.
Yeah it doesnt, just a tiny bit cleaner....your call
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.
Core developer's will is law ;). Jokes aside, I will change it to 0. As I said, it is the same 👍
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.
Hehe ;)
We gotta make everything as good as we possibly can -- chances that somebody touches code again are pretty low, so better get it correct (and neat) in the first place.
Hey are you in IRC at some point, I remember you asked about dependencies ....
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.
Yeah, I am still curious about them ;). Regarding IRC, I could be online tomorrow morning, will I find you @karlnapf?
src/shogun/io/SGIO.h
Outdated
@@ -288,6 +288,13 @@ class SGIO | |||
return location_info; | |||
} | |||
|
|||
/** get last progress |
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.
@return last time progress was registered
I.e. needs doxygen and a human understandable description (this is API doc)
tests/unit/io/SGIO_unittest.cc
Outdated
|
||
TEST(SGIOTest, progress_correct_bounds) | ||
{ | ||
/* Positive values */ |
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.
pls split positive and negative into separate tests. tests should be as small as possible
tests/unit/io/SGIO_unittest.cc
Outdated
EXPECT_EQ(tmp2.get_last_progress(), (float64_t)-1); | ||
|
||
/* Negative values */ | ||
SGIO tmp; |
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.
same here, split
bebcb3d
to
b451da9
Compare
src/shogun/io/SGIO.h
Outdated
@@ -288,6 +288,15 @@ class SGIO | |||
return location_info; | |||
} | |||
|
|||
/** get last_progress |
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.
Sorry for being picky, but these things are never fixed otherwise.
You can just remove the text here, and only have the @ in a single line
src/shogun/io/SGIO.h
Outdated
@@ -288,6 +288,12 @@ class SGIO | |||
return location_info; | |||
} | |||
|
|||
/** @return last progress as percentage */ |
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.
A* :)
Ill merge once CI is green |
tests/unit/io/SGIO_unittest.cc
Outdated
{ | ||
SGIO tmp; | ||
tmp.enable_progress(); | ||
for (int i=0; i<100; i++) { |
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.
minor, new line for {
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.
Sorry there is some things wrong with the tests that need fix. Didnt see that earlier
tests/unit/io/SGIO_unittest.cc
Outdated
{ | ||
SGIO tmp2; | ||
tmp2.enable_progress(); | ||
for (int i=-100; i>0; i++) { |
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.
this loop is never executed
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.
argh noob fail
tests/unit/io/SGIO_unittest.cc
Outdated
SGIO tmp2; | ||
tmp2.enable_progress(); | ||
tmp2.progress(0, 100, 1); | ||
EXPECT_EQ(tmp2.get_last_progress(), (float64_t)0); |
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.
(float64_t)0
can be just 0.0
But in fact that is not even necessary.
What you want to use here is EXPECT_NEAR
which compares floating point numbers, where you can set the epsilon to machine precision or so
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.
Can I use EXPECT_FLOAT_EQ
? Seems to have the same behaviour as EXPECT_NEAR
and also its meaning is more straightforward.
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.
Sure! Didn't know about that guy actually
tests/unit/io/SGIO_unittest.cc
Outdated
SGIO tmp; | ||
tmp.enable_progress(); | ||
tmp.progress(0, -1, -2); | ||
EXPECT_EQ(tmp.get_last_progress(), (float64_t)0); |
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.
same here, sorry I didnt spot those earler.
Cannot check floats for equality....it is not portable
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.
Same question as above
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.
Yep!!
Add a getter to retrieve the last_progress (for testing purpose).
I'm heikoS
You might need to try a few times, I'm more online under the week than on
weekend
On Fri, 17 Mar 2017 at 17:26, Giovanni De Toni ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/shogun/io/SGIO.cpp
<#3705 (comment)>
:
> @@ -189,6 +196,7 @@ void SGIO::progress(
if (current_val >= max_val-1)
{
v = 100;
+ last_progress=v-1e-6;
Yeah, I am still curious about them ;). Regarding IRC, I could be online
tomorrow morning, will I find you @karlnapf <https://github.com/karlnapf>?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3705 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAqqv4CO-OIPkQ-OZmRy2fjjSJpx3KTlks5rmsJEgaJpZM4MeKpA>
.
--
Sent from my phone
|
@karlnapf any update on this one? |
Nice patch, thanks! |
@vigsterkr @lisitsyn pls merge |
Add SGIO::progress unit tests and enhance SGIO::progress
Unit tests for #3694 plus little changes to SGIO::progress to make unit tests pass.