scipy.sparse.dok_matrix.

astype#

dok_matrix.astype(dtype, casting='unsafe', copy=True)[source]#

Cast the array/matrix elements to a specified type.

Parameters:
dtypestring or numpy dtype

Typecode or data-type to which to cast the data.

casting{β€˜no’, β€˜equiv’, β€˜safe’, β€˜same_kind’, β€˜unsafe’}, optional

Controls what kind of data casting may occur. Defaults to β€˜unsafe’ for backwards compatibility. β€˜no’ means the data types should not be cast at all. β€˜equiv’ means only byte-order changes are allowed. β€˜safe’ means only casts which can preserve values are allowed. β€˜same_kind’ means only safe casts or casts within a kind, like float64 to float32, are allowed. β€˜unsafe’ means any data conversions may be done.

copybool, optional

If copy is False, the result might share some memory with this array/matrix. If copy is True, it is guaranteed that the result and this array/matrix do not share any memory.