-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
%s changed to fstring, single quotes in f string changed to double qu… #30108
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 1 commit
Commits
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1209,8 +1209,7 @@ def period_format(int64_t value, int freq, object fmt=None): | |||||
elif freq_group == 4000: # WK | ||||||
left = period_asfreq(value, freq, 6000, 0) | ||||||
right = period_asfreq(value, freq, 6000, 1) | ||||||
return '%s/%s' % (period_format(left, 6000), | ||||||
period_format(right, 6000)) | ||||||
return f"(period_format(left, 6000)/period_format(right, 6000))" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just pushed this change. it fixed the errors for locally |
||||||
elif (freq_group == 5000 # BUS | ||||||
or freq_group == 6000): # DAY | ||||||
fmt = b'%Y-%m-%d' | ||||||
|
@@ -1227,7 +1226,7 @@ def period_format(int64_t value, int freq, object fmt=None): | |||||
elif freq_group == 12000: # NANOSEC | ||||||
fmt = b'%Y-%m-%d %H:%M:%S.%n' | ||||||
else: | ||||||
raise ValueError(f'Unknown freq: {freq}') | ||||||
raise ValueError(f"Unknown freq: {freq}") | ||||||
|
||||||
return _period_strftime(value, freq, fmt) | ||||||
|
||||||
|
@@ -1275,15 +1274,15 @@ cdef object _period_strftime(int64_t value, int freq, object fmt): | |||||
if i == 0: | ||||||
repl = str(quarter) | ||||||
elif i == 1: # %f, 2-digit year | ||||||
repl = f'{(year % 100):02d}' | ||||||
repl = f"{(year % 100):02d}" | ||||||
elif i == 2: | ||||||
repl = str(year) | ||||||
elif i == 3: | ||||||
repl = f'{(value % 1_000):03d}' | ||||||
repl = f"{(value % 1_000):03d}" | ||||||
elif i == 4: | ||||||
repl = f'{(value % 1_000_000):06d}' | ||||||
repl = f"{(value % 1_000_000):06d}" | ||||||
elif i == 5: | ||||||
repl = f'{(value % 1_000_000_000):09d}' | ||||||
repl = f"{(value % 1_000_000_000):09d}" | ||||||
|
||||||
result = result.replace(str_extra_fmts[i], repl) | ||||||
|
||||||
|
@@ -1391,7 +1390,7 @@ def get_period_field_arr(int code, int64_t[:] arr, int freq): | |||||
|
||||||
func = _get_accessor_func(code) | ||||||
if func is NULL: | ||||||
raise ValueError(f'Unrecognized period code: {code}') | ||||||
raise ValueError(f"Unrecognized period code: {code}") | ||||||
|
||||||
sz = len(arr) | ||||||
out = np.empty(sz, dtype=np.int64) | ||||||
|
@@ -1578,8 +1577,8 @@ cdef class _Period: | |||||
freq = to_offset(freq) | ||||||
|
||||||
if freq.n <= 0: | ||||||
raise ValueError(f'Frequency must be positive, because it ' | ||||||
f'represents span: {freq.freqstr}') | ||||||
raise ValueError(f"Frequency must be positive, because it " | ||||||
f"represents span: {freq.freqstr}") | ||||||
|
||||||
return freq | ||||||
|
||||||
|
@@ -1613,8 +1612,8 @@ cdef class _Period: | |||||
return NotImplemented | ||||||
elif op == Py_NE: | ||||||
return NotImplemented | ||||||
raise TypeError(f'Cannot compare type {type(self).__name__} ' | ||||||
f'with type {type(other).__name__}') | ||||||
raise TypeError(f"Cannot compare type {type(self).__name__} " | ||||||
f"with type {type(other).__name__}") | ||||||
|
||||||
def __hash__(self): | ||||||
return hash((self.ordinal, self.freqstr)) | ||||||
|
@@ -1632,8 +1631,8 @@ cdef class _Period: | |||||
if nanos % offset_nanos == 0: | ||||||
ordinal = self.ordinal + (nanos // offset_nanos) | ||||||
return Period(ordinal=ordinal, freq=self.freq) | ||||||
raise IncompatibleFrequency(f'Input cannot be converted to ' | ||||||
f'Period(freq={self.freqstr})') | ||||||
raise IncompatibleFrequency(f"Input cannot be converted to " | ||||||
f"Period(freq={self.freqstr})") | ||||||
elif util.is_offset_object(other): | ||||||
freqstr = other.rule_code | ||||||
base = get_base_alias(freqstr) | ||||||
|
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.
are we calling this function inside a loop? if so, we may need to be careful about whether cython fstrings differently from % formatting
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.
more generally, id prefer to have non-trivial function calls occur outside of f-space.
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 CI failures look related to this