Skip to content

Commit 939f3ff

Browse files
nvictushameerabbasi
authored andcommitted
Modifications to enable sparse xarrays (#261)
* Implement the copy arg for astype * Expose numpy's result_type() through sparse
1 parent 72ca41e commit 939f3ff

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

sparse/coo/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
eye, full, full_like, zeros, zeros_like, ones, ones_like,
66
kron, argwhere, isposinf, isneginf)
77

8+
from numpy.core._multiarray_umath import result_type
9+
810
__all__ = ['COO', 'as_coo', 'elemwise', 'tensordot', 'dot', 'matmul', 'concatenate', 'stack', 'triu', 'tril', 'where', 'nansum', 'nanmean',
911
'nanprod', 'nanmin', 'nanmax', 'nanreduce', 'roll', 'eye', 'full', 'full_like', 'zeros', 'zeros_like', 'ones', 'ones_like', 'kron', 'argwhere',
10-
'isposinf', 'isneginf']
12+
'isposinf', 'isneginf', 'result_type']

sparse/coo/core.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,7 @@ def clip(self, min=None, max=None, out=None):
20662066
return self.__array_ufunc__(np.clip, '__call__', self, a_min=min,
20672067
a_max=max, out=out)
20682068

2069-
def astype(self, dtype):
2069+
def astype(self, dtype, copy=True):
20702070
"""
20712071
Copy of the array, cast to a specified type.
20722072
@@ -2077,7 +2077,7 @@ def astype(self, dtype):
20772077
:obj:`COO.elemwise`: Apply an arbitrary element-wise function to one or two
20782078
arguments.
20792079
"""
2080-
return self.__array_ufunc__(np.ndarray.astype, '__call__', self, dtype=dtype)
2080+
return self.__array_ufunc__(np.ndarray.astype, '__call__', self, dtype=dtype, copy=copy)
20812081

20822082
def maybe_densify(self, max_size=1000, min_density=0.25):
20832083
"""

0 commit comments

Comments
 (0)