Skip to content

[ML] By-fields should respect model_plot_config.terms #86

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

dimitris-athanasiou
Copy link
Contributor

@dimitris-athanasiou dimitris-athanasiou commented May 3, 2018

This commit restores respecting the model_plot_config.terms
for by-fields. The bug seems to have been introduced in 6.2.0.
Note that I am also adding an integration test in the java
side to ensure such regressions are caught in the future.

Closes elastic/elasticsearch#30004

This commit restores respecting the model_plot_config.terms
for by-fields. The bug seems to have been introduced in 6.2.0.
Note that I am also adding an integration test in the java
side to ensure such regressions are caught in the future.

Closes elastic/elasticsearch#30004
@dimitris-athanasiou dimitris-athanasiou force-pushed the respect-model-plot-terms-for-by-field branch from 1b3edb0 to 3bd9439 Compare May 3, 2018 07:53
@@ -159,7 +159,7 @@ bool CModelDetailsView::contains(const TStrSet& terms, const std::string& key) {
}

bool CModelDetailsView::hasByField() const {
return (this->base().isPopulation()
return !(this->base().isPopulation()

Choose a reason for hiding this comment

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

wouldn't it be easier to switch the conditional expressions?

! is always hard to parse and probably the root of this regression?

Choose a reason for hiding this comment

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

obviously hard, I overlooked the brackets. Maybe == false - I think we recently discussed to use this in favor of !

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean changing this method into hasNoByField and then inverting the conditionals where it's called from? I'd rather not do that. But we could certainly change the function to the format (...).empty() == false. Do you prefer this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@hendrikmuhs
Copy link

LGTM

Any chance to create a testcase for this? If I got it right, this is an uncovered case.

Copy link

@hendrikmuhs hendrikmuhs left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -162,7 +162,7 @@ bool CModelDetailsView::hasByField() const {
return (this->base().isPopulation()
? this->base().dataGatherer().attributeFieldName()
: this->base().dataGatherer().personFieldName())
.empty();
.empty() == false;
Copy link
Contributor

Choose a reason for hiding this comment

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

The other thing that might possibly improve readability is to split this into two statements. Storing the result of the ternary operator in a const std::string & local variable and then returning a condition based on this in a second statement won't make the code less efficient once the optimiser has run on it, as the optimiser can easily see that the const std::string & can live in a register and never written back to memory.

And regardless of whether you decide to make that change, have you run clang-format on the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to split the statement.

I have run it. It's clang-format that indented the line I changed. Not sure why. I imagine it will change again once I split the statement.

@dimitris-athanasiou
Copy link
Contributor Author

@hendrikmuhs I looked into creating a unit test but it wasn't straightforward. Instead, I am writing an integration test in the java side. I've been thinking to create such a test for a long time for model plots, so it's a good opportunity.

Copy link
Contributor

@droberts195 droberts195 left a comment

Choose a reason for hiding this comment

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

LGTM

@droberts195
Copy link
Contributor

The only other thing to watch out for with this is that 6.3.0 BC3 has started. I fully expect there to be a BC4 but if there isn't then this will end up in 6.3.1. I will keep an eye on 6.3.0 progress.

@dimitris-athanasiou dimitris-athanasiou merged commit 0394b62 into elastic:master May 3, 2018
@dimitris-athanasiou dimitris-athanasiou deleted the respect-model-plot-terms-for-by-field branch May 3, 2018 08:47
dimitris-athanasiou added a commit that referenced this pull request May 3, 2018
This commit restores respecting the model_plot_config.terms
for by-fields. The bug seems to have been introduced in 6.2.0.
Note that I am also adding an integration test in the java
side to ensure such regressions are caught in the future.

Closes elastic/elasticsearch#30004
dimitris-athanasiou added a commit that referenced this pull request May 3, 2018
This commit restores respecting the model_plot_config.terms
for by-fields. The bug seems to have been introduced in 6.2.0.
Note that I am also adding an integration test in the java
side to ensure such regressions are caught in the future.

Closes elastic/elasticsearch#30004
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants