-
Notifications
You must be signed in to change notification settings - Fork 1.9k
test: unit tests improvements #3281
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
Conversation
lalo
commented
Sep 2, 2021
- remove print from explore_test.cc
- shift things around from tutorial_test.cc to simulator.h
- add callback hook to simulator
1) remove print from explore_test.cc 2) shift things around from tutorial_test.cc to simulator.h 3) add callback hook to simulator
| const auto str_pdf = to_string(the_pdf); // 2-3.5:0.0666667,3.5-4.5:0.8,4.5-6.2:0.0588235 | ||
| // avoid float precision compare | ||
| BOOST_CHECK_EQUAL(str_pdf.find("2-3.5:"), 0); | ||
| BOOST_CHECK(str_pdf.find(",3.5-4.5:0.8,4.5-6.2:") > 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.
This wont be resilient to float differences. Is that okay? Also if the to_string changes then this test will break
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.
well its all generated from right above, any suggestions on how to replace that print? or just delete or what
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.
You could pick out the bits of it and assert that segment exists. It's way more work and not really worth it. I just wanted to point it out. Let's not worry about it
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 it passes it stays, if not we can later revisit. It is already wrong printing random stuff.
| { | ||
| // maps an int: # learned examples | ||
| // with a function to 'test' at that point in time in the simulator | ||
| using callback_map = typename std::map<int, std::function<bool(vw*)>>; |
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.
Typename is probably not needed here
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.
it will be later i think, or what makes you say that?
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.
std::map is not ambiguous so you don't need to tell the compiler is a type? I'm not 100% so leaving it here is fine
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.
yea the benefit is low, i was thinking for default arg to some function. It looks a bit cleaner with a short typedef
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.
typename shouldn't be needed since there isn't a need to specify that this is a type, I think it is mostly used with templates to distinguish any ambiguity
|
related: #3252 |
|
|
||
| std::vector<float> _test_helper(const std::string&, int = 3000, int = 10); | ||
| std::vector<float> _test_helper_save_load(const std::string&, int = 3000, int = 10); | ||
| std::vector<float> _test_helper_hook(const std::string&, callback_map&, int = 3000, int = 10); |
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.
where is this being called from?
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.
automl PR for more examples:
vowpal_wabbit/test/unit_test/automl_test.cc
Line 162 in 3528eeb
| "--test_red 0 --cb_explore_adf --quiet --epsilon 0.2 --random_seed 5", test_hooks, (int)num_iterations); |
332bddd to
1053b12
Compare