From 8432f2368eb91181a19bf768986a3f31bde10490 Mon Sep 17 00:00:00 2001 From: Nezar Abdennur Date: Sat, 13 Jul 2019 17:38:48 -0400 Subject: [PATCH 1/2] Implement the copy arg for astype --- sparse/coo/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sparse/coo/core.py b/sparse/coo/core.py index 730e04e7..2b260968 100644 --- a/sparse/coo/core.py +++ b/sparse/coo/core.py @@ -2066,7 +2066,7 @@ def clip(self, min=None, max=None, out=None): return self.__array_ufunc__(np.clip, '__call__', self, a_min=min, a_max=max, out=out) - def astype(self, dtype): + def astype(self, dtype, copy=True): """ Copy of the array, cast to a specified type. @@ -2077,7 +2077,7 @@ def astype(self, dtype): :obj:`COO.elemwise`: Apply an arbitrary element-wise function to one or two arguments. """ - return self.__array_ufunc__(np.ndarray.astype, '__call__', self, dtype=dtype) + return self.__array_ufunc__(np.ndarray.astype, '__call__', self, dtype=dtype, copy=copy) def maybe_densify(self, max_size=1000, min_density=0.25): """ From 8e236b5018c75656da87fc5281480f2e1308d64f Mon Sep 17 00:00:00 2001 From: Nezar Abdennur Date: Sat, 13 Jul 2019 17:40:13 -0400 Subject: [PATCH 2/2] Expose numpy's result_type() through sparse --- sparse/coo/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sparse/coo/__init__.py b/sparse/coo/__init__.py index 8f12d74e..3fa5616e 100644 --- a/sparse/coo/__init__.py +++ b/sparse/coo/__init__.py @@ -5,6 +5,8 @@ eye, full, full_like, zeros, zeros_like, ones, ones_like, kron, argwhere, isposinf, isneginf) +from numpy.core._multiarray_umath import result_type + __all__ = ['COO', 'as_coo', 'elemwise', 'tensordot', 'dot', 'matmul', 'concatenate', 'stack', 'triu', 'tril', 'where', 'nansum', 'nanmean', 'nanprod', 'nanmin', 'nanmax', 'nanreduce', 'roll', 'eye', 'full', 'full_like', 'zeros', 'zeros_like', 'ones', 'ones_like', 'kron', 'argwhere', - 'isposinf', 'isneginf'] + 'isposinf', 'isneginf', 'result_type']