File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -156,8 +156,23 @@ def astype(data, **kwargs):
156156 # FIXME: This should no longer be necessary in future versions of sparse
157157 # Current versions of sparse (v0.10.0) don't support the "casting" kwarg
158158 # This was fixed by https://github.com/pydata/sparse/pull/392
159- if "casting" in repr (e ):
159+ try :
160+ import sparse
161+ except ImportError :
162+ sparse = None
163+ if (
164+ "got an unexpected keyword argument 'casting'" in repr (e )
165+ and sparse is not None
166+ and isinstance (data , sparse ._coo .core .COO )
167+ ):
168+ warnings .warn (
169+ "The current version of sparse does not support the 'casting' argument. It will be ignored in the call to astype()." ,
170+ RuntimeWarning ,
171+ stacklevel = 4 ,
172+ )
160173 kwargs .pop ("casting" )
174+ else :
175+ raise e
161176 return data .astype (** kwargs )
162177
163178
You can’t perform that action at this time.
0 commit comments