Skip to content
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

Filter entities from comparator combiner when not listed in input_features #3251

Merged
merged 4 commits into from
Mar 15, 2023

Conversation

tgaddair
Copy link
Collaborator

No description provided.

@ksbrar
Copy link
Collaborator

ksbrar commented Mar 15, 2023

Wondering why this behavior is not enforced by this validation check:

if sorted(config.combiner.entity_1 + config.combiner.entity_2) != sorted(input_feature_names):

@tgaddair
Copy link
Collaborator Author

@ksbrar that would validate the config, but this PR makes the behavior more permissive by letting these configs go through.

@ksbrar
Copy link
Collaborator

ksbrar commented Mar 15, 2023

Ah gotcha, was thinking backwards - purpose IS to make the parameter more permissive 👍

},
}

with pytest.raises(ConfigValidationError) if not expected else contextlib.nullcontext():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maximally parameterizing tests to minimize code duplication is tempting, but it can make tests more difficult to read and understand when it involves adding logic to the test itself.

See "Avoid logic in tests" from Microsoft's testing best practices guide.

The behavior we are testing for is more readable/understandable as three separate tests, imo:

def test_comparator_combiner_raises_missing_features():
def test_comparator_combiner_removes_extra_features():
def test_comparator_combiner_raises_duplicated_features():

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can't say I agree. I was thinking of adding a handful of additioanl tests to this. Parametrizing makes this super easy. Separate tests means in practice, no one's ever going to bother.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The good thing is that the relatively simple logic in this test means it's already pretty readable.

Now that there are 7 tests, I would agree that splitting into separate tests would be too much code duplication and not worthwhile.

As a nit: would you be able to add a quick comment do the different lines explaining what each case is testing for?

@arnavgarg1 arnavgarg1 added the release-0.7 Needs cherry-pick into 0.7 release branch label Mar 15, 2023
@github-actions
Copy link

Unit Test Results

         6 files  ±  0           6 suites  ±0   7h 29m 6s ⏱️ + 30m 36s
  4 094 tests +  7    4 051 ✔️ +  7    43 💤 ±0  0 ±0 
12 239 runs   - 43  12 109 ✔️  - 38  130 💤  - 5  0 ±0 

Results for commit 677f23a. ± Comparison against base commit d5f61eb.

@tgaddair tgaddair merged commit 0bef777 into master Mar 15, 2023
@tgaddair tgaddair deleted the filter-comparator branch March 15, 2023 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-0.7 Needs cherry-pick into 0.7 release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants