-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: Move capitalize_first_letter to where it's used #57096
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
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9a5ffd2
Use str.captialize instead of helper
mroeschke 00f0992
Use title instead
mroeschke b775e21
Use string capwords
mroeschke 088b988
Merge remote-tracking branch 'upstream/main' into cln/helper
mroeschke 9208bee
Merge remote-tracking branch 'upstream/main' into cln/helper
mroeschke be1df81
Pylint
mroeschke 61e6b14
Merge remote-tracking branch 'upstream/main' into cln/helper
mroeschke 19fa575
Just use helper function
mroeschke 2d65f02
Merge remote-tracking branch 'upstream/main' into cln/helper
mroeschke fd76f47
Merge remote-tracking branch 'upstream/main' into cln/helper
mroeschke 8ce54ce
Remove helper function
mroeschke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The equivalent of the deleted function is
str.capitalize()
.str.title()
makes the first letter of every word uppercase, not only the first letter of the whole string. Not sure if in this case it makes a difference, but maybe worth keeping the same exact behavior.In any case, nice clean up.
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.
Looks like neither is correct
I found
string.capwords
works for what we want to compare here so I'll use thatThere 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 like the current implementation better. But I think it simply does a case insensitive comparison, which is fine. But if that's what we really want, I'd just apply
.lower()
to both sides. The code withstring.capwords
does exactly the same I think, but when reading it feels like there must be a reason to usestring.capwords
in particular, so I find it a bit misleading.@MarcoGorelli @natmokval any thoughts on this?
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.
string.capwords
allows a case insensitive match for the first letter only which is what we want.lower
would do a case insensitive match on the whole string which is incorrect because we don't want to do that for the frequency in the brackets.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.
seems like, if we replace
string.capwords
with.lower
all tests pass, but I prefer not to change the frequency in the brackets.Thouhg for
dtype
we use both"period[D]"
and"Period[D]"
, it's better to keep the correct case for the frequency.The reason: currently we are working on creating a consistent naming for aliases (xref #56346).
Deprecated lowercase strings in favour of uppercase strings denoting:
Deprecated uppercase strings in favour of lowercase strings denoting:
For some frequencies the deprecation is done, for example we show
FutureWarning
iffreq="q"
For others, for example Day/Daily we can use both
'D'
and'd'
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.
Sorry to insist @mroeschke, but I don't think the code in the PR does what you think it does (or maybe I'm missing something, but I can't see what).
string.capwords
is making the comparison fully case insensitive:Any case variation of
period[us]
would be converted toPeriod[us]
and the comparison will be true regardless on which part of the string has different capitalization.If the resulting string is going to be used for anything else than comparing, I agree the exact function used is relevant. But in this case, any of
.upper()
,.lower()
,.title()
,string.capwords()
... would be equivalent, and I think.lower()
is the one that makes the code clearer.Or maybe we know that one of the sides of the comparison is in the
Period[ms]
orperiod[ms]
capitalization? Then we should remove the call tostring.capwords
in that side of the comparison, andstring.capwords
will do what we want.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.
Ah OK thanks for talking that through. I understand the situation clearer now. I think with the requirement to keep the frequency in the brackets unmodified, I think the only solution is to use the original helper function to the latest commit changed it back to that