Skip to content
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

Ensure that DatetimeArray keeps reference to original data #23956

Merged
merged 3 commits into from
Nov 28, 2018

Conversation

TomAugspurger
Copy link
Contributor

(cherry picked from commit 49f6495ba5ceef35a7a962f20e8b863c544592b7)

This avoids a segfault I (and possibly @jbrockmendel) were seeing on our datetimearray branches from us freeing a region of memory we didn't allocate.

I haven't really groked things yet, but _libs/reduction.pyx::Slider is doing some strange things with the data of the array passed to it (overwriting the buffer's .data and .strides attributes). One of the arguments, buff, is a slice on the original index. It seems like ensuring that the ndarray backing the DatetimeArray sliced index is the same as the original index avoids the segfault.

(cherry picked from commit 49f6495ba5ceef35a7a962f20e8b863c544592b7)
@TomAugspurger TomAugspurger added Datetime Datetime data dtype ExtensionArray Extending pandas with custom dtypes or arrays. labels Nov 27, 2018
@TomAugspurger TomAugspurger added this to the 0.24.0 milestone Nov 27, 2018
@pep8speaks
Copy link

Hello @TomAugspurger! Thanks for submitting the PR.

@@ -99,11 +99,11 @@ def ensure_datetime64ns(arr: ndarray, copy: bool=True):

ivalues = arr.view(np.int64).ravel()

result = np.empty(shape, dtype='M8[ns]')
result = np.empty(shape, dtype=NS_DTYPE)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be clear: this change is cosmetic. The real change is below.

@codecov
Copy link

codecov bot commented Nov 27, 2018

Codecov Report

Merging #23956 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #23956   +/-   ##
=======================================
  Coverage   92.31%   92.31%           
=======================================
  Files         161      161           
  Lines       51471    51471           
=======================================
  Hits        47515    47515           
  Misses       3956     3956
Flag Coverage Δ
#multiple 90.7% <ø> (ø) ⬆️
#single 42.43% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db8d33e...a77a24a. Read the comment docs.

pandas/_libs/tslibs/conversion.pyx Outdated Show resolved Hide resolved
@jreback
Copy link
Contributor

jreback commented Nov 28, 2018

lgtm.

@jreback jreback merged commit 2712c8f into pandas-dev:master Nov 28, 2018
@jreback
Copy link
Contributor

jreback commented Nov 28, 2018

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants