-
Notifications
You must be signed in to change notification settings - Fork 871
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
Allow TitleCase and camelCase #1854
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1854 +/- ##
==========================================
+ Coverage 98.82% 98.83% +0.01%
==========================================
Files 147 147
Lines 16290 16291 +1
==========================================
+ Hits 16099 16102 +3
+ Misses 191 189 -2
Continue to review full report at Codecov.
|
featuretools/primitives/utils.py
Outdated
def camel_and_title_to_snake(name): | ||
name = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) | ||
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', name).lower() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect "Top3Words" to be converted to "top_3_words" but currently this will return "top3_words"
A test just for the |
Is there somewhere in the documentation that we can put the new constraints on what primitive strings will be recognized? I guess we never specifically mentioned that they had to me the same as |
@dvreed77 Not sure if we need to handle this case, but wanted to note a potentially problematic string for I think we can avoid dealing with this specific example if we just use the word "Null" an time we might use "nan" in a primitive name, but it's something to keep in mind bc we can't stop users from trying to pass in that string |
@@ -68,3 +69,16 @@ def test_list_semantic_tags(): | |||
ft_semantic_tags = ft.list_semantic_tags() | |||
ww_semantic_tags = list_semantic_tags() | |||
assert ft_semantic_tags.equals(ww_semantic_tags) | |||
|
|||
|
|||
def test_camel_and_title_to_snake(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we include a snake case test case to confirm snake case passed in is unaltered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Pull Request Description
Fixes #1761
implementation that allowed all variations of case and underscore: #1841
Feature Request
Provide convenience to a user by allowing them to pass a primitive name in either snake_case, TitleCase or camelCase
Implementation
Reduce TitleCase and camelCase into snake_case before matching them internally. This means we can't accept primitive names like "cOuNt" because it will be converted to "c_ou_nt". I think this is the desired behavior though
Assumptions: