Skip to content

Refactor can_stack_primitive_on_inputs #2522

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

Merged
merged 16 commits into from
Jul 27, 2023

Conversation

sbadithe
Copy link
Contributor

@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Merging #2522 (1547a2b) into main (85c60ae) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #2522   +/-   ##
=======================================
  Coverage   99.47%   99.47%           
=======================================
  Files         403      403           
  Lines       24197    24203    +6     
=======================================
+ Hits        24070    24076    +6     
  Misses        127      127           
Files Changed Coverage Δ
featuretools/synthesis/deep_feature_synthesis.py 99.56% <100.00%> (+<0.01%) ⬆️

@sbadithe sbadithe marked this pull request as ready for review March 15, 2023 04:16
@@ -1094,17 +1094,60 @@ def _find_root_primitive(feature):
return feature.primitive


def _check_if_stacking_is_prohibited(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you try to type this? might be hard, but would be helpful to add types to new things we create

Copy link
Contributor

Choose a reason for hiding this comment

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

Added some type hints in 5178220


if tup_primitive_stack_on is None or isinstance(
# we permit stacking only if it is not prohibited and meets the criterion to be permitted
if _check_if_stacking_is_permitted(
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe I'm missing something, but prohibited and permitted should be mutually exclusive states, and so if its not prohibited, its permitted. Can you refactor even more to make this the case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I'm with Dave here, I like that you extracted this logic into separate functions but is it possible we could just merge these two functions together?

Copy link
Contributor

Choose a reason for hiding this comment

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

@dvreed77 I don't think prohibited and permitted in this case are mutually exclusive. I think we can have cases where both checks are False or both are True because the logic checks are different between the "permitted" and "prohibited" functions. We want prohibited to take precedence, so in the case that both checks are True or both checks are False, we want the result to be "prohibited".

I might be missing something still, but I think those conditions make it a little tricker to refactor this further.

Copy link
Contributor

Choose a reason for hiding this comment

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

I did add some additional comments to maybe clarify what is going on a little better. I'm open to other suggestions on how to improve further though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with Nate here, I remember trying to find a way to clean it up before coming up with the original changes, but none were immediately apparent to me at the time. I think this PR was an initial attempt at refactoring the stacking logic at a surface level, mostly to play around with and discover the areas where we could refactor. A second, more fundamental refactor might be needed to simplify the deeper logic of how we handle stacking.

Comment on lines 1180 to 1183
continue

if f_primitive.base_of is None:
continue
if primitive_class in f_primitive.base_of:
continue

# if we reach this case, we default to stacking not being permitted
return False
Copy link
Contributor

Choose a reason for hiding this comment

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

since we continue into a return False here we could probably
just do: return _check_if_stacking_is_permitted()

Copy link
Contributor

Choose a reason for hiding this comment

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

We only want to return when _check_if_stacking_is_permitted returns False, otherwise we need to keep going to make sure it's True for all inputs.

@rwedge
Copy link
Contributor

rwedge commented Mar 20, 2023

We should test this branch with the many features ecommerce test on looking glass to verify feature definitions are unchanged

@thehomebrewnerd
Copy link
Contributor

We should test this branch with the many features ecommerce test on looking glass to verify feature definitions are unchanged

Tested this against v1.27.0 and the number of features generated for all tests remained the same.

@gsheni gsheni merged commit 2adac99 into main Jul 27, 2023
@gsheni gsheni deleted the refactor-can-stack-primitive-on-inputs branch July 27, 2023 16:23
@thehomebrewnerd thehomebrewnerd mentioned this pull request Oct 26, 2023
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.

Refactor can_stack_primitive_on_inputs helper function
6 participants