Skip to content

Commit

Permalink
Update copy
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed May 21, 2024
1 parent b35634f commit 6e8f94e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions datashader/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,8 @@ def astype(self, dtype, copy=True):
elif is_extension_array_dtype(dtype):
return dtype.construct_array_type()._from_sequence(
np.asarray(self))
if copy:
return np.array([v for v in self], dtype=dtype)
else:
return np.asarray([v for v in self], dtype=dtype)

return np.array([v for v in self], dtype=dtype)

def tolist(self):
# Based on pandas ExtensionArray.tolist
Expand All @@ -647,10 +645,12 @@ def tolist(self):
else:
return list(self)

def __array__(self, dtype=None, copy=None):
def __array__(self, dtype=None, copy=True):
dtype = np.dtype(object) if dtype is None else np.dtype(dtype)
arr = np.asarray(self.tolist(), dtype=dtype)
return arr.copy() if copy else arr
if copy:
return np.array(self.tolist(), dtype=dtype)
else:
return np.array(self, dtype=dtype)

def duplicated(self, *args, **kwargs):
msg = "duplicated is not implemented for RaggedArray"
Expand Down

0 comments on commit 6e8f94e

Please sign in to comment.