Skip to content

Conversation

@bassmang
Copy link
Member

@bassmang bassmang commented Jun 8, 2021

No description provided.

@bassmang bassmang requested a review from jackgerrits June 8, 2021 19:47
}

auto tree = scoped_calloc_or_throw<cats_tree>();
auto tree = VW::make_unique<cats_tree>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like _cost_star, _a, _b are unitialized after this call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just recommitted. Let me know if manually initializing _a and _b is preferred to creating a constructor in node_cost.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having the node_cost initialization done internally is good as it affects any other usage too. So this approach is better

std::string tree_stats_to_string();
min_depth_binary_tree _binary_tree;
float _cost_star;
float _cost_star = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be a float literal 0.f

{
uint32_t node_id;
float cost;
node_cost(uint32_t node_id = 0, float cost = 0) : node_id(node_id), cost(cost) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nit, so feel free to wontfix. I'd say updating lines 55 and 56 is preferable as default params in constructors is a but confusing and the default constructor compared to this constructor with default parameters is ambiguous. (well default won't be generated in this case, and I think default default constructor is usually best)

uint32_t node_id = 0;
float cost = 0.f;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually tried this initially, however it causes a compilation error with commands such as "_a = {node_id, _cost_star};"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. In that case I think we should have two constructors. Default and two parameter rather than a since one with default parameters.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok just recommitted.

@bassmang bassmang merged commit ebd65e4 into VowpalWabbit:master Jun 10, 2021
@bassmang bassmang deleted the refac branch June 10, 2021 14:27
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.

2 participants