File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -507,7 +507,7 @@ def to_numpy(
507507 else :
508508 with warnings .catch_warnings ():
509509 warnings .filterwarnings ("ignore" , category = RuntimeWarning )
510- data = np . array ( self ._data , dtype = dtype , copy = copy )
510+ data = self ._data . astype ( dtype , copy = copy )
511511 return data
512512
513513 @doc (ExtensionArray .tolist )
@@ -581,7 +581,10 @@ def __array__(
581581 the array interface, return my values
582582 We return an object array here to preserve our scalar values
583583 """
584- if copy is False and self ._hasna :
584+ if copy is False :
585+ if not self ._hasna :
586+ # special case, here we can simply return the underlying data
587+ return np .array (self ._data , dtype = dtype , copy = copy )
585588 raise ValueError (
586589 "Unable to avoid copy while creating an array as requested."
587590 )
You can’t perform that action at this time.
0 commit comments