-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix upstream dev issues #9953
Merged
Merged
fix upstream dev issues #9953
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 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 |
---|---|---|
|
@@ -579,20 +579,23 @@ def _numbers_to_timedelta( | |
) -> np.ndarray: | ||
"""Transform numbers to np.timedelta64.""" | ||
# keep NaT/nan mask | ||
nan = np.isnan(flat_num) | (flat_num == np.iinfo(np.int64).min) | ||
if flat_num.dtype.kind == "f": | ||
nan = np.asarray(np.isnan(flat_num)) | ||
elif flat_num.dtype.kind == "i": | ||
nan = np.asarray(flat_num == np.iinfo(np.int64).min) | ||
|
||
# in case we need to change the unit, we fix the numbers here | ||
# this should be safe, as errors would have been raised above | ||
ns_time_unit = _NS_PER_TIME_DELTA[time_unit] | ||
ns_ref_date_unit = _NS_PER_TIME_DELTA[ref_unit] | ||
if ns_time_unit > ns_ref_date_unit: | ||
flat_num *= np.int64(ns_time_unit / ns_ref_date_unit) | ||
flat_num = np.asarray(flat_num * np.int64(ns_time_unit / ns_ref_date_unit)) | ||
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. For pandas 3.0 CoW (copy on write) this array might be flagged readonly. So creating a copy here. The asarray-wrapping is needed for upstream-dev to keep 0d-arrays an array. |
||
time_unit = ref_unit | ||
|
||
# estimate fitting resolution for floating point values | ||
# this iterates until all floats are fractionless or time_unit == "ns" | ||
if flat_num.dtype.kind == "f" and time_unit != "ns": | ||
flat_num_dates, new_time_unit = _check_higher_resolution(flat_num, time_unit) # type: ignore[arg-type] | ||
flat_num, new_time_unit = _check_higher_resolution(flat_num, time_unit) | ||
if time_unit != new_time_unit: | ||
msg = ( | ||
f"Can't decode floating point {datatype} to {time_unit!r} without " | ||
|
@@ -608,7 +611,8 @@ def _numbers_to_timedelta( | |
with warnings.catch_warnings(): | ||
warnings.simplefilter("ignore", RuntimeWarning) | ||
flat_num = flat_num.astype(np.int64) | ||
flat_num[nan] = np.iinfo(np.int64).min | ||
if nan.any(): | ||
flat_num[nan] = np.iinfo(np.int64).min | ||
|
||
# cast to wanted type | ||
return flat_num.astype(f"timedelta64[{time_unit}]") | ||
|
This file contains 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
Oops, something went wrong.
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.
That's a bit more explicit. The asarray-wrapping is needed for upstream-dev to keep 0d-arrays an array.