Convert

class npdsp.Convert(dtype: DTypeLike, name: str | None = None)[source]

Convert the data type of a signal.

Parameters:
  • dtype (numpy.typing.DTypeLike) – NumPy data type to convert the input signal to.

  • name (str, optional) – Optional name used to identify the block within a pipeline.

Notes

Conversion uses numpy.ndarray.astype() with copy=False. NumPy may still create a copy when the requested data type differs from the input data type.

Examples

>>> block = Convert(np.float32)
>>> block([1, 2, 3]).dtype
dtype('float32')
process(x: NDArray[Any]) NDArray[Any][source]

Convert the input signal to the configured data type.

Parameters:

x (Signal) – Input signal.

Returns:

Signal converted to self.dtype.

Return type:

Signal