Skip to content

Conversation

@lalo
Copy link
Collaborator

@lalo lalo commented Sep 2, 2021

  1. remove print from explore_test.cc
  2. shift things around from tutorial_test.cc to simulator.h
  3. 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);
Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Member

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

Copy link
Collaborator Author

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*)>>;
Copy link
Member

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

Copy link
Collaborator Author

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?

Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Collaborator

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

@lalo lalo enabled auto-merge (squash) September 2, 2021 15:04
@lalo lalo disabled auto-merge September 2, 2021 15:11
@lalo lalo enabled auto-merge (squash) September 2, 2021 15:11
@lalo
Copy link
Collaborator Author

lalo commented Sep 2, 2021

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);
Copy link
Collaborator

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?

Copy link
Collaborator Author

@lalo lalo Sep 2, 2021

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:

"--test_red 0 --cb_explore_adf --quiet --epsilon 0.2 --random_seed 5", test_hooks, (int)num_iterations);

@lalo lalo force-pushed the fix_ut branch 2 times, most recently from 332bddd to 1053b12 Compare September 2, 2021 17:31
@lalo lalo merged commit a88b94f into VowpalWabbit:master Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants